forked from old/legacy-imlib2
Added rectangle clipping, in the form:
void imlib_image_draw_rectangle_clipped(int x, int y, int width, int height, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax); Works well. If you make install then cd test, make, ./imlib2, you'll see the demo/test of the clipping code. Next up: draw_polygon and draw_polygon_clipped. Then (eeek) fill_polygon, fill_polygon_clipped, and some clipping for image blending (fun). SVN revision: 3276
This commit is contained in:
parent
ee1b52edaa
commit
e423fc372d
|
@ -233,6 +233,10 @@ Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2, char make_up
|
|||
* rectangle */
|
||||
Imlib_Updates imlib_image_draw_line_clipped(int x1, int y1, int x2, int y2, int clip_xmin, int clip_xmax, int clip_ymin, int clip_ymax, char make_updates);
|
||||
void imlib_image_draw_rectangle(int x, int y, int width, int height);
|
||||
void
|
||||
imlib_image_draw_rectangle_clipped(int x, int y, int width, int height,
|
||||
int clip_xmin, int clip_xmax, int clip_ymin,
|
||||
int clip_ymax);
|
||||
void imlib_image_fill_rectangle(int x, int y, int width, int height);
|
||||
void imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x, int y);
|
||||
void imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source, int x, int y, int width, int height, int destination_x, int destination_y);
|
||||
|
|
|
@ -1237,6 +1237,24 @@ __imlib_draw_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r, DATA8 g,
|
|||
__imlib_draw_line(im, x + w - 1, y, x + w - 1, y + h - 1, r, g, b, a, op, 0);
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_draw_box_clipped(ImlibImage * im, int x, int y, int w, int h,
|
||||
int clip_xmin, int clip_xmax, int clip_ymin,
|
||||
int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||
ImlibOp op)
|
||||
{
|
||||
__imlib_draw_line_clipped(im, x, y, x + w - 1, y, clip_xmin, clip_xmax,
|
||||
clip_ymin, clip_ymax, r, g, b, a, op, 0);
|
||||
__imlib_draw_line_clipped(im, x, y, x, y + h - 1, clip_xmin, clip_xmax,
|
||||
clip_ymin, clip_ymax, r, g, b, a, op, 0);
|
||||
__imlib_draw_line_clipped(im, x, y + h - 1, x + w - 1, y + h - 1, clip_xmin,
|
||||
clip_xmax, clip_ymin, clip_ymax, r, g, b, a, op,
|
||||
0);
|
||||
__imlib_draw_line_clipped(im, x + w - 1, y, x + w - 1, y + h - 1, clip_xmin,
|
||||
clip_xmax, clip_ymin, clip_ymax, r, g, b, a, op,
|
||||
0);
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_draw_filled_box(ImlibImage * im, int x, int y, int w, int h, DATA8 r,
|
||||
DATA8 g, DATA8 b, DATA8 a, ImlibOp op)
|
||||
|
@ -1592,8 +1610,9 @@ __imlib_clip_line(int x0, int y0, int x1, int y1, int xmin, int xmax, int ymin,
|
|||
return accept;
|
||||
}
|
||||
|
||||
ImlibOutCode __imlib_comp_outcode(double x, double y, double xmin, double xmax,
|
||||
double ymin, double ymax)
|
||||
ImlibOutCode
|
||||
__imlib_comp_outcode(double x, double y, double xmin, double xmax, double ymin,
|
||||
double ymax)
|
||||
{
|
||||
ImlibOutCode code = 0;
|
||||
|
||||
|
|
|
@ -33,4 +33,9 @@ __imlib_draw_line_clipped(ImlibImage * im, int x1, int y1, int x2, int y2,
|
|||
int clip_xmin, int clip_xmax, int clip_ymin,
|
||||
int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||
ImlibOp op, char make_updates);
|
||||
void
|
||||
__imlib_draw_box_clipped(ImlibImage * im, int x, int y, int w, int h,
|
||||
int clip_xmin, int clip_xmax, int clip_ymin,
|
||||
int clip_ymax, DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||
ImlibOp op);
|
||||
#endif
|
||||
|
|
52
test/main.c
52
test/main.c
|
@ -761,8 +761,58 @@ int main (int argc, char **argv)
|
|||
imlib_context_set_color(255, 255, 255, 255);
|
||||
uu = imlib_image_draw_line(200, 200, x, y, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
uu = imlib_image_draw_line_clipped(200, 0, 0, 200, 50, 100, 0, 300, 1);
|
||||
|
||||
/* test line clipping */
|
||||
imlib_image_draw_rectangle(50,50,100,100);
|
||||
up = imlib_update_append_rect(up, 50,50,100,100);
|
||||
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
uu = imlib_image_draw_line(0, 0, 200, 200, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
uu = imlib_image_draw_line_clipped(0, 0, 200, 200, 50, 150, 50, 150, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
uu = imlib_image_draw_line(305, 25, 20, 200, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
uu = imlib_image_draw_line_clipped(305, 25, 20, 200, 50, 150, 50, 150, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
uu = imlib_image_draw_line(100, 5, 100, 205, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
uu = imlib_image_draw_line_clipped(100, 5, 100, 205, 50, 150, 50, 150, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
uu = imlib_image_draw_line(275, 5, 20, 100, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
uu = imlib_image_draw_line_clipped(275, 5, 20, 100, 50, 150, 50, 150, 1);
|
||||
up = imlib_updates_append_updates(up, uu);
|
||||
|
||||
/* test rectangle clipping */
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
imlib_image_draw_rectangle(70,90,20,20);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
imlib_image_draw_rectangle_clipped(70,90,20,20,50, 150, 50, 150);
|
||||
up = imlib_update_append_rect(up, 70,90,20,20);
|
||||
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
imlib_image_draw_rectangle(115,70,60,30);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
imlib_image_draw_rectangle_clipped(115,70,60,30,50, 150, 50, 150);
|
||||
up = imlib_update_append_rect(up, 115,70,60,30);
|
||||
|
||||
imlib_context_set_color(255, 255, 255, 255);
|
||||
imlib_image_draw_rectangle(30,120,50,50);
|
||||
imlib_context_set_color(255, 55, 55, 255);
|
||||
imlib_image_draw_rectangle_clipped(30,120,50,50,50, 150, 50, 150);
|
||||
up = imlib_update_append_rect(up, 30,120,50,50);
|
||||
|
||||
}
|
||||
{
|
||||
static Imlib_Color_Range rg = NULL;
|
||||
|
|
Loading…
Reference in New Issue