Add comments to bezierPatch demos, simplify. (#173)

This commit is contained in:
Abe Pazos
2021-02-23 08:24:10 +01:00
committed by GitHub
parent 10aed4d53d
commit 8d6b82a24e
4 changed files with 95 additions and 42 deletions

View File

@@ -2,12 +2,18 @@ import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.shapes.bezierPatch
import org.openrndr.math.bezier
import org.openrndr.shape.Circle
import org.openrndr.shape.LineSegment
import org.openrndr.shape.Rectangle
import org.openrndr.shape.drawComposition
import org.openrndr.shape.ShapeContour
/**
* Shows how to create a [bezierPatch] out of a
* closed [ShapeContour] with 4 curved segments.
*
* Calling [Circle.contour] is one way of producing
* such a contour with vertices at the cardinal points
* but one can manually create any other 4-segment closed contour
* to use in bezier patches.
*/
fun main() {
application {
configure {
@@ -20,16 +26,17 @@ fun main() {
this.outputFile = System.getProperty("screenshotPath")
}
}
val c = Circle(width / 2.0, height / 2.0, 350.0).contour
val bp = bezierPatch(c)
extend {
drawer.clear(ColorRGBa.PINK)
val c = Circle(width/2.0, height/2.0, 350.0).contour
val bp = bezierPatch(c)
drawer.stroke = ColorRGBa.BLACK
for (i in 0..10) {
drawer.stroke = ColorRGBa.BLACK
drawer.contour(bp.horizontal(i/10.0))
drawer.contour(bp.vertical(i/10.0))
drawer.contour(bp.horizontal(i / 10.0))
drawer.contour(bp.vertical(i / 10.0))
}
}
}