From 969d342e91dc1f31a385bb91b7d72d3c6ba59d2c Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Fri, 24 Jan 2025 18:10:37 +0100 Subject: [PATCH] [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. --- .../src/commonMain/kotlin/blend/ContourBlend.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/orx-shapes/src/commonMain/kotlin/blend/ContourBlend.kt b/orx-shapes/src/commonMain/kotlin/blend/ContourBlend.kt index da1abed8..c217fb09 100644 --- a/orx-shapes/src/commonMain/kotlin/blend/ContourBlend.kt +++ b/orx-shapes/src/commonMain/kotlin/blend/ContourBlend.kt @@ -34,12 +34,19 @@ class ContourBlend(val a: RectifiedContour, val b: RectifiedContour) { * * @param a the first 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 * @throws IllegalArgumentException if the preprocessing for contours fails to produce an equal number of segments */ -fun ContourBlend(a: ShapeContour, b: ShapeContour): ContourBlend { - val ra = a.rectified() - val rb = b.rectified() +fun ContourBlend( + a: ShapeContour, + 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 sb = rb.splitForBlend(ra) require(sa.originalPath.segments.size == sb.originalPath.segments.size) {