/* draws everything else */ void draw_1dtetris (TWidget *wid, ttk_surface srf) { char buffer[8]; if (score == 0) snprintf(buffer, 8, "%d", score); else snprintf(buffer, 8, "%d00", score); // draw playfield ttk_fillrect (srf, 0, 0, w, HWH, ttk_makecol(BLACK)); ttk_rect (srf, pf_x, 6, pf_x+pf_w, 6+pf_h, ttk_makecol(WHITE)); ttk_line (srf, pf_x+1, 6, pf_x+pf_w-2, 6, ttk_makecol(BLACK)); // draw next frame ttk_rect (srf, nf_x, nf_y, nf_x+nf_w, nf_y+nf_h, ttk_makecol(WHITE)); ttk_text (srf, ttk_textfont, nf_x+1, nf_y-ttk_text_height(ttk_textfont), ttk_makecol(WHITE), "next"); // draw score frame ttk_rect (srf, sf_x, nf_y, sf_x+sf_w, nf_y+nf_w, ttk_makecol(WHITE)); ttk_text (srf, ttk_textfont, sf_x+1, nf_y-ttk_text_height(ttk_textfont), ttk_makecol(WHITE), "score"); ttk_text (srf, ttk_textfont, sf_x+sf_w-ttk_text_width(ttk_textfont, buffer)-3, nf_y + (nf_w/2 - ttk_text_height(ttk_textfont)/2), ttk_makecol(WHITE), buffer); // draw moving brick draw_brick(srf, pf_x, 7-(sq_size*brick_length), brick_length, brick_depth); // draw next brick draw_brick(srf, nf_x+sq_size/2, nf_y+sq_size/2, next_length, 0); // hide bad programming skills for users eyes :) ttk_fillrect (srf, pf_x, 0, pf_x+pf_w, 6, ttk_makecol(BLACK)); }
static void duckhunt_message (char *message) { int length; length = pz_vector_width (message, 6, 8, 1); ttk_rect (duckhunt_srf, ((WIDTH/2)-(length/2))-6, ((HEIGHT/3)-(8/2))-6, ((WIDTH/2)+(length/2))+6, ((HEIGHT/3)+(8/2))+6, ttk_makecol(WHITE)); ttk_fillrect (duckhunt_srf, ((WIDTH/2)-(length/2))-5, ((HEIGHT/3)-(8/2))-5, ((WIDTH/2)+(length/2))+5, ((HEIGHT/3)+(8/2))+5, ttk_makecol(BLACK)); pz_vector_string (duckhunt_srf, message, (WIDTH/2)-(length/2), (HEIGHT/3)-(8/2), 6, 8, 1, ttk_makecol(WHITE)); }
le * eval_gfx_DrawRect ( lithp_burrito * lb, const int argc, le * branch ) { int x,y,a,b; if( !lb || !branch || argc != 5 ) return( leNew( "NIL" )); eval_getint_4( lb, branch, &x, &y, &a, &b ); ttk_rect( lb->srf, x, y, a, b, lb->pen1 ); return( leNew( "T" )); }
static void draw_digit( ttk_surface srf, clocks_globals *glob, int w, int v, int use_ap, ttk_color c_ol, ttk_color c_fill, ttk_color c_dark ) { /* 0 1 2 3 */ int array[9]; /* the bits - one for each light */ TApItem *boxOn = NULL, *boxOnB = NULL; TApItem *boxOff = NULL, *boxOffB = NULL; int x, z; /* misc */ int sx=0, sy=0; /* start x/ start y for the box */ int w2 = glob->w>>1; /* w/2 */ int h2 = glob->h>>1; /* h/2 */ int w6 = glob->w/6; /* w/6 */ int h6 = glob->h/6; /* h/6 */ /* the positions in the 3x3 grid for each of the 9 lights */ int xp[9] = { 0, w6, w6+w6, 0, w6, w6+w6, 0, w6, w6+w6 }; int yp[9] = { 0, 0, 0, h6, h6, h6, h6+h6, h6+h6, h6+h6 }; /* determine sx/sy */ if( w & 0x01 ) sx = w2; else sx = 0; if( w & 0x02 ) sy = h2; else sy = 0; /* use the apearance colorscheme */ if( use_ap ) { if( w == 0 || w == 3 ) { boxOff = ttk_ap_getx( "box.default.bg" ); boxOffB = ttk_ap_getx( "box.default.border" ); boxOn = ttk_ap_getx( "box.selected.bg" ); boxOnB = ttk_ap_getx( "box.selected.border" ); } else { boxOff = ttk_ap_getx( "box.default.bg" ); boxOffB = ttk_ap_getx( "box.default.border" ); boxOn = ttk_ap_getx( "box.special.bg" ); boxOnB = ttk_ap_getx( "box.special.border" ); } } /* generate the array */ for( x=0 ; x<9 ; x++ ) array[x] = 0; for( x=0 ; x<v ; ) { int idx = rand()%9; if( !array[idx]) { array[idx] = 1; x++; } } /* draw the number */ /* 0 1 2 3 4 5 6 7 8 */ for( z=0 ; z<9 ; z++ ) { int x1 = sx+xp[z]+INS; int y1 = sy+yp[z]+INS; int x2 = sx+xp[z]+w6-INS; int y2 = sy+yp[z]+h6-INS; if( use_ap ) { ttk_ap_fillrect( srf, (array[z])? boxOn : boxOff, x1, y1, x2, y2 ); ttk_ap_rect( srf, (array[z])? boxOnB : boxOffB, x1, y1, x2, y2 ); } else { if( array[z] ) { ttk_fillrect( srf, x1, y1, x2, y2, c_fill ); ttk_rect( srf, x1, y1, x2, y2, c_ol ); } else { ttk_fillrect( srf, x1, y1, x2, y2, c_dark ); } } } }