Last active
June 16, 2019 15:03
-
-
Save aligkts/2c69d1ba82a56a15fa5d1b020b50f160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RectOverlay(private val graphicOverlay: GraphicOverlay, | |
private val rect: Rect) : GraphicOverlay.Graphic(graphicOverlay) { | |
private val RECT_COLOR = Color.RED | |
private val strokeWidth = 4.0f | |
private val rectPaint: Paint = Paint() | |
init { | |
rectPaint.color = RECT_COLOR | |
rectPaint.style = Paint.Style.STROKE | |
rectPaint.strokeWidth = strokeWidth | |
postInvalidate() | |
} | |
override fun draw(canvas: Canvas) { | |
val rectF = RectF(rect) | |
rectF.left = translateX(rectF.left) | |
rectF.right = translateX(rectF.right) | |
rectF.top = translateY(rectF.top) | |
rectF.bottom = translateY(rectF.bottom) | |
canvas.drawRect(rectF, rectPaint) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment