generated from sigonasr2/JavaProjectTemplate
FillCircle implemented
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
d20c20490c
commit
f307b36e76
@ -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,41 +895,6 @@ 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)
|
||||
return;
|
||||
|
||||
if (radius > 0)
|
||||
{
|
||||
int x0 = 0;
|
||||
int y0 = radius;
|
||||
int d = 3 - 2 * radius;
|
||||
|
||||
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 (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 (d < 0)
|
||||
d += 4 * x0++ + 6;
|
||||
else
|
||||
d += 4 * (x0++ - y0--) + 10;
|
||||
}
|
||||
}
|
||||
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);
|
||||
@ -970,6 +936,38 @@ public class Panel extends JPanel implements Runnable,KeyListener {
|
||||
Draw(x, y, col);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (radius > 0)
|
||||
{
|
||||
int x0 = 0;
|
||||
int y0 = radius;
|
||||
int d = 3 - 2 * radius;
|
||||
|
||||
while (y0 >= x0)
|
||||
{
|
||||
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
|
||||
Draw(x, y, col);
|
||||
}
|
||||
|
||||
Color ColorLerp(Color c1, Color c2, float t)
|
||||
{ return new Color((int)((c2.r * t) + c1.r * (1.0f - t)),(int)((c2.g * t) + c1.g * (1.0f - t)),(int)((c2.b * t) + c1.b * (1.0f - t)),(int)((c2.a * t) + c1.a * (1.0f - t))); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user