Skip to content

Commit

Permalink
add start & end angle for Lines.poly (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
Redstonneur1256 committed Apr 8, 2024
1 parent 8b6f34c commit 8a2decd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions arc-core/src/arc/graphics/g2d/Lines.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ public static void quad(float x1, float y1, float x2, float y2, float x3, float
polyline(floatBuilder, true);
}

public static void poly(float x, float y, int sides, float radius, float angle){
float space = 360f / sides;
public static void poly(float x, float y, int sides, float radius, float startAngle, float endAngle){
float space = (endAngle - startAngle) / sides;
float hstep = stroke / 2f / Mathf.cosDeg(space/2f);
float r1 = radius - hstep, r2 = radius + hstep;

for(int i = 0; i < sides; i++){
float a = space * i + angle, cos = Mathf.cosDeg(a), sin = Mathf.sinDeg(a), cos2 = Mathf.cosDeg(a + space), sin2 = Mathf.sinDeg(a + space);
float a = space * i + startAngle, cos = Mathf.cosDeg(a), sin = Mathf.sinDeg(a), cos2 = Mathf.cosDeg(a + space), sin2 = Mathf.sinDeg(a + space);
Fill.quad(
x + r1*cos, y + r1*sin,
x + r1*cos2, y + r1*sin2,
Expand All @@ -370,6 +370,10 @@ public static void poly(float x, float y, int sides, float radius, float angle){
}
}

public static void poly(float x, float y, int sides, float radius, float angle){
poly(x, y, sides, radius, angle, angle + 360);
}

public static void poly(float x, float y, int sides, float radius){
poly(x, y, sides, radius, 0);
}
Expand Down

0 comments on commit 8a2decd

Please sign in to comment.