From 8a2decd6567d904d4390f52e5be4b8f86f105c9d Mon Sep 17 00:00:00 2001 From: Redstonneur1256 Date: Tue, 9 Apr 2024 01:08:42 +0200 Subject: [PATCH] add start & end angle for Lines.poly (#165) --- arc-core/src/arc/graphics/g2d/Lines.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arc-core/src/arc/graphics/g2d/Lines.java b/arc-core/src/arc/graphics/g2d/Lines.java index 63f95d61..be670ac7 100644 --- a/arc-core/src/arc/graphics/g2d/Lines.java +++ b/arc-core/src/arc/graphics/g2d/Lines.java @@ -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, @@ -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); }