void drawLineF(int x0, int x1, int y0, int y1, u16 color) { #ifdef _DEBUG fprintf(debug, "drawLineF(x0=//d, x1=//d, y0=//d, y1=//d, color=//X)\n", x0, x1, y0, y1, color); #endif int dy = y1 - y0; int dx = x1 - x0; int stepx, stepy; int fraction; 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 */ setPixel3(y0, x0, color); if (dx > dy) { fraction = dy - (dx >> 1); /* same as 2*dy - dx */ while (x0 != x1) { if (fraction >= 0) { y0 += stepy; fraction -= dx; /* same as fraction -= 2*dx */ } x0 += stepx; fraction += dy; /* same as fraction -= 2*dy */ setPixel3(y0, x0, color); } } else {
//Draws a character void drawChar3(int r, int c, char chr, u16 fg_color, u16 bg_color) { for (int i = 0; i < TEXT_WIDTH; i++) { for (int j = 0; j < TEXT_HEIGHT; j++) { if (!get_bit(fontdata[OFFSET(chr, i, TEXT_WIDTH)], TEXT_HEIGHT-j-1)) { setPixel3(j+r, i+c, bg_color); } else { setPixel3(j+r, i+c, fg_color); } } } }
//Draws a hollow rectangle void drawHollowRect3(int r, int c, int width, int height, u16 color) { //Draw the top and bottom of the rectangle for (int j = 0; j < width; j++) { setPixel3(r, j, color); setPixel3(r+height-1, j, color); } //Draw the sides for (int i = 1; i < height-1; i++) { setPixel3(i, c, color); setPixel3(i, c+width-1, color); } }
//Draws a filled rectangle void drawRect3(int r, int c, int width, int height, u16 color) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { setPixel3(i+r, j+c, color); } } }
//Draws an image array void drawImage3(int r, int c, int width, int height, const u16* img) { int img_ndx = 0; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { setPixel3(i+r, j+c, img[img_ndx++]); } } }
//Draws an image array slowly void drawImageDelayed3(int r, int c, int width, int height, const u16* img, int delay) { int img_ndx = 0; volatile int k; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { setPixel3(i+r, j+c, img[img_ndx++]); for (k = 0; k < 250*delay; k++); } } }
void drawChar3(int row, int col, char ch, unsigned short color) { int r, c; for(r=0; r<8; r++) { for(c=0; c<6; c++) { if(fontdata_6x8[ch*6*8+r*6+c]) { setPixel3(row+r, col+c, color); } } } }