From 83b8faed94bc87b22754e44d6ba61f16380f377f Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Wed, 17 Jan 2024 00:07:22 +0100 Subject: [PATCH] [orx-shapes] Add Tunni point/line operations --- .../kotlin/tunni/DemoTunniAdjuster01.kt | 31 ++++++++++++++++ .../jvmDemo/kotlin/tunni/DemoTunniPoint01.kt | 36 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniAdjuster01.kt create mode 100644 orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniPoint01.kt diff --git a/orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniAdjuster01.kt b/orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniAdjuster01.kt new file mode 100644 index 00000000..69f5ec20 --- /dev/null +++ b/orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniAdjuster01.kt @@ -0,0 +1,31 @@ +package tunni + +import contour +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extra.shapes.adjust.adjustContour +import org.openrndr.extra.shapes.tunni.tunniLine +import org.openrndr.shape.Circle +import kotlin.math.cos + +fun main() { + application { + program { + extend { + val c = Circle(drawer.bounds.center, 200.0).contour + val c2 = adjustContour(c) { + selectEdges { it -> true } + for (e in edges) { + val tl = e.tunniLine + e.withTunniLine(tl.position(0.5) + tl.normal * cos(seconds)*200.0) + } + } + for (s in c2.segments) { + drawer.stroke = ColorRGBa.WHITE + drawer.lineSegment(s.tunniLine) + } + drawer.contour(c2) + } + } + } +} \ No newline at end of file diff --git a/orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniPoint01.kt b/orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniPoint01.kt new file mode 100644 index 00000000..048dbce8 --- /dev/null +++ b/orx-shapes/src/jvmDemo/kotlin/tunni/DemoTunniPoint01.kt @@ -0,0 +1,36 @@ +package tunni + +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extra.shapes.tunni.tunniLine +import org.openrndr.extra.shapes.tunni.tunniPoint +import org.openrndr.extra.shapes.tunni.withTunniLine +import org.openrndr.shape.Circle +import kotlin.math.cos + +fun main() { + application { + program { + extend { + drawer.clear(ColorRGBa.WHITE) + drawer.fill = ColorRGBa.BLACK + val c = Circle(drawer.bounds.center, 200.0).contour + + drawer.fill = null + for (s in c.segments) { + val tp = s.tunniPoint + println(tp) + drawer.circle(tp, 10.0) + val sc = s.cubic + drawer.lineSegment(sc.control[0], sc.control[1]) + //drawer.segment(s.withTunniPoint(tp + (mouse.position - drawer.bounds.center)/2.0)) + drawer.segment(s.withTunniLine(s.tunniLine.position(0.5) + s.tunniLine.normal * cos(seconds) * 40.0)) + + } + + drawer.contour(c) + + } + } + } +} \ No newline at end of file