Repository navigation
Expand file tree
/
Copy pathShapeBuilder.kt
More file actions
69 lines (55 loc) · 1.5 KB
/
Copy pathShapeBuilder.kt
File metadata and controls
69 lines (55 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package ja.burhanrashid52.photoeditor.shape
import android.graphics.Color
import android.graphics.Paint
import androidx.annotation.ColorInt
/**
*
*
* Used to hold a Shape parameters: type, size, opacity and color.
*
*/
class ShapeBuilder {
var shapeType: ShapeType = ShapeType.Brush
private set
var shapeSize: Float = DEFAULT_SHAPE_SIZE
private set
@androidx.annotation.IntRange(from = 0, to = 255)
var shapeOpacity: Int? = DEFAULT_SHAPE_OPACITY
private set
@get:ColorInt
@ColorInt
var shapeColor: Int = DEFAULT_SHAPE_COLOR
private set
var shapePaintStyle: Paint.Style = Paint.Style.STROKE
private set
fun withShapeType(shapeType: ShapeType): ShapeBuilder {
this.shapeType = shapeType
return this
}
fun withShapeSize(size: Float): ShapeBuilder {
shapeSize = size
return this
}
fun withShapeOpacity(
@androidx.annotation.IntRange(
from = 0,
to = 255
) opacity: Int?
): ShapeBuilder {
shapeOpacity = opacity
return this
}
fun withShapeColor(@ColorInt color: Int): ShapeBuilder {
shapeColor = color
return this
}
fun withShapePaintStyle(style: Paint.Style): ShapeBuilder {
shapePaintStyle = style
return this
}
companion object {
const val DEFAULT_SHAPE_SIZE = 25.0f
val DEFAULT_SHAPE_OPACITY = null
const val DEFAULT_SHAPE_COLOR = Color.BLACK
}
}