|
Post by graaaeme10 on Aug 24, 2021 18:20:02 GMT -8
Hi there, I'm using this code to draw arcs, which should draw a grey arc first then a red arc over top, in the second half of the arc:
void plainArc(int x, int y, int r1, int r2, uint16_t a1, uint16_t a2, uint32_t color, byte options) {
int ra = r2 * 2;
GD.SaveContext();
GD.ColorMask(0, 0, 0, 1);
GD.Clear();
GD.Begin(POINTS);
PAINT_ALPHA();
GD.PointSize(r2 * 8);
GD.Vertex2f(8 * x, 8 * y);
CLEAR_ALPHA();
GD.PointSize(r1 * 8);
GD.Vertex2f(8 * x, 8 * y);
int px, py;
GD.Begin(LINES);
GD.LineWidth(12);
GD.polar(px, py, ra, a1);
GD.Vertex2f(8 * x, 8 * y);
GD.Vertex2f(8 * (x + px), 8 * (y + py));
GD.polar(px, py, ra, a2);
GD.Vertex2f(8 * x, 8 * y);
GD.Vertex2f(8 * (x + px), 8 * (y + py));
Poly po;
po.begin();
po.v(8 * x, 8 * y);
for (int i = 0; i < 5; i++) {
int rx, ry;
GD.polar(rx, ry, ra, a2 + ((65536 - a2 + a1) / 4) * i);
po.v(8 * (x + rx), 8 * (y + ry));
}
po.draw();
GD.RestoreContext();
GD.SaveContext();
DRAW_IN_ALPHA();
GD.Begin(RECTS);
GD.ColorRGB(color);
GD.Vertex2f(8 * (x - r2), 8 * (y - r2));
GD.Vertex2f(8 * (x + r2), 8 * (y + r2));
GD.RestoreContext();
}
plainArc(400, 250, 123, 126, 8192, 57344, 0x303030, 0);
plainArc(400, 250, 122, 127, 32768, 57344, 0xFF0000, 1);
However it only displays the red arc, it would appear that the polygon that is drawn in the alpha channel to mask off the non-drawn portion of the arc is masking off the next arc to be drawn. I would have thought with saving and restoring the context, this wouldn't be an issue. EDIT: It would appear the poly is just drawing itself in black, and not removing from the alpha channel?
Any help would be appreciated, cheers.
|
|