From 3da0040b07b66470c72ce2d57a480b2658c085f2 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Mon, 9 Mar 2020 12:50:22 +0100 Subject: [PATCH] Add Drawer extension methods for rounded rectangle --- orx-shapes/src/main/kotlin/RoundedRectangle.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/orx-shapes/src/main/kotlin/RoundedRectangle.kt b/orx-shapes/src/main/kotlin/RoundedRectangle.kt index 29d4a196..4c88a302 100644 --- a/orx-shapes/src/main/kotlin/RoundedRectangle.kt +++ b/orx-shapes/src/main/kotlin/RoundedRectangle.kt @@ -1,3 +1,4 @@ +import org.openrndr.draw.Drawer import org.openrndr.math.Vector2 import org.openrndr.shape.contour import kotlin.math.min @@ -33,4 +34,13 @@ class RoundedRectangle(val corner: Vector2, val width: Double, val height: Doubl curveTo(Vector2(x, y), Vector2(x + r, y)) close() } -} \ No newline at end of file +} + +fun Drawer.roundedRectangle(x: Double, y: Double, width: Double, height: Double, radius: Double) = + contour(RoundedRectangle(x, y, width, height, radius).contour) + +fun Drawer.roundedRectangle(position: Vector2, width: Double, height: Double, radius: Double) = + contour(RoundedRectangle(position, width, height, radius).contour) + +fun Drawer.roundedRectangle(roundedRectangle: RoundedRectangle) = + contour(roundedRectangle.contour) \ No newline at end of file