-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDemoFCurveSheet01.kt
54 lines (44 loc) · 2 KB
/
DemoFCurveSheet01.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
49
50
51
52
53
54
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extra.fcurve.efcurve
import org.openrndr.extra.fcurve.fcurve
import org.openrndr.math.Vector2
fun main() = application {
configure {
width = 720
height = 720
}
program {
val fcurveTexts = listOf(
//"(l 35.0 25.0 h {175-35})[4]", // linear steps
"(c 33% 0% 67% 67% 35.0 25.0 h {175-35})[4]", // ease-in steps
"(c 50% 50% 50% 100% 35.0 25.0 h {175-35})[4]", // ease-out steps
"(c 50% 0% 50% 100% 35.0 25.0 h {175-35})[4]", // ease-in-out steps
"(c 95% 0% 100% 100% 35.0 25.0 h {175-35})[4]", // arc-in steps
"(c 0% 0% 5% 100% 35.0 25.0 h {175-35})[4]", // arc-out steps
"(c 95% 0% 100% 100% 17.5 12.5 c 0% 0% 5% 100% 17.5 12.5 h {175-35})[4]", // arc-out steps
)
val fcurves = fcurveTexts.map { fcurve(efcurve(it)) }
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.fontMap = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 16.0)
drawer.translate(10.0, 20.0)
drawer.stroke = ColorRGBa.PINK
drawer.lineSegment(mouse.position.x - 10.0, 0.0, mouse.position.x - 10.0, height * 1.0)
fun color(i: Int): ColorRGBa =
ColorRGBa.BLUE.toHSVa().shiftHue(i * 30.0).saturate(0.5).shade(0.9).toRGBa()
for (i in fcurveTexts.indices) {
drawer.fill = color(i)
drawer.text(fcurveTexts[i], 0.0, 120.0)
drawer.stroke = color(i).opacify(0.25)
drawer.lineSegment(0.0, 100.0, width - 20.0, 100.0)
drawer.stroke = color(i)
val y = 100.0 - fcurves[i].value(mouse.position.x - 10.0)
drawer.contours(fcurves[i].contours(offset = Vector2(0.0, 100.0)))
drawer.circle(mouse.position.x - 10.0, y, 10.0)
drawer.translate(0.0, 110.0)
}
}
}
}