AtomSoft
Well-Known Member
i think i got it now lol im so dumb lol
Its cool i edited like this : (cuz i forget everything trust me lol )
Its cool i edited like this : (cuz i forget everything trust me lol )
Code:
/**********************************************************
draw a line between two points
code shamelessly stolen from Jim Lynch's 6100 driver
which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setline(char top0, char left0, char top1, char left1) {
int dy = left1 - left0;
int dx = top1 - top0;
int stepx, stepy;
if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
dy <<= 1; // dy is now 2*dy
dx <<= 1; // dx is now 2*dx
lcd_setpixel(top0, left0);
if (dx > dy) {
int fraction = dy - (dx >> 1); // same as 2*dy - dx
while (top0 != top1) {
if (fraction >= 0) {
left0 += stepy;
fraction -= dx; // same as fraction -= 2*dx
}
top0 += stepx;
fraction += dy; // same as fraction -= 2*dy
lcd_setpixel(top0, left0);
}
} else {
int fraction = dx - (dy >> 1);
while (left0 != left1) {
if (fraction >= 0) {
top0 += stepx;
fraction -= dy;
}
left0 += stepy;
fraction += dx;
lcd_setpixel(top0, left0);
}
}
}
/**********************************************************
draw a circle between two points
code shamelessly stolen from Jim Lynch's 6100 driver
which itself is based on Jack Bresenham's line algorithm
**********************************************************/
void lcd_setcircle(char top, char left, char radius) {
int f = 1 - radius;
int ddF_x = 0;
int ddF_y = -2 * radius;
int x = 0;
int y = radius;
lcd_setpixel(top, left + radius);
lcd_setpixel(top, left - radius);
lcd_setpixel(top + radius, left);
lcd_setpixel(top - radius, left);
while(x < y) {
if(f >= 0) {
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x + 1;
lcd_setpixel(top + x, left + y);
lcd_setpixel(top - x, left + y);
lcd_setpixel(top + x, left - y);
lcd_setpixel(top - x, left - y);
lcd_setpixel(top + y, left + x);
lcd_setpixel(top - y, left + x);
lcd_setpixel(top + y, left - x);
lcd_setpixel(top - y, left - x);
}
}
Last edited: