diff --git a/orx-shapes/src/commonMain/kotlin/drawers/BezierPatchDrawer.kt b/orx-shapes/src/commonMain/kotlin/drawers/BezierPatchDrawer.kt index 4c95a1c8..71151a26 100644 --- a/orx-shapes/src/commonMain/kotlin/drawers/BezierPatchDrawer.kt +++ b/orx-shapes/src/commonMain/kotlin/drawers/BezierPatchDrawer.kt @@ -162,7 +162,7 @@ class BezierPatchDrawer { internal fun ensureVertexCount(count: Int) { if (vertices.vertexCount < count) { vertices.destroy() - vertexBuffer( + vertices = vertexBuffer( vertexFormat { position(3) color(4) @@ -213,7 +213,7 @@ class BezierPatchDrawer { shader.end() } - @JvmName("drawBezierPatchOKLab") + @JvmName("drawBezierPatchesOKLab") fun drawBezierPatches( context: DrawContext, drawStyle: DrawStyle, @@ -260,7 +260,7 @@ class BezierPatchDrawer { shader.end() } - @JvmName("drawBezierPatch3D") + @JvmName("drawBezierPatches3D") fun drawBezierPatches( context: DrawContext, drawStyle: DrawStyle, @@ -304,7 +304,7 @@ class BezierPatchDrawer { shader.end() } - @JvmName("drawBezierPatch3DOKLab") + @JvmName("drawBezierPatches3DOKLab") fun drawBezierPatches( context: DrawContext, drawStyle: DrawStyle, diff --git a/orx-shapes/src/demo/kotlin/DemoBezierPatches01.kt b/orx-shapes/src/demo/kotlin/DemoBezierPatches01.kt new file mode 100644 index 00000000..5afebdf4 --- /dev/null +++ b/orx-shapes/src/demo/kotlin/DemoBezierPatches01.kt @@ -0,0 +1,44 @@ +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.extensions.SingleScreenshot +import org.openrndr.extra.shapes.bezierPatch +import org.openrndr.shape.Circle +import org.openrndr.shape.ShapeContour +import org.openrndr.extra.shapes.drawers.bezierPatch +import org.openrndr.extra.shapes.drawers.bezierPatches + +/** + * 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. + */ +suspend fun main() { + application { + configure { + width = 800 + height = 800 + } + program { + if (System.getProperty("takeScreenshot") == "true") { + extend(SingleScreenshot()) { + this.outputFile = System.getProperty("screenshotPath") + } + } + + val c0 = Circle(width / 3.0, height / 2.0, 150.0).contour + val bp0 = bezierPatch(c0) + + val c1 = Circle(2.0*width / 3.0, height / 2.0, 150.0).contour + val bp1 = bezierPatch(c1) + + + extend { + drawer.bezierPatches(listOf(bp0, bp1)) + } + } + } +} \ No newline at end of file