-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoBezierPatch04.kt
46 lines (42 loc) · 1.46 KB
/
DemoBezierPatch04.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
package bezierpatch
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.shapes.bezierpatches.bezierPatch
import org.openrndr.shape.Circle
/**
* Shows how to get positions and gradient values of those positions
* from a [bezierPatch]
*
* You can think of bezierPatch.position() as requesting points
* in a wavy flag (the bezier patch) using normalized uv coordinates.
*/
fun main() {
application {
configure {
width = 800
height = 800
}
program {
val bp = bezierPatch(
Circle(drawer.bounds.center, 350.0).contour
//Rectangle.fromCenter(drawer.bounds.center, 550.0).contour
)
extend {
drawer.clear(ColorRGBa.PINK)
drawer.stroke = ColorRGBa.BLACK
for (j in 1 until 50 step 2) {
for (i in 1 until 50 step 2) {
val u = i / 50.0
val v = j / 50.0
val pos = bp.position(u, v)
val grad = bp.gradient(u, v).normalized * 10.0
val perpendicular = grad.perpendicular()
drawer.lineSegment(pos - grad, pos + grad)
drawer.lineSegment(pos - perpendicular, pos + perpendicular)
//drawer.circle(pos + grad, 3.0)
}
}
}
}
}
}