|
|
|
@ -374,6 +374,7 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void Draw(int x, int y, Color col) { |
|
|
|
|
if (x<0||y<0||x>=JavaProjectTemplate.WINDOW_WIDTH||y>=JavaProjectTemplate.WINDOW_HEIGHT) return; |
|
|
|
|
Draw(y*JavaProjectTemplate.WINDOW_WIDTH+x,col.getColor()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -894,9 +895,14 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
|
} |
|
|
|
|
} catch (CloneNotSupportedException e) {} |
|
|
|
|
} |
|
|
|
|
/*void PixelGameEngine::DrawCircle(int32_t x, int32_t y, int32_t radius, Pixel p, uint8_t mask) |
|
|
|
|
{ // Thanks to IanM-Matrix1 #PR121
|
|
|
|
|
if (radius < 0 || x < -radius || y < -radius || x - GetDrawTargetWidth() > radius || y - GetDrawTargetHeight() > radius) |
|
|
|
|
|
|
|
|
|
public void Draw_Circle(int x, int y, int radius, Color col) { |
|
|
|
|
Draw_Circle(x,y,radius,col,(byte)0xFF); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//The mask indicates which pie slices to draw, each bit of the mask represents 1/8th of a pie slice. By default all pie slices are drawn.
|
|
|
|
|
public void Draw_Circle(int x, int y, int radius, Color col, byte mask) { |
|
|
|
|
if (radius < 0 || x < -radius || y < -radius || x - JavaProjectTemplate.WINDOW_WIDTH > radius || y - JavaProjectTemplate.WINDOW_HEIGHT > radius) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (radius > 0) |
|
|
|
@ -908,16 +914,16 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
|
while (y0 >= x0) // only formulate 1/8 of circle
|
|
|
|
|
{ |
|
|
|
|
// Draw even octants
|
|
|
|
|
if (mask & 0x01) Draw(x + x0, y - y0, p);// Q6 - upper right right
|
|
|
|
|
if (mask & 0x04) Draw(x + y0, y + x0, p);// Q4 - lower lower right
|
|
|
|
|
if (mask & 0x10) Draw(x - x0, y + y0, p);// Q2 - lower left left
|
|
|
|
|
if (mask & 0x40) Draw(x - y0, y - x0, p);// Q0 - upper upper left
|
|
|
|
|
if ((mask & 0x01)!=0) Draw(x + x0, y - y0, col);// Q6 - upper right right
|
|
|
|
|
if ((mask & 0x04)!=0) Draw(x + y0, y + x0, col);// Q4 - lower lower right
|
|
|
|
|
if ((mask & 0x10)!=0) Draw(x - x0, y + y0, col);// Q2 - lower left left
|
|
|
|
|
if ((mask & 0x40)!=0) Draw(x - y0, y - x0, col);// Q0 - upper upper left
|
|
|
|
|
if (x0 != 0 && x0 != y0) |
|
|
|
|
{ |
|
|
|
|
if (mask & 0x02) Draw(x + y0, y - x0, p);// Q7 - upper upper right
|
|
|
|
|
if (mask & 0x08) Draw(x + x0, y + y0, p);// Q5 - lower right right
|
|
|
|
|
if (mask & 0x20) Draw(x - y0, y + x0, p);// Q3 - lower lower left
|
|
|
|
|
if (mask & 0x80) Draw(x - x0, y - y0, p);// Q1 - upper left left
|
|
|
|
|
if ((mask & 0x02)!=0) Draw(x + y0, y - x0, col);// Q7 - upper upper right
|
|
|
|
|
if ((mask & 0x08)!=0) Draw(x + x0, y + y0, col);// Q5 - lower right right
|
|
|
|
|
if ((mask & 0x20)!=0) Draw(x - y0, y + x0, col);// Q3 - lower lower left
|
|
|
|
|
if ((mask & 0x80)!=0) Draw(x - x0, y - y0, col);// Q1 - upper left left
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (d < 0) |
|
|
|
@ -927,15 +933,10 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
Draw(x, y, p); |
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
public void Draw_Circle(int x, int y, int radius, Color col) { |
|
|
|
|
Draw_Circle(x,y,radius,col,(byte)0xFF); |
|
|
|
|
Draw(x, y, col); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//The mask indicates which pie slices to draw, each bit of the mask represents 1/8th of a pie slice. By default all pie slices are drawn.
|
|
|
|
|
public void Draw_Circle(int x, int y, int radius, Color col, byte mask) { |
|
|
|
|
public void Fill_Circle(int x, int y, int radius, Color col) { |
|
|
|
|
if (radius < 0 || x < -radius || y < -radius || x - JavaProjectTemplate.WINDOW_WIDTH > radius || y - JavaProjectTemplate.WINDOW_HEIGHT > radius) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
@ -945,25 +946,22 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
|
int y0 = radius; |
|
|
|
|
int d = 3 - 2 * radius; |
|
|
|
|
|
|
|
|
|
while (y0 >= x0) // only formulate 1/8 of circle
|
|
|
|
|
while (y0 >= x0) |
|
|
|
|
{ |
|
|
|
|
// Draw even octants
|
|
|
|
|
if ((mask & 0x01)!=0) Draw(x + x0, y - y0, col);// Q6 - upper right right
|
|
|
|
|
if ((mask & 0x04)!=0) Draw(x + y0, y + x0, col);// Q4 - lower lower right
|
|
|
|
|
if ((mask & 0x10)!=0) Draw(x - x0, y + y0, col);// Q2 - lower left left
|
|
|
|
|
if ((mask & 0x40)!=0) Draw(x - y0, y - x0, col);// Q0 - upper upper left
|
|
|
|
|
if (x0 != 0 && x0 != y0) |
|
|
|
|
{ |
|
|
|
|
if ((mask & 0x02)!=0) Draw(x + y0, y - x0, col);// Q7 - upper upper right
|
|
|
|
|
if ((mask & 0x08)!=0) Draw(x + x0, y + y0, col);// Q5 - lower right right
|
|
|
|
|
if ((mask & 0x20)!=0) Draw(x - y0, y + x0, col);// Q3 - lower lower left
|
|
|
|
|
if ((mask & 0x80)!=0) Draw(x - x0, y - y0, col);// Q1 - upper left left
|
|
|
|
|
} |
|
|
|
|
drawline(x - y0, x + y0, y - x0, col); |
|
|
|
|
if (x0 > 0) drawline(x - y0, x + y0, y + x0, col); |
|
|
|
|
|
|
|
|
|
if (d < 0) |
|
|
|
|
d += 4 * x0++ + 6; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (x0 != y0) |
|
|
|
|
{ |
|
|
|
|
drawline(x - x0, x + x0, y - y0, col); |
|
|
|
|
drawline(x - x0, x + x0, y + y0, col); |
|
|
|
|
} |
|
|
|
|
d += 4 * (x0++ - y0--) + 10; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|