MCPcopy Create free account
hub / github.com/Snapchat/Valdi / ShapeView

Class ShapeView

valdi/src/java/com/snap/valdi/views/ShapeView.kt:18–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16private val DEFAULT_COLOR = Color.TRANSPARENT
17
18@Keep
19class ShapeView(context: Context) : View(context), ValdiRecyclableView {
20
21 companion object {
22 private const val TAG = "ShapeView"
23 }
24
25 var strokeStart: Float = 0.0f
26 set(value) {
27 if (field != value) {
28 field = value
29 invalidate()
30 }
31 }
32
33 var strokeEnd: Float = 1.0f
34 set(value) {
35 if (field != value) {
36 field = value
37 invalidate()
38 }
39 }
40
41 private val geometricPath = GeometricPath()
42 private val strokePaint = Paint()
43 private val fillPaint = Paint()
44 private val coordinateResolver = CoordinateResolver(context)
45 private var pathInterpolator: PathInterpolator? = null
46
47 init {
48 strokePaint.strokeJoin = Paint.Join.MITER
49 strokePaint.strokeCap = Paint.Cap.BUTT
50 strokePaint.style = Paint.Style.STROKE
51
52 fillPaint.style = Paint.Style.FILL
53
54 strokePaint.isAntiAlias = true
55 fillPaint.isAntiAlias = true
56
57 resetStrokeColor()
58 resetFillColor()
59 resetStrokeWidth()
60 resetStrokeCap()
61 resetStrokeJoin()
62 }
63
64 fun setPathData(pathData: ByteArray?) {
65 geometricPath.setPathData(pathData)
66 pathInterpolator?.reset()
67 invalidate()
68 }
69
70 fun setStrokeWidth(strokeWidth: Float) {
71 strokePaint.strokeWidth = coordinateResolver.toPixelF(strokeWidth)
72 invalidate()
73 }
74
75 fun resetStrokeWidth() {

Callers

nothing calls this directly

Calls 3

GeometricPathClass · 0.50
PaintClass · 0.50
CoordinateResolverClass · 0.50

Tested by

no test coverage detected