Skip to content

Commit 4d86812

Browse files
committed
field names changed.
1 parent 4e2bc1b commit 4d86812

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

library/src/main/java/io/syslogic/colorpicker/compose/AlphaPainter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AlphaPainter(intrinsicSize: Size) : BasePainter(intrinsicSize) {
3737
drawRect(
3838
size = size,
3939
color = Color(borderStrokeColor),
40-
topLeft = Offset(outline.left, outline.top),
40+
topLeft = Offset(outerRect.left, outerRect.top),
4141
style = Stroke(width = borderStrokeWidth,
4242
pathEffect = PathEffect.cornerPathEffect(borderCornerRadius)
4343
)
@@ -49,8 +49,8 @@ class AlphaPainter(intrinsicSize: Size) : BasePainter(intrinsicSize) {
4949
/* Outer rectangle (dark) */
5050
drawRoundRect(
5151
color = Color(trackerStrokeColorOuter),
52-
size = Size(alphaTrackerWidth, rect.height()),
53-
topLeft = Offset(p.x - (alphaTrackerWidth / 2), rect.top),
52+
size = Size(alphaTrackerWidth, innerRect.height()),
53+
topLeft = Offset(p.x - (alphaTrackerWidth / 2), innerRect.top),
5454
style = Stroke(width = trackerStrokeWidth,
5555
pathEffect = PathEffect.cornerPathEffect(trackerCornerRadius)
5656
)
@@ -59,8 +59,8 @@ class AlphaPainter(intrinsicSize: Size) : BasePainter(intrinsicSize) {
5959
/* Inner rectangle (light) */
6060
drawRoundRect(
6161
color = Color(trackerStrokeColorInner),
62-
size = Size(alphaTrackerWidth - 2, rect.height() - 2),
63-
topLeft = Offset(p.x - (alphaTrackerWidth / 2) + 1, rect.top + 1),
62+
size = Size(alphaTrackerWidth - 2, innerRect.height() - 2),
63+
topLeft = Offset(p.x - (alphaTrackerWidth / 2) + 1, innerRect.top + 1),
6464
style = Stroke(width = trackerStrokeWidth,
6565
pathEffect = PathEffect.cornerPathEffect(trackerCornerRadius)
6666
)

library/src/main/java/io/syslogic/colorpicker/compose/BasePainter.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ abstract class BasePainter(override val intrinsicSize: Size) : Painter() {
5555
protected lateinit var canvas: NativeCanvas
5656

5757
/** Boundaries */
58-
protected lateinit var outline: RectF
59-
protected lateinit var rect: RectF
58+
protected lateinit var outerRect: RectF
59+
protected lateinit var innerRect: RectF
6060

6161
/** Being called by all implementations onDraw. */
6262
fun setCanvas(drawContext: DrawContext, density: Float) {
@@ -81,13 +81,13 @@ abstract class BasePainter(override val intrinsicSize: Size) : Painter() {
8181
/* Native Canvas */
8282
canvas = drawContext.canvas.nativeCanvas
8383
val bounds: Rect = canvas.clipBounds
84-
outline = RectF(
84+
outerRect = RectF(
8585
bounds.left.toFloat(),
8686
bounds.top.toFloat(),
8787
bounds.right.toFloat(),
8888
bounds.bottom.toFloat()
8989
)
90-
rect = RectF(
90+
innerRect = RectF(
9191
bounds.left.toFloat() + borderStrokeWidth,
9292
bounds.top.toFloat() + borderStrokeWidth,
9393
bounds.right.toFloat() - borderStrokeWidth,
@@ -101,8 +101,8 @@ abstract class BasePainter(override val intrinsicSize: Size) : Painter() {
101101
* @return the {@link Point} where AlphaPainter shall draw the tracker rectangle.
102102
*/
103103
fun alphaToPoint(value: Float): Point {
104-
val x: Int = (value * rect.width()).toInt()
105-
val y: Int = rect.top.toInt()
104+
val x: Int = (value * innerRect.width()).toInt()
105+
val y: Int = innerRect.top.toInt()
106106
return Point(x, y)
107107
}
108108

@@ -112,8 +112,8 @@ abstract class BasePainter(override val intrinsicSize: Size) : Painter() {
112112
* @return the {@link Point} where HuePainter shall draw the tracker rectangle.
113113
*/
114114
fun hueToPoint(value: Float): Point {
115-
val x: Int = rect.left.toInt()
116-
val y: Int = (rect.height() - value * rect.height() / 360f + rect.top).toInt()
115+
val x: Int = innerRect.left.toInt()
116+
val y: Int = (innerRect.height() - value * innerRect.height() / 360f + innerRect.top).toInt()
117117
return Point(x, y)
118118
}
119119

@@ -124,8 +124,8 @@ abstract class BasePainter(override val intrinsicSize: Size) : Painter() {
124124
* @return the Point where SatValPainter shall draw the tracker circle.
125125
*/
126126
fun satValToPoint(saturation: Float, value: Float): Point {
127-
val x: Int = (saturation * rect.width() + rect.left).toInt()
128-
val y: Int = ((1f - value) * rect.height() + rect.top).toInt()
127+
val x: Int = (saturation * innerRect.width() + innerRect.left).toInt()
128+
val y: Int = ((1f - value) * innerRect.height() + innerRect.top).toInt()
129129
return Point(x, y)
130130
}
131131
}

library/src/main/java/io/syslogic/colorpicker/compose/ColorPainter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ColorPainter(intrinsicSize: Size) : BasePainter(intrinsicSize) {
3232
drawRect(
3333
size = size,
3434
color = Color(borderStrokeColor),
35-
topLeft = Offset(outline.left, outline.top),
35+
topLeft = Offset(outerRect.left, outerRect.top),
3636
style = Stroke(width = borderStrokeWidth,
3737
pathEffect = PathEffect.cornerPathEffect(borderCornerRadius)
3838
)

library/src/main/java/io/syslogic/colorpicker/compose/HuePainter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ class HuePainter(intrinsicSize: Size) : BasePainter(intrinsicSize) {
3737
drawRect(
3838
size = size,
3939
color = Color(borderStrokeColor),
40-
topLeft = Offset(outline.left, outline.top),
40+
topLeft = Offset(outerRect.left, outerRect.top),
4141
style = Stroke(width = borderStrokeWidth,
4242
pathEffect = PathEffect.cornerPathEffect(borderCornerRadius)
4343
)
4444
)
4545

4646
/* Vertical Tracker */
4747
val p: Point = hueToPoint(value)
48-
val offset = Offset(rect.left, p.y - (hueTrackerHeight / 2))
48+
val offset = Offset(innerRect.left, p.y - (hueTrackerHeight / 2))
4949
drawRoundRect(
5050
color = Color(trackerStrokeColorOuter),
51-
size = Size(rect.width(), hueTrackerHeight),
51+
size = Size(innerRect.width(), hueTrackerHeight),
5252
topLeft = offset,
5353
style = Stroke(width = trackerStrokeWidth,
5454
pathEffect = PathEffect.cornerPathEffect(trackerCornerRadius)

library/src/main/java/io/syslogic/colorpicker/compose/SatValPainter.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ class SatValPainter(intrinsicSize: Size) : BasePainter(intrinsicSize) {
3333
val alpha: Int = getAlpha().times(255).toInt()
3434
val color: Int = HSVToColor(alpha, floatArrayOf(getHue(), 1F, 1F))
3535
val mSaturationShader = LinearGradientShader (
36-
from = Offset(rect.right, rect.top),
37-
to = Offset(rect.left, rect.top),
36+
from = Offset(innerRect.right, innerRect.top),
37+
to = Offset(innerRect.left, innerRect.top),
3838
tileMode = TileMode.Clamp,
3939
colors = listOf(Color(color), Color.White)
4040
)
4141

4242
/* Value Shader */
4343
val mContrastShader = LinearGradientShader(
44-
from = Offset(rect.left, rect.bottom),
45-
to = Offset(rect.left, rect.top),
44+
from = Offset(innerRect.left, innerRect.bottom),
45+
to = Offset(innerRect.left, innerRect.top),
4646
tileMode = TileMode.Clamp,
4747
colors = listOf(Color.Black, Color.White)
4848
)
4949

5050
/* Compose Shader */
5151
val composition = Paint()
5252
composition.shader = ComposeShader(mContrastShader, mSaturationShader, PorterDuff.Mode.MULTIPLY)
53-
canvas.drawRect(rect, composition)
53+
canvas.drawRect(innerRect, composition)
5454

5555
/* Border */
5656
val border = Paint()
5757
border.style = Paint.Style.STROKE
5858
border.strokeWidth = borderStrokeWidth
5959
border.color = borderStrokeColor
60-
canvas.drawRect(outline, border)
60+
canvas.drawRect(outerRect, border)
6161

6262
/* Tracker */
6363
val p: Point = satValToPoint(getSat(), getValue())

0 commit comments

Comments
 (0)