[orx-shapes] Enhance ContourBlend with customizable rectification params

Added `distanceTolerance` and `lengthScale` parameters to the `ContourBlend` function for improved flexibility during contour rectification. Default values maintain backward compatibility.
This commit is contained in:
Edwin Jakobs
2025-01-24 18:10:37 +01:00
parent e413c6e387
commit 969d342e91

View File

@@ -34,12 +34,19 @@ class ContourBlend(val a: RectifiedContour, val b: RectifiedContour) {
* *
* @param a the first ShapeContour to blend * @param a the first ShapeContour to blend
* @param b the second ShapeContour to blend * @param b the second ShapeContour to blend
* @param distanceTolerance the distance tolerance used in the rectification preprocess of [a] and [b]
* @param lengthScale the length scale used in the rectification preprocess of [a] and [b]
* @return a ContourBlend instance representing the blended contours * @return a ContourBlend instance representing the blended contours
* @throws IllegalArgumentException if the preprocessing for contours fails to produce an equal number of segments * @throws IllegalArgumentException if the preprocessing for contours fails to produce an equal number of segments
*/ */
fun ContourBlend(a: ShapeContour, b: ShapeContour): ContourBlend { fun ContourBlend(
val ra = a.rectified() a: ShapeContour,
val rb = b.rectified() b: ShapeContour,
distanceTolerance: Double = 0.5,
lengthScale: Double = 1.0
): ContourBlend {
val ra = a.rectified(distanceTolerance, lengthScale)
val rb = b.rectified(distanceTolerance, lengthScale)
val sa = ra.splitForBlend(rb) val sa = ra.splitForBlend(rb)
val sb = rb.splitForBlend(ra) val sb = rb.splitForBlend(ra)
require(sa.originalPath.segments.size == sb.originalPath.segments.size) { require(sa.originalPath.segments.size == sb.originalPath.segments.size) {