From ae657a7db355e27d3fcde806e94356fde7b4f4f3 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 27 Nov 2024 12:03:19 -0500 Subject: [PATCH] Fill utility --- arc-core/src/arc/graphics/g2d/Fill.java | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/arc-core/src/arc/graphics/g2d/Fill.java b/arc-core/src/arc/graphics/g2d/Fill.java index 05357e2f..8f733d2e 100644 --- a/arc-core/src/arc/graphics/g2d/Fill.java +++ b/arc-core/src/arc/graphics/g2d/Fill.java @@ -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(); } @@ -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); } @@ -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); @@ -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(); }