static void draw_board(int m, int n) { int i, j, x, y, len; x = 100 + n * D ; y = 100 + m * D ; for (i = x - R; i <= x +R; i++) for (j = y - R; j <= y + R; j++) { switch (board[m][n]) { case BLACK: len = sqrt((x - i)*(x - i) + (y -j)*(y -j)); if (len <= R) { fb_draw_point(i, j, 0x00); fb_draw_point(xres() - 200 + D / 2 + (x - i), R + 10 + (y -j), 0xFF); } break; case WHITE: len = sqrt((x - i)*(x - i) + (y -j)*(y -j)); if (len <= R) { fb_draw_point(i, j, 0xFF); fb_draw_point(xres() - 200 + D / 2 + (x - i), R + 10 + (y -j), 0x00); } break; case NONE: break; default: break; } } }
void dram(int x, int y) { int x1, y1; for (x1 = x; x1 < y; x1++) for (y1 = x; y1 < y; y1++) { fb_draw_point(x1, y1, 0xaf); } }
void dram(int x, int y) { int x1, y1; for (x1 = x; x1 < y; x1++) for (y1 = x; y1 < y; y1++) { if ( ((x1-(x+R))*(x1-(x+R))+(y1-(y-R))*(y1-(y-R))) <= R*R) fb_draw_point(x1, y1, 0xaf); } }
void clear(int x, int y) { int x1, y1; for (x1 = x; x1 <= y; x1++) for (y1 = x; y1 < y; y1++) { fb_draw_point(x1, y1, 0x00); } }
static void draw_element(int x, int y, int color) { int i, j; x+=800; //y+=200; for (i = 0; i < DRAW_BLOCK_SIZE; i++) { for (j = 0; j < DRAW_BLOCK_SIZE; j++) { fb_draw_point(x+j, y+i, color); } } }
void draw_element(int x, int y, int color) { int px = x*SIZE; int py = y*SIZE; int i, j; for (i = 0; i < SIZE; i++) { for (j = 0; j < SIZE; j++) { fb_draw_point(px+j, py+i, color); } } }
void circle(int x, int y, int r, int color) { int i, j; for (i = x - r; i <= x + r; i++) { for (j = y - r; j <= y + r; j++) { if ((i - x) * (i - x) + (j - y) * (j - y) <= r * r) { fb_draw_point(i, j, color); } } } }
static void init_board(void) { int i, j, startx = 50, starty = 50, endx=xres() - 50, endy = yres() - 50; int BW = 1, che_count = 1, winner = 1, space = 0, col = 0; boardx = (endx - 100) / D > MAXBOARD ? MAXBOARD: (endx - 100) / D; boardy = (endy - 100) / D > MAXBOARD ? MAXBOARD: (endy - 100) / D; system("clear"); for (; startx <= endx - 400 ; startx += D) for (starty = 100; starty <= endy; starty +=D) { for (i = 0; i <= D; i++) for (j = 0; j <= D; j++) if ((i < D - 1) && (j < D -1) ) { fb_draw_point(i+startx ,j+starty , 244); } else fb_draw_point(i+startx ,j+starty ,0x00); //printdig(i+startx ,j+starty , col++); } }
void draw_box_v2(int x, int y, int size, struct color_v *color) { int i, j; struct color_v deeptmp, deepline, lighttmp; deeptmp.b = color->b - 7; deeptmp.g = color->g - 25; deeptmp.r = color->r - 7; deepline.b = color->b - 10; deepline.g = color->g - 30; deepline.r = color->r - 10; lighttmp.b = color->b + 7; lighttmp.g = (color->g + 15) > 255 ? 255 :(color->g + 15) ; lighttmp.r = color->r + 7; for (i = 0; i < size; i++) for (j = 0; y >= 100 && j < size; j++) if (i > 0 && j > 0 && (i < size - 3) && (j < size - 3)) { if ((i > 2 && i < size - 5 && (j == 2 || j == size - 5)) || \ (j > 2 && j < size - 5 && (i == 2 || i == size - 5)) ) fb_draw_point_v2(i+x, j+y, &deepline);// draw 4 deep line else if ((i == 2 || i == D - 5) && ( j == 2 || j == D - 5)) fb_draw_point(i + x, j + y, BG); // draw 4 point else if (((i==D/4*1 || i == D/4*3-1) && j> D/4*1 && j < D/4*3-1) \ ||((j ==D/4*1 || j == D/4*3-1) && i > D/4*1 && i < D/4*3-1)) fb_draw_point_v2(i+x ,j+y,&lighttmp); // draw light line else if (i > D/4*1 && i < D/4*3-1 && j > D/4*1 && j < D/4*3-1) fb_draw_point_v2(i+x ,j+y, &deeptmp); // draw deep box else fb_draw_point_v2(i+x ,j+y, color); // draw box } else if (i == size -1 || j == size -1) fb_draw_point(i + x, j + y, BG); // draw BG line else if (i == 0 || i == size-2 || j == 0 || j == size - 2) fb_draw_point_v2(i+x ,j+y, &deeptmp); // draw shadow }
int main(void) { int x, y; int ret; ret = fb_open(); if (ret != 0) { fprintf(stderr, "fb_open() error.\n"); exit(1); } // for (x = 0; x < xres(); x++) // for (y = 0; y < yres(); y++) { // fb_draw_point(x, y, 0x30); // } for (x = 300; x < 400; x++) for (y = 300; y < 400; y++) { fb_draw_point(x, y, 0xaf); } fb_close(); return 0; }