[orx-shapes] Add custom tensions to HobbyCurve and related 2D/3D demos and tests

This commit is contained in:
Edwin Jakobs
2025-08-16 16:27:03 +02:00
parent 72b02ce585
commit e6997a968f
5 changed files with 98 additions and 26 deletions

View File

@@ -8,6 +8,10 @@ import org.openrndr.math.Vector2
import kotlin.random.Random
fun main() = application {
configure {
width = 720
height = 720
}
program {
val points = List(40) {
Vector2(

View File

@@ -0,0 +1,28 @@
package hobbycurve
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.noise.scatter
import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
import org.openrndr.extra.shapes.ordering.hilbertOrder
import kotlin.random.Random
fun main() = application {
configure {
width = 720
height = 720
}
program {
extend {
for (i in -20..20) {
val t = i / 10.0
val points = drawer.bounds.offsetEdges(-50.0).scatter(25.0, random = Random(0)).hilbertOrder()
drawer.stroke = ColorRGBa.WHITE.opacify(0.5)
drawer.fill = null
drawer.contour(hobbyCurve(points, closed = false, tensions = { i, inAngle, outAngle ->
Pair(t, t)
}))
}
}
}
}

View File

@@ -29,7 +29,7 @@ fun main() = application {
val hobby3D = hobbyCurve(
pts.map { it.xy0 + Vector3(0.0, 0.0, Double.uniform(-360.0, 360.0, r)) },
true,
tensions = { chordIndex: Int ->
tensions = { chordIndex, inAngle, outAngle ->
Pair(
cos(seconds + chordIndex * 0.1) * 0.5 + 0.5,
cos(seconds + (1.0 + chordIndex) * 0.1) * 0.5 + 0.5