-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoHobbyCurve3D01.kt
48 lines (43 loc) · 1.54 KB
/
DemoHobbyCurve3D01.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
38
39
40
41
42
43
44
45
46
47
48
package hobbycurve
import org.openrndr.WindowMultisample
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolated
import org.openrndr.extra.noise.scatter
import org.openrndr.extra.noise.uniform
import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
import org.openrndr.math.Vector3
import kotlin.math.cos
import kotlin.random.Random
fun main() = application {
configure {
width = 720
height = 720
multisample = WindowMultisample.SampleCount(4)
}
program {
val pts = drawer.bounds.scatter(30.0, distanceToEdge = 200.0, random = Random(3000))
extend {
drawer.stroke = ColorRGBa.PINK
drawer.strokeWeight = 4.0
drawer.fill = null
val r = Random(3000)
val hobby3D = hobbyCurve(
pts.map { it.xy0 + Vector3(0.0, 0.0, Double.uniform(-360.0, 360.0, r)) },
true,
tensions = { chordIndex: Int ->
Pair(
cos(seconds + chordIndex * 0.1) * 0.5 + 0.5,
cos(seconds + (1.0 + chordIndex) * 0.1) * 0.5 + 0.5
)
})
drawer.isolated {
drawer.ortho(0.0, width.toDouble(), height.toDouble(), 0.0, -4000.0, 4000.0)
drawer.translate(width / 2.0, height / 2.0)
drawer.rotate(Vector3.UNIT_Y, seconds * 16.0)
drawer.translate(-width / 2.0, -height / 2.0)
drawer.path(hobby3D)
}
}
}
}