-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoTurtle03.kt
37 lines (33 loc) · 1.15 KB
/
DemoTurtle03.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Drawing shape contours aligned to the turtle's orientation.
*/
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.turtle.contour
import org.openrndr.extra.turtle.turtle
import org.openrndr.math.Vector2
import org.openrndr.shape.Circle
fun main() {
application {
program {
// turtle returns List<ShapeContour>
val contours = turtle(drawer.bounds.center + Vector2(-100.0, 100.0)) {
forward(100.0)
// let the turtle draw a full a circle
val circle0 = Circle(Vector2.ZERO, 100.0)
contour(circle0.contour)
// let the turtle draw a half circle
val circle1 = Circle(Vector2.ZERO, 50.0)
contour(circle1.contour.sub(0.0, 0.5))
// let the turtle draw another half circle
val circle2 = Circle(Vector2.ZERO, 25.0)
contour(circle2.contour.sub(0.0, 0.5))
}
extend {
// draw the contours
drawer.stroke = ColorRGBa.PINK
drawer.contours(contours)
}
}
}
}