From 1bf7abbb96645a2d414b82fba2d50e00dd752b9c Mon Sep 17 00:00:00 2001 From: Ricardo Matias Date: Wed, 9 Mar 2022 08:56:09 +0100 Subject: [PATCH] Add curl parameter to extension methods (#229) --- orx-shapes/src/commonMain/kotlin/HobbyCurve.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/orx-shapes/src/commonMain/kotlin/HobbyCurve.kt b/orx-shapes/src/commonMain/kotlin/HobbyCurve.kt index 5b3cc899..dcd58975 100644 --- a/orx-shapes/src/commonMain/kotlin/HobbyCurve.kt +++ b/orx-shapes/src/commonMain/kotlin/HobbyCurve.kt @@ -11,17 +11,17 @@ import kotlin.math.sin import kotlin.math.sqrt -fun ShapeContour.hobbyCurve(): ShapeContour { +fun ShapeContour.hobbyCurve(curl: Double = 0.0): ShapeContour { val vertices = if (closed) segments.map { it.start } else segments.map { it.start } + segments.last().end - return hobbyCurve(vertices, closed) + return hobbyCurve(vertices, closed, curl) } -fun Shape.hobbyCurve() : Shape { +fun Shape.hobbyCurve(curl: Double = 0.0) : Shape { return Shape(contours.map { - it.hobbyCurve() + it.hobbyCurve(curl) }) } @@ -158,4 +158,3 @@ private fun rho(a: Double, b: Double): Double { private fun rotate(v: Vector2, s: Double, c: Double) = Vector2(v.x * c - v.y * s, v.x * s + v.y * c) private fun rotateAngle(v: Vector2, alpha: Double) = rotate(v, sin(alpha), cos(alpha)) -