diff --git a/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt b/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt index 73915f8c8..dafa6c82d 100644 --- a/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt +++ b/orx-shapes/src/commonMain/kotlin/adjust/ContourEdge.kt @@ -54,7 +54,7 @@ data class ContourEdge( */ fun toLinear(): ContourEdge { return if (contour.segments[segmentIndex].type != SegmentType.LINEAR) { - val newSegment = contour.segments[segmentIndex].copy(control = emptyArray()) + val newSegment = contour.segments[segmentIndex].copy(control = emptyList()) val newSegments = contour.segments .update(segmentIndex to newSegment) @@ -217,7 +217,7 @@ data class ContourEdge( val segment = contour.segments[segmentIndex] val newSegment = segment.copy( start = segment.start.transformedBy(transform), - control = segment.control.map { it.transformedBy(transform) }.toTypedArray(), + control = segment.control.map { it.transformedBy(transform) }, end = segment.end.transformedBy(transform) ) val segmentInIndex = if (contour.closed) (segmentIndex - 1).mod(contour.segments.size) else segmentIndex - 1 @@ -228,26 +228,27 @@ data class ContourEdge( val newSegments = contour.segments.map { it }.toMutableList() if (refIn != null) { - val control = if (refIn.linear || !updateTangents) { + var control = if (refIn.linear || !updateTangents) { refIn.control } else { refIn.cubic.control } if (control.isNotEmpty()) { - control[1] = control[1].transformedBy(transform) + control = listOf(control[0], control[1].transformedBy(transform)) } - newSegments[segmentInIndex] = refIn.copy(end = segment.start.transformedBy(transform)) + newSegments[segmentInIndex] = refIn.copy(control = control, end = segment.start.transformedBy(transform)) } if (refOut != null) { - val control = if (refOut.linear || !updateTangents) { + var control = if (refOut.linear || !updateTangents) { refOut.control } else { refOut.cubic.control } if (control.isNotEmpty()) { - control[0] = control[0].transformedBy(transform) + control = listOf(control[0].transformedBy(transform), control[1]) + } - newSegments[segmentOutIndex] = refOut.copy(start = segment.end.transformedBy(transform)) + newSegments[segmentOutIndex] = refOut.copy(start = segment.end.transformedBy(transform), control = control) } newSegments[segmentIndex] = newSegment diff --git a/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt b/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt index f1610324a..19a7b64a4 100644 --- a/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt +++ b/orx-shapes/src/commonMain/kotlin/adjust/ContourVertex.kt @@ -101,14 +101,14 @@ data class ContourVertex( contour.segments.getOrNull(segmentIndex - 1) newSegments[segmentIndex] = run { val cubicSegment = refOut.cubic - val newControls = arrayOf((transformOut * cubicSegment.control[0].xy01).xy, cubicSegment.control[1]) + val newControls = listOf((transformOut * cubicSegment.control[0].xy01).xy, cubicSegment.control[1]) refOut.copy(control = newControls) } val segmentIndexIn = (segmentIndex - 1).mod(contour.segments.size) if (refIn != null) { newSegments[segmentIndexIn] = run { val cubicSegment = refIn.cubic - val newControls = arrayOf(cubicSegment.control[0], (transformIn * cubicSegment.control[1].xy01).xy) + val newControls = listOf(cubicSegment.control[0], (transformIn * cubicSegment.control[1].xy01).xy) refIn.copy(control = newControls) } } @@ -166,7 +166,7 @@ data class ContourVertex( if (contour.closed || segmentIndex< contour.segments.size) { newSegments[segmentIndex] = if (updateTangents && !refOut.linear) { val cubicSegment = refOut.cubic - val newControls = arrayOf(transform(cubicSegment.control[0]), cubicSegment.control[1]) + val newControls = listOf(transform(cubicSegment.control[0]), cubicSegment.control[1]) refOut.copy(start = newPosition, control = newControls) } else { newSegments[segmentIndex].copy(start = newPosition) @@ -174,7 +174,7 @@ data class ContourVertex( } else { newSegments[segmentIndex-1] = if (updateTangents && !refOut.linear) { val cubicSegment = refOut.cubic - val newControls = arrayOf(cubicSegment.control[0], transform(cubicSegment.control[1])) + val newControls = listOf(cubicSegment.control[0], transform(cubicSegment.control[1])) refOut.copy(end = newPosition, control = newControls) } else { newSegments[segmentIndex-1].copy(end = newPosition) @@ -186,7 +186,7 @@ data class ContourVertex( newSegments[segmentIndexIn] = if (updateTangents && !refIn.linear) { val cubicSegment = refIn.cubic - val newControls = arrayOf(cubicSegment.control[0], transform(cubicSegment.control[1])) + val newControls = listOf(cubicSegment.control[0], transform(cubicSegment.control[1])) newSegments[segmentIndexIn].copy(control = newControls, end = newPosition) } else { diff --git a/orx-shapes/src/commonMain/kotlin/offset/Offset.kt b/orx-shapes/src/commonMain/kotlin/offset/Offset.kt index fa443c798..b9237242d 100644 --- a/orx-shapes/src/commonMain/kotlin/offset/Offset.kt +++ b/orx-shapes/src/commonMain/kotlin/offset/Offset.kt @@ -101,13 +101,13 @@ fun Segment.scale(polarity: YPolarity, scale: (Double) -> Double): Segment { val nd = d.normalized * s it + rc * nd } - return copy(newStart, newControls.toTypedArray(), newEnd) + return copy(newStart, newControls, newEnd) } else { val newControls = control.mapIndexed { index, it -> val rc = scale((index + 1.0) / 3.0) it + rc * normal((index + 1.0), polarity) } - return copy(newStart, newControls.toTypedArray(), newEnd) + return copy(newStart, newControls, newEnd) } }