static void make_texture(cube21_conf *cp) { int x, y, x0, y0; float grayp[2] = {TEX_GRAY}; for(y=0; y<TEX_HEIGHT; y++) for(x=0; x<TEX_WIDTH; x++) cp->texture[y][x] = 255; draw_horz_line(cp, 0, TEX_WIDTH-1, 0); draw_horz_line(cp, cp->texq*TEX_WIDTH, TEX_WIDTH-1, cp->texp*TEX_HEIGHT); draw_horz_line(cp, cp->texq*TEX_WIDTH, TEX_WIDTH-1, cp->texq*TEX_HEIGHT); draw_horz_line(cp, 0, cp->texq*TEX_WIDTH, TEX_HEIGHT/2); draw_horz_line(cp, 0, TEX_WIDTH-1, TEX_HEIGHT*3/4); draw_horz_line(cp, 0, TEX_WIDTH-1, TEX_HEIGHT-1); draw_vert_line(cp, 0, 0, TEX_HEIGHT-1); draw_vert_line(cp, cp->texq*TEX_WIDTH, 0, TEX_HEIGHT*3/4); draw_vert_line(cp, TEX_WIDTH-1, 0, TEX_HEIGHT-1); draw_slanted_horz(cp, 0, cp->texp*TEX_HEIGHT, TEX_WIDTH/2, TEX_HEIGHT/2); draw_slanted_vert(cp, cp->texp*TEX_WIDTH, 0, TEX_WIDTH/2, TEX_HEIGHT/2); draw_slanted_vert(cp, cp->texq*TEX_WIDTH, 0, TEX_WIDTH/2, TEX_HEIGHT/2); x0 = grayp[0]*TEX_WIDTH; y0 = grayp[1]*TEX_HEIGHT; for(y=-1; y<=1; y++) for(x=-1; x<=1; x++) cp->texture[y0+y][x0+x] = 100; }
void gfx_draw_rect(rect_t rect) { draw_horiz_line(rect.x, rect.y, rect.width-1); draw_horiz_line(rect.x, rect.y + rect.height-1, rect.width-1); draw_vert_line(rect.x, rect.y, rect.height); draw_vert_line(rect.x + rect.width-1, rect.y, rect.height); }
static void make_texture(rubikblocks_conf *cp) { int x, y; for(y = 0; y < TEX_HEIGHT; y++) for(x = 0; x < TEX_WIDTH; x++) cp->texture[y][x] = 255; draw_horz_line(cp, 0, TEX_WIDTH-1, 0); draw_horz_line(cp, 0, TEX_WIDTH-1, TEX_HEIGHT-1); draw_vert_line(cp, 0, 0, TEX_HEIGHT-1); draw_vert_line(cp, TEX_WIDTH-1, 0, TEX_HEIGHT-1); }
void draw_rectangle(screen_t screen,int x, int y,int x2, int y2, char col) { int x_count,y_count; if(col&FILLED) { for(y_count=y;y_count<=y2;y_count++) for(x_count=x;x_count<=x2;x_count++) put_pixel(screen,x_count,y_count,col); } else { draw_horiz_line(screen,x,y,x2,col); draw_horiz_line(screen,x,y2,x2,col); draw_vert_line(screen,x,y,y2,col); draw_vert_line(screen,x2,y,y2,col); } }
static void bscope_render (const gfloat * data) { bscope_blur (); gint prev_y = (0.5 + data[0]) * height; prev_y = CLAMP (prev_y, 0, height - 1); for (gint i = 0; i < width; i ++) { gint y = (0.5 + data[i * 512 / width]) * height; y = CLAMP (y, 0, height - 1); draw_vert_line (i, prev_y, y); prev_y = y; } bscope_draw (); }
/* * move_left * DESCRIPTION: Move the player right one pixel (assumed to be a legal move) * INPUTS: xpos -- pointer to player's x position (pixel) in the maze * OUTPUTS: *xpos -- decreased by one from initial value * RETURN VALUE: none * SIDE EFFECTS: pans display by one pixel when appropriate */ static void move_left (int* xpos) { /* * Move player by one pixel and check whether display should be panned. * Panning is necessary when the player moves past the left pan border * while the leftmost pixels of the maze are not on-screen. */ if (--(*xpos) < game_info.map_x + BLOCK_X_DIM * PAN_BORDER && game_info.map_x > SHOW_MIN) { /* * Shift the logical view to the left by one pixel and draw the * new line. */ set_view_window (--game_info.map_x, game_info.map_y); (void)draw_vert_line (0); } }
/* * move_photo_right * DESCRIPTION: Move background photo right one or more pixels. Amount of * motion depends on game_info.x_speed. Movement stops at * left edge of photo. * INPUTS: none * OUTPUTS: none * RETURN VALUE: none * SIDE EFFECTS: shifts view window */ static void move_photo_right () { int32_t delta; /* Number of pixels by which to move. */ int32_t idx; /* Index over columns to redraw. */ /* Calculate the number of pixels by which to move. */ delta = (game_info.x_speed > game_info.map_x ? game_info.map_x : game_info.x_speed); /* Shift the logical view to the left. */ game_info.map_x -= delta; set_view_window (game_info.map_x, game_info.map_y); /* Draw the newly exposed lines. */ for (idx = 0; delta > idx; idx++) { (void)draw_vert_line (idx); } }
/* * move_photo_left * DESCRIPTION: Move background photo left one or more pixels. Amount of * motion depends on game_info.x_speed. Movement stops at * right edge of photo. * INPUTS: none * OUTPUTS: none * RETURN VALUE: none * SIDE EFFECTS: shifts view window */ static void move_photo_left () { int32_t delta; /* Number of pixels by which to move. */ int32_t idx; /* Index over columns to redraw. */ /* Calculate the number of pixels by which to move. */ delta = room_photo_width (game_info.where) - SCROLL_X_DIM - game_info.map_x; delta = (game_info.x_speed > delta ? delta : game_info.x_speed); /* Shift the logical view to the right. */ game_info.map_x += delta; set_view_window (game_info.map_x, game_info.map_y); /* Draw the newly exposed lines. */ for (idx = 1; delta >= idx; idx++) { (void)draw_vert_line (SCROLL_X_DIM - idx); } }
/* * move_right * DESCRIPTION: Move the player right one pixel (assumed to be a legal move) * INPUTS: xpos -- pointer to player's x position (pixel) in the maze * OUTPUTS: *xpos -- increased by one from initial value * RETURN VALUE: none * SIDE EFFECTS: pans display by one pixel when appropriate */ static void move_right (int* xpos) { /* * Move player by one pixel and check whether display should be panned. * Panning is necessary when the player moves past the right pan border * while the rightmost pixels of the maze are not on-screen. */ if (++(*xpos) > game_info.map_x + SCROLL_X_DIM - BLOCK_X_DIM * (PAN_BORDER + 1) && game_info.map_x + SCROLL_X_DIM < (2 * game_info.maze_x_dim + 1) * BLOCK_X_DIM - SHOW_MIN) { /* * Shift the logical view to the right by one pixel and draw the * new line. */ set_view_window (++game_info.map_x, game_info.map_y); (void)draw_vert_line (SCROLL_X_DIM - 1); } }
void gfx_draw_line(int x1, int y1, int x2, int y2) { double delta, tx, ty; if (((x2 - x1) < 0)) { swap(int, x1, x2); swap(int, y1, y2); } if (((y2 - y1) < 0)) { swap(int, x1, x2); swap(int, y1, y2); } if (y1 == y2) { if (x1 > x2) { swap(int, x1, x2); } draw_horiz_line(x1, y1, x2 - x1); } else if (x1 == x2) { if (y1 > y2) { swap(int, y1, y2); } draw_vert_line(x1, y1, y2 - y1); } else if (abs(x2 - x1) > abs(y2 - y1)) { delta = ((double) (y2 - y1)) / ((double) (x2 - x1)); ty = (double) (y1); if (x1 > x2) { int i; for (i = x1; i >= x2; i--) { gfx_set_cursor(i, (int) (ty + 0.5), i, (int) (ty + 0.5)); lcd_write_data(ctx->fcolor); ty = ty - delta; } } else { int i; for (i = x1; i <= x2; i++) { gfx_set_cursor(i, (int) (ty + 0.5), i, (int) (ty + 0.5)); lcd_write_data(ctx->fcolor); ty = ty + delta; } } } else { delta = ((float) (x2 - x1)) / ((float) (y2 - y1)); tx = (float) (x1); if (y1 > y2) { int i; for (i = y2 + 1; i > y1; i--) { gfx_set_cursor((int) (tx + 0.5), i, (int) (tx + 0.5), i); lcd_write_data(ctx->fcolor); tx = tx + delta; } } else { int i; for (i = y1; i < y2 + 1; i++) { gfx_set_cursor((int) (tx + 0.5), i, (int) (tx + 0.5), i); lcd_write_data(ctx->fcolor); tx = tx + delta; } } } lcd_clr_cursor(); }