Commit 711c728b authored by Roman Sedaikin's avatar Roman Sedaikin

Added [ColorSpace.sRGBLinear], refactored [Path] and [Paint].

parent 000e45b8
...@@ -22,6 +22,7 @@ class ColorSpace : Managed { ...@@ -22,6 +22,7 @@ class ColorSpace : Managed {
} }
val sRGB = ColorSpace(_nMakeSRGB(), false) val sRGB = ColorSpace(_nMakeSRGB(), false)
val sRGBLinear = ColorSpace(_nMakeSRGBLinear(), false)
val displayP3 = ColorSpace(_nMakeDisplayP3(), false) val displayP3 = ColorSpace(_nMakeDisplayP3(), false)
} }
......
...@@ -438,13 +438,16 @@ class Paint : Managed { ...@@ -438,13 +438,16 @@ class Paint : Managed {
* *
* @return zero and greater miter limit * @return zero and greater miter limit
*/ */
val strokeMiter: Float var strokeMiter: Float
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
_nGetStrokeMiter(_ptr) _nGetStrokeMiter(_ptr)
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setStrokeMiter(value)
}
/** /**
* Sets the limit at which a sharp corner is drawn beveled. * Sets the limit at which a sharp corner is drawn beveled.
...@@ -465,13 +468,16 @@ class Paint : Managed { ...@@ -465,13 +468,16 @@ class Paint : Managed {
/** /**
* @return the geometry drawn at the beginning and end of strokes. * @return the geometry drawn at the beginning and end of strokes.
*/ */
val strokeCap: PaintStrokeCap var strokeCap: PaintStrokeCap
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
PaintStrokeCap.values().get(_nGetStrokeCap(_ptr)) PaintStrokeCap.values().get(_nGetStrokeCap(_ptr))
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setStrokeCap(value)
}
/** /**
* Sets the geometry drawn at the beginning and end of strokes. * Sets the geometry drawn at the beginning and end of strokes.
...@@ -492,13 +498,16 @@ class Paint : Managed { ...@@ -492,13 +498,16 @@ class Paint : Managed {
/** /**
* @return the geometry drawn at the corners of strokes. * @return the geometry drawn at the corners of strokes.
*/ */
val strokeJoin: PaintStrokeJoin var strokeJoin: PaintStrokeJoin
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
PaintStrokeJoin.values().get(_nGetStrokeJoin(_ptr)) PaintStrokeJoin.values().get(_nGetStrokeJoin(_ptr))
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setStrokeJoin(value)
}
/** /**
* Sets the geometry drawn at the corners of strokes. * Sets the geometry drawn at the corners of strokes.
...@@ -564,7 +573,7 @@ class Paint : Managed { ...@@ -564,7 +573,7 @@ class Paint : Managed {
* @return [Shader] or null * @return [Shader] or null
* @see [https://fiddle.skia.org/c/@Paint_refShader](https://fiddle.skia.org/c/@Paint_refShader) * @see [https://fiddle.skia.org/c/@Paint_refShader](https://fiddle.skia.org/c/@Paint_refShader)
*/ */
val shader: Shader? var shader: Shader?
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
val shaderPtr = _nGetShader(_ptr) val shaderPtr = _nGetShader(_ptr)
...@@ -572,6 +581,9 @@ class Paint : Managed { ...@@ -572,6 +581,9 @@ class Paint : Managed {
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setShader(value)
}
/** /**
* @param shader how geometry is filled with color; if null, color is used instead * @param shader how geometry is filled with color; if null, color is used instead
...@@ -594,7 +606,7 @@ class Paint : Managed { ...@@ -594,7 +606,7 @@ class Paint : Managed {
* @return [ColorFilter] or null * @return [ColorFilter] or null
* @see [https://fiddle.skia.org/c/@Paint_refColorFilter](https://fiddle.skia.org/c/@Paint_refColorFilter) * @see [https://fiddle.skia.org/c/@Paint_refColorFilter](https://fiddle.skia.org/c/@Paint_refColorFilter)
*/ */
val colorFilter: ColorFilter? var colorFilter: ColorFilter?
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
val colorFilterPtr = _nGetColorFilter(_ptr) val colorFilterPtr = _nGetColorFilter(_ptr)
...@@ -602,6 +614,9 @@ class Paint : Managed { ...@@ -602,6 +614,9 @@ class Paint : Managed {
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setColorFilter(value)
}
/** /**
* @param colorFilter [ColorFilter] to apply to subsequent draw * @param colorFilter [ColorFilter] to apply to subsequent draw
...@@ -628,13 +643,16 @@ class Paint : Managed { ...@@ -628,13 +643,16 @@ class Paint : Managed {
* *
* @return mode used to combine source color with destination color * @return mode used to combine source color with destination color
*/ */
val blendMode: BlendMode? var blendMode: BlendMode?
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
BlendMode.values().get(_nGetBlendMode(_ptr)) BlendMode.values().get(_nGetBlendMode(_ptr))
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setBlendMode(value)
}
/** /**
* @return true if BlendMode is BlendMode.SRC_OVER, the default. * @return true if BlendMode is BlendMode.SRC_OVER, the default.
...@@ -648,10 +666,10 @@ class Paint : Managed { ...@@ -648,10 +666,10 @@ class Paint : Managed {
* @param mode BlendMode used to combine source color and destination * @param mode BlendMode used to combine source color and destination
* @return this * @return this
*/ */
fun setBlendMode(mode: BlendMode): Paint { fun setBlendMode(mode: BlendMode?): Paint {
assert(mode != null) { "Paint::setBlendMode expected mode != null" } assert(mode != null) { "Paint::setBlendMode expected mode != null" }
Stats.onNativeCall() Stats.onNativeCall()
_nSetBlendMode(_ptr, mode.ordinal) _nSetBlendMode(_ptr, mode!!.ordinal)
return this return this
} }
...@@ -659,7 +677,7 @@ class Paint : Managed { ...@@ -659,7 +677,7 @@ class Paint : Managed {
* @return [PathEffect] or null * @return [PathEffect] or null
* @see [https://fiddle.skia.org/c/@Paint_refPathEffect](https://fiddle.skia.org/c/@Paint_refPathEffect) * @see [https://fiddle.skia.org/c/@Paint_refPathEffect](https://fiddle.skia.org/c/@Paint_refPathEffect)
*/ */
val pathEffect: PathEffect? var pathEffect: PathEffect?
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
val pathEffectPtr = _nGetPathEffect(_ptr) val pathEffectPtr = _nGetPathEffect(_ptr)
...@@ -667,6 +685,9 @@ class Paint : Managed { ...@@ -667,6 +685,9 @@ class Paint : Managed {
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setPathEffect(value)
}
/** /**
* @param p replace [Path] with a modification when drawn * @param p replace [Path] with a modification when drawn
......
...@@ -447,13 +447,16 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR), ...@@ -447,13 +447,16 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
} }
} }
val fillMode: PathFillMode var fillMode: PathFillMode
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
PathFillMode.values().get(_nGetFillMode(_ptr)) PathFillMode.values().get(_nGetFillMode(_ptr))
} finally { } finally {
Reference.reachabilityFence(this) Reference.reachabilityFence(this)
} }
set(value) {
setFillMode(value)
}
fun setFillMode(fillMode: PathFillMode): Path { fun setFillMode(fillMode: PathFillMode): Path {
Stats.onNativeCall() Stats.onNativeCall()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment