Files
orx/openrndr-demos/src/demo/kotlin/DemoContourIntersections03.kt
Abe Pazos 7c97b80728 Tweak contour intersection demos
1. Change size of circles indicating intersections
to make it obvious that the circles are not filled,
and that only part of the intersecting shapes are
being drawn.

2. Make intersecting shapes more visible by using
different colors.

3. Animate self-intersecting shape.
2020-08-01 14:30:47 +02:00

36 lines
1.2 KiB
Kotlin

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.LineJoin
import org.openrndr.math.Vector2
import org.openrndr.shape.ShapeContour
import org.openrndr.shape.intersections
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
fun main() = application {
program {
val points = 200
extend {
val contour = ShapeContour.fromPoints(
List(points) {
val a = PI * 2 * it / points
val x = (200 + 50 * cos(a * 2)) * sin(a * 3 + sin(a))
val y = 150 * cos(a * 2 + seconds * 0.2)
Vector2(x, y)
}, closed = true
)
val ints = intersections(contour, contour)
drawer.run {
clear(ColorRGBa.WHITE)
translate(width * 0.5, height * 0.5)
fill = null
stroke = ColorRGBa.BLACK
lineJoin = LineJoin.ROUND
contour(contour)
fill = ColorRGBa.PINK.opacify(0.3)
circles(ints.map { it.position }, 10.0)
}
}
}
}