Skip to content

Instantly share code, notes, and snippets.

@aligkts
Last active June 16, 2019 15:03
Show Gist options
  • Save aligkts/2c69d1ba82a56a15fa5d1b020b50f160 to your computer and use it in GitHub Desktop.
Save aligkts/2c69d1ba82a56a15fa5d1b020b50f160 to your computer and use it in GitHub Desktop.
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