From e4f9903ffcbc90d8bd9cf84abb8bc9236cec9e19 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sat, 4 May 2024 10:36:39 +0200 Subject: [PATCH] [orx-shapes] Fix ShapeContour.roundCorners, add demo. Closes #333 --- .../kotlin/operators/ChamferCorners.kt | 2 +- .../kotlin/operators/DemoRoundCorners01.kt | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 orx-shapes/src/jvmDemo/kotlin/operators/DemoRoundCorners01.kt diff --git a/orx-shapes/src/commonMain/kotlin/operators/ChamferCorners.kt b/orx-shapes/src/commonMain/kotlin/operators/ChamferCorners.kt index ed505fc3..c5fde689 100644 --- a/orx-shapes/src/commonMain/kotlin/operators/ChamferCorners.kt +++ b/orx-shapes/src/commonMain/kotlin/operators/ChamferCorners.kt @@ -97,7 +97,7 @@ fun ShapeContour.chamferCorners( moveOrLineTo(q0) chamfer(q0, s0.end, q1) } else { - lineTo(s0.end) + moveOrLineTo(s0.end) } } } diff --git a/orx-shapes/src/jvmDemo/kotlin/operators/DemoRoundCorners01.kt b/orx-shapes/src/jvmDemo/kotlin/operators/DemoRoundCorners01.kt new file mode 100644 index 00000000..aa002b81 --- /dev/null +++ b/orx-shapes/src/jvmDemo/kotlin/operators/DemoRoundCorners01.kt @@ -0,0 +1,25 @@ +package operators + +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extra.shapes.operators.roundCorners +import org.openrndr.extra.shapes.primitives.regularStar + +fun main() = application { + configure { + width = 720 + height = 720 + } + program { + val rp = regularStar(7, 150.0, 300.0, drawer.bounds.center) + extend { + drawer.clear(ColorRGBa.WHITE) + drawer.fill = null + drawer.stroke = ColorRGBa.BLACK.opacify(0.2) + for (i in 1 until 8 ) { + val r = rp.roundCorners(i * 15.0).close() + drawer.contour(r) + } + } + } +} \ No newline at end of file