9. Rectangle
9.1. Stroked Rectangle
<<funcdefs>>=
void btprnt_draw_rect(btprnt_region *r,
int x, int y,
int w, int h,
int clr);
<<funcs>>=
void btprnt_draw_rect(btprnt_region *r,
int x, int y,
int w, int h,
int clr)
{
btprnt_draw_hline(r, x, y, w, clr);
btprnt_draw_hline(r, x, y + (h - 1), w, clr);
btprnt_draw_vline(r, x, y, h, clr);
btprnt_draw_vline(r, x + (w - 1), y, h, clr);
}
9.2. Filled Rectangle
<<funcdefs>>=
void btprnt_draw_rect_filled(btprnt_region *r,
int xpos, int ypos,
int w, int h,
int clr);
<<funcs>>=
void btprnt_draw_rect_filled(btprnt_region *r,
int xpos, int ypos,
int w, int h,
int clr)
{
int x, y;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
btprnt_region_draw(r,
xpos + x,
ypos + y,
clr);
}
}
}
prev | home | next