Skip to content

Commit

Permalink
[orx-shapes] use phase parameter in regularStar (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvee1 authored Feb 4, 2021
1 parent cc766b6 commit d6dbf2a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions orx-shapes/src/main/kotlin/RegularStar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d6dbf2a

Please sign in to comment.