Skip to content

Commit

Permalink
refactor drawing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
thelsing committed Nov 15, 2023
1 parent b8f673c commit fe7b9a3
Show file tree
Hide file tree
Showing 19 changed files with 969 additions and 846 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
public class AreaRenderer {
public record TriangledPolygon(float[] vertices, short[] indices) {}

public AreaRenderer(TextureRegion whitePixelRegion, ShapeDrawer drawer) {
this.whitePixel = whitePixelRegion;
this.drawer = drawer;
}

private ShapeDrawer drawer;
private TextureRegion whitePixel;

Expand All @@ -47,6 +42,15 @@ public AreaRenderer(TextureRegion whitePixelRegion, ShapeDrawer drawer) {

private Color color;

public AreaRenderer(ShapeDrawer drawer) {
this.drawer = drawer;
this.whitePixel = drawer.getRegion();
}

public ShapeDrawer getShapeDrawer() {
return drawer;
}

public void setColor(Color value) {
if (value == null) {
color = Color.WHITE;
Expand Down Expand Up @@ -225,7 +229,7 @@ private void drawDebug(float[] vertices, short[] indicies) {
drawer.setColor(oldColor);
}

protected void paintVertices(PolygonSpriteBatch batch, float[] vertices, short[] holeIndices) {
public void paintVertices(PolygonSpriteBatch batch, float[] vertices, short[] holeIndices) {
var indices = Earcut.earcut(vertices, holeIndices, (short) 2).toArray();
var polyReg = new PolygonRegion(textureRegion, vertices, indices);

Expand Down Expand Up @@ -342,7 +346,7 @@ public FloatArray pathToFloatArray(PathIterator it) {
private Vector2 BC = new Vector2();
private Vector2 vec1 = new Vector2();

enum JoinType {
public enum JoinType {
Pointy,
Smooth,
Round
Expand Down
Loading

0 comments on commit fe7b9a3

Please sign in to comment.