Add comments to bezierPatch demos, simplify. (#173)
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.Screenshots
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.shapes.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 {
|
||||
@@ -17,23 +23,26 @@ fun main() {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val bp = bezierPatch(
|
||||
Circle(drawer.bounds.center, 350.0).contour
|
||||
//Rectangle.fromCenter(drawer.bounds.center, 550.0).contour
|
||||
)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
val bp = bezierPatch(Circle(width / 2.0, height / 2.0, 350.0).contour)
|
||||
|
||||
for (i in 0..50) {
|
||||
drawer.stroke = ColorRGBa.BLACK.opacify(1.0)
|
||||
}
|
||||
drawer.stroke = ColorRGBa.BLACK
|
||||
|
||||
for (j in 1 until 50 step 2) {
|
||||
for (i in 1 until 50 step 2) {
|
||||
val p = bp.position(i / 50.0, j / 50.0)
|
||||
val g2 = bp.gradient(i / 50.0, j / 50.0).normalized
|
||||
val g = g2.perpendicular()
|
||||
drawer.lineSegment(p, p + g2 * 10.0)
|
||||
drawer.lineSegment(p, p - g2 * 10.0)
|
||||
drawer.lineSegment(p, p + g * 10.0)
|
||||
drawer.lineSegment(p, p - g * 10.0)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user