[orx-shapes] Add edge/contour replacement

This commit is contained in:
Edwin Jakobs
2023-10-27 16:27:19 +02:00
parent 349ff99dde
commit fd5d6f7020
4 changed files with 121 additions and 9 deletions

View File

@@ -1,9 +1,27 @@
package org.openrndr.extra.shapes.adjust
import org.openrndr.math.Vector2
import org.openrndr.shape.ShapeContour
data class ContourAdjusterEdge(val contourAdjuster: ContourAdjuster, val segmentIndex: () -> Int) {
val startPosition
get() = contourAdjuster.contour.segments[segmentIndex()].start
val endPosition
get() = contourAdjuster.contour.segments[segmentIndex()].end
fun position(t: Double) : Vector2 {
return contourAdjuster.contour.segments[segmentIndex()].position(t)
}
fun normal(t: Double) : Vector2 {
return contourAdjuster.contour.segments[segmentIndex()].normal(t)
}
/**
* A [ContourAdjusterVertex] interface for the start-vertex of the edge
*/
@@ -62,9 +80,10 @@ data class ContourAdjusterEdge(val contourAdjuster: ContourAdjuster, val segment
fun scale(scaleFactor: Double, anchorT: Double = 0.5, updateTangents: Boolean = true) =
wrap { scaledBy(scaleFactor, anchorT, updateTangents = true) }
fun replaceWith(t:Double, updateTangents: Boolean = true) {
wrap { replacedWith(t, updateTangents) }
}
fun replaceWith(t:Double, updateTangents: Boolean = true) = wrap { replacedWith(t, updateTangents) }
fun replaceWith(openContour: ShapeContour) = wrap { replacedWith(openContour) }
fun sub(t0:Double, t1: Double, updateTangents: Boolean = true) {
contourAdjuster.contour =