Skip to content

Commit

Permalink
Fill utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Nov 27, 2024
1 parent ed5dd28 commit ae657a7
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions arc-core/src/arc/graphics/g2d/Fill.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@ public static void light(float x, float y, int sides, float radius, float rotati
}
}

public static void lightInner(float x, float y, int sides, float innerRadius, float radius, float rotation, Color center, Color edge){
float centerf = center.toFloatBits(), edgef = edge.toFloatBits();

float space = 360f / sides;

for(int i = 0; i < sides; i ++){
float px = Angles.trnsx(space * i + rotation, radius);
float py = Angles.trnsy(space * i + rotation, radius);
float px2 = Angles.trnsx(space * (i + 1) + rotation, radius);
float py2 = Angles.trnsy(space * (i + 1) + rotation, radius);
quad(
x + Angles.trnsx(space * i + rotation, innerRadius), y + Angles.trnsy(space * i + rotation, innerRadius), centerf,
x + px, y + py, edgef,
x + px2, y + py2, edgef,
x + Angles.trnsx(space * (i+1) + rotation, innerRadius), y + Angles.trnsy(space * (i+1) + rotation, innerRadius), centerf
);
}
}

public static void polyBegin(){
polyFloats.clear();
}
Expand Down Expand Up @@ -265,7 +284,7 @@ public static void poly(float x, float y, int sides, float radius, float rotatio
tri(x, y, x + px, y + py, x + px2, y + py2);
}
}

public static void arc(float x, float y, float radius, float fraction){
arc(x, y, radius, fraction, 0f);
}
Expand All @@ -278,7 +297,7 @@ public static void arc(float x, float y, float radius, float fraction, float rot
int max = Mathf.ceil(sides * fraction);
polyBegin();
polyPoint(x, y);

for(int i = 0; i <= max; i++){
float a = (float)i / max * fraction * 360f + rotation;
float x1 = Angles.trnsx(a, radius);
Expand All @@ -287,7 +306,7 @@ public static void arc(float x, float y, float radius, float fraction, float rot
polyPoint(x + x1, y + y1);
}
polyPoint(x, y);

polyEnd();
}

Expand Down

0 comments on commit ae657a7

Please # to comment.