From c5c60db7c88bff00e7611acc8e97b6b5522cac02 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Mon, 3 Aug 2020 09:03:14 +0200 Subject: [PATCH] [openrndr-demos] Add DemoContourNearest01 --- .../src/demo/kotlin/DemoContourNearest01.kt | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 openrndr-demos/src/demo/kotlin/DemoContourNearest01.kt diff --git a/openrndr-demos/src/demo/kotlin/DemoContourNearest01.kt b/openrndr-demos/src/demo/kotlin/DemoContourNearest01.kt new file mode 100644 index 00000000..de4d26c9 --- /dev/null +++ b/openrndr-demos/src/demo/kotlin/DemoContourNearest01.kt @@ -0,0 +1,54 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extra.noise.simplex +import org.openrndr.shape.OrientedEllipse + +fun main() { + application { + program { + extend { + drawer.clear(ColorRGBa.BLACK) + drawer.fill = null + + val offset = seconds * 0.1 + val contours = listOf( + OrientedEllipse( + simplex(320, offset)*width/2.0 + width/2.0, + simplex(3120, offset)*height/2.0 + height/2.0, + simplex(3420, offset)*50.0 + 80.0, + simplex(7521, offset)*50.0+ 80.0, + simplex(3212, offset)*180.0+180.0 + ).contour, + OrientedEllipse( + simplex(5320, offset)*width/2.0 + width/2.0, + simplex(73120, offset)*height/2.0 + height/2.0, + simplex(23420, offset)*50.0 + 80.0, + simplex(47521, offset)*50.0+ 80.0, + simplex(33212, offset)*180.0+180.0 + ).contour + ) + drawer.fill = null + drawer.stroke = ColorRGBa.PINK + for (contour in contours) { + drawer.contour(contour) + } + + for (j in contours.indices) { + for (i in 0 until j) { + val eqj = contours[j].equidistantPositions(50) + val eqi = contours[i].equidistantPositions(50) + + for (p in eqj) { + val q = contours[i].nearest(p).position + drawer.lineSegment(p, q) + } + for (p in eqi) { + val q = contours[j].nearest(p).position + drawer.lineSegment(p, q) + } + } + } + } + } + } +} \ No newline at end of file