[orx-shapes] use phase parameter in regularStar (#168)
This commit is contained in:
committed by
GitHub
parent
cc766b6db1
commit
d6dbf2a6d7
@@ -9,10 +9,11 @@ import kotlin.math.sin
|
||||
|
||||
fun regularStar(points: Int, innerRadius: Double, outerRadius: Double, center: Vector2 = Vector2.ZERO, phase: Double = 0.0): ShapeContour {
|
||||
return contour {
|
||||
val theta = Math.toRadians(phase)
|
||||
val phi = PI * 2.0 / (points * 2)
|
||||
for (i in 0 until points * 2 step 2) {
|
||||
val outerPoint = Vector2(cos(i * phi), sin(i * phi)) * outerRadius + center
|
||||
val innerPoint = Vector2(cos((i + 1) * phi), sin((i + 1) * phi)) * innerRadius + center
|
||||
val outerPoint = Vector2(cos(i * phi + theta), sin(i * phi + theta)) * outerRadius + center
|
||||
val innerPoint = Vector2(cos((i + 1) * phi + theta), sin((i + 1) * phi + theta)) * innerRadius + center
|
||||
moveOrLineTo(outerPoint)
|
||||
lineTo(innerPoint)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user