Achhhh! I suppose you could do it with a narrow filled box and rotate it through 90 degrees. But that's still overwriting pixels you've already drawn. It could also leave some pretty rough edges.
I just dug up the source code I used. Bear in mind this is for my Image class and uses some functions that aren't explained here since I was actually working direction on the D3D copy of the image. But this should be illustrative of how do do the point and line routines.
DWORD Image::Circle (int cx, int cy, int radius, DWORD clr, bool fill)
{
Lock();
int xCenter=cx,yCenter=cy;
int x=0,y=radius;
int d=3-(2*radius);
while(x<=y){
Plot (xCenter+x,yCenter+y, clr);
Plot (xCenter+y,yCenter+x, clr);
Plot (xCenter-x,yCenter+y, clr);
Plot (xCenter+y,yCenter-x, clr);
Plot (xCenter-x,yCenter-y, clr);
Plot (xCenter-y,yCenter-x, clr);
Plot (xCenter+x,yCenter-y, clr);
Plot (xCenter-y,yCenter+x, clr);
if (fill) { // if we're doing a fill then we can
// TO DO : since these are horizontal lines we can probably
// speed things up by drawing a straight line using a pointer
// but make it a function
Line (xCenter+x + 1, yCenter+y, xCenter-x -1, yCenter+y, clr);
Line (xCenter+y + 1, yCenter+x, xCenter-y -1, yCenter+x, clr);
Line (xCenter+y + 1, yCenter-x, xCenter-y -1, yCenter-x, clr);
Line (xCenter-x + 1, yCenter-y, xCenter+x -1, yCenter-y, clr);
}
if (d<0)
d += (x << 2)+6;
else
{
d += ((x-y) << 2)+10;
y -= 1;
}
x++;
}
Unlock();
return clr;
}
DWORD Image::Plot(int x, int y, DWORD clr)
{ // puts color pixel at x/y coordinates. assumes image is locked
if (x >= 0 && x < thisImage.width && y >= 0 && y < thisImage.height) *(thisImage.bytes + y * thisImage.pitch32 + x) = clr ;
return clr;
}
DWORD Image::Line(int x0, int y0, int x1, int y1, DWORD clr)
{
Lock();
int dx = abs(x1 - x0),
dy = abs(y1 - y0);
bool steep = dy > dx;
if(steep)
{
std::swap(dx, dy);
std::swap(x0, y0);
std::swap(x1, y1);
}
int error = 0,
de = dy,
&x = steep ? y0 : x0,
&y = steep ? x0 : y0,
xstep = (x0 < x1) ? 1 : -1,
ystep = (y0 < y1) ? 1 : -1;
Plot(x, y, clr);
while(x0 != x1)
{
x0 += xstep;
error += de;
if( (error << 1) >= dx)
{
y0 += ystep;
error -= dx;
}
Plot(x, y, clr);
}
Unlock();
return clr;
}
Lilith, Night Butterfly
I'm not a programmer but I play one in the office