Drawing functions: drawing circles and more...

I think, there aren't enough drawing functions in GE, so I made a little script with some basic colors and two functions: drawRectangle(x1, y1, x2, y2), drawCircle(x, y, r).
Here is the script:
You have to copy it to a global code.
Maybe I will try to make some more functions and constants for it.
And, what do you think about this? Do you think, I could have made the circle functions myself (and even better), do you think, you can need my functions and constants? Please tell me your opinions. You could also make suggestions for more functions and constants, that I could try to make.
Here is the script:
- Code: Select all
#define RED 255, 0, 0
#define GREEN 0, 255, 0
#define BLUE 0, 0, 255
#define YELLOW 255, 255, 0
#define PURPLE 255, 0, 255
#define AQUA 0, 0, 255
#define ORANGE 255, 127, 0
#define WHITE 255, 255, 255
#define BLACK 0, 0, 0
#define DARKRED 127, 0, 0
#define DARKGREEN 0, 127, 0
#define DARKBLUE 0, 127, 0
#define DARKYELLOW 127, 127, 0
#define DARKPURPLE 127, 0, 127
#define DARKAQUA 0, 0, 255
void drawCircle(double xpos, double ypos, double r)
{
int xp, yp;
for(yp=floor(ypos)-ceil(r);yp<ceil(ypos)+ceil(r);yp++)
for(xp=floor(xpos)-ceil(r);xp<ceil(xpos)+ceil(r);xp++)
if(sqrt(pow(max(xpos, xp)-min(xpos, xp), 2)+pow(max(ypos, yp)-min(ypos, yp), 2))<=r) putpixel(xp, yp);
}
void drawRectangle(double x1, double y1, double x2, double y2)
{
int xp, yp;
if(max(x1, x)-min(x1, x2)<max(y1, y2)-min(y1, y2)) // draw vertical lines
{
for(xp=min(x1, x2);xp<max(x1, x2);xp++)
{
moveto(xp, min(y1, y2));
lineto(xp, max(y1, y2));
}
}
else // draw horizontal lines
{
for(yp=min(y1, y2);yp<max(y1, y2);yp++)
{
moveto(min(x1, x2), yp);
lineto(max(x1, x2), yp);
}
}
}
You have to copy it to a global code.
Maybe I will try to make some more functions and constants for it.
And, what do you think about this? Do you think, I could have made the circle functions myself (and even better), do you think, you can need my functions and constants? Please tell me your opinions. You could also make suggestions for more functions and constants, that I could try to make.