public static void draw_arc(int x, int y, int width, int height, int stroke, int start, int sweep, int color, int alpha, int closure, boolean fill) {
Graphics2D graphics = Sprite.createGraphics(Raster.pixels, Raster.width, Raster.height);
graphics.setColor(new Color((color >> 16 & 0xff), (color >> 8 & 0xff), (color & 0xff), ((alpha >= 256 || alpha < 0) ? 255 : alpha)));
RenderingHints render = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
render.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);//fix the 'jittering'
graphics.setRenderingHints(render);
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
if(!fill) {
graphics.setStroke(new BasicStroke((stroke < 1 ? 1 : stroke));
}
//Closure types - OPEN(0), CHORD(1), PIE(2)
Arc2D.Double arc = new Arc2D.Double(x + stroke, y + stroke, width, height, start, sweep, closure);
if(fill) {
graphics.fill(arc);
} else {
graphics.draw(arc);
}
}
Spoiler for Might need:
In your Sprite class
Code:
private static final ColorModel COLOR_MODEL = new DirectColorModel(32, 0xff0000, 0xff00, 0xff);
public static Graphics2D createGraphics(int[] pixels, int width, int height) {
return new BufferedImage(
COLOR_MODEL,
java.awt.image.Raster.createWritableRaster(COLOR_MODEL.createCompatibleSampleModel(width, height),
new DataBufferInt(pixels, width * height), null),
false, new java.util.Hashtable<Object, Object>()).createGraphics();
}
start would be the angle you want the sweep to start from,
sweep is the distance from the start angle (+ and - determine direction)
stroke is the line thickness
If ya wanna know more, [Only registered and activated users can see links. ]
start would be the angle you want the sweep to start from,
sweep is the distance from the start angle (+ and - determine direction)
stroke is the line thickness
If ya wanna know more, [Only registered and activated users can see links. ]
Yes, I had stroke set to 0 like an idiot haha, anyways thank you so much for this.
This is what I used it for:
[Only registered and activated users can see links. ]