[cairo-commit] cairo-demo/cairo_snippets curve_rectangle.cairo, NONE, 1.1 ChangeLog, 1.8, 1.9 Makefile, 1.6, 1.7

OEyvind Kolaas commit at pdx.freedesktop.org
Wed May 19 02:39:02 PDT 2004


Committed by: pippin

Update of /cvs/cairo/cairo-demo/cairo_snippets
In directory pdx:/tmp/cvs-serv8261

Modified Files:
	ChangeLog Makefile 
Added Files:
	curve_rectangle.cairo 
Log Message:
added curved_rectangle snippet, which also tests alpha stroking


--- NEW FILE: curve_rectangle.cairo ---
/* a custom shape, that could be wrapped in a function */
double x0     = 0.1,   /*< parameters like cairo_rectangle */
       y0     = 0.1,
       width  = 0.8,
       height = 0.8,
       radius = 0.4;   /*< and an approximate curvature radius */

double x1,y1;

x1=x0+width;
y1=y0+height;
if (!width || !height)
    return;
if (width/2<radius) {
    if (height/2<radius) {
        cairo_move_to  (cr, x0, (y0 + y1)/2);
        cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
        cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
        cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
        cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
    } else {
        cairo_move_to  (cr, x0, y0 + radius);
        cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
        cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
        cairo_line_to (cr, x1 , y1 - radius);
        cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
        cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
    }
} else {
    if (height/2<radius) {
        cairo_move_to  (cr, x0, (y0 + y1)/2);
        cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
        cairo_line_to (cr, x1 - radius, y0);
        cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
        cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
        cairo_line_to (cr, x0 + radius, y1);
        cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
    } else {
        cairo_move_to  (cr, x0, y0 + radius);
        cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
        cairo_line_to (cr, x1 - radius, y0);
        cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
        cairo_line_to (cr, x1 , y1 - radius);
        cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
        cairo_line_to (cr, x0 + radius, y1);
        cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
    }
}
cairo_close_path (cr);

/* and fill/stroke it */
cairo_save (cr);
    cairo_set_rgb_color (cr, 0.5,0.5,1);
    cairo_fill (cr);
cairo_restore (cr);
cairo_set_alpha (cr, 0.5);
cairo_set_rgb_color (cr, 0.5, 0,0);
cairo_stroke (cr);

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/ChangeLog,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** a/ChangeLog	18 May 2004 21:54:57 -0000	1.8
--- b/ChangeLog	19 May 2004 09:39:00 -0000	1.9
***************
*** 1,3 ****
--- 1,7 ----
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 	* curve_rectangle.cairo: added a custom shape snippet, which also
+ 	tests storking with alpha
+ 
+ 2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
  	* Makefile: general cleanup, added target html
  	* cairo_snippets_png.c: removed html stuff

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** a/Makefile	18 May 2004 21:54:57 -0000	1.6
--- b/Makefile	19 May 2004 09:39:00 -0000	1.7
***************
*** 19,23 ****
  
  clean:
! 	rm -f prepare_snippets $(COMPILE_PROGS) snippets.c snippets.html *.png *.eps *.o *~
  
  cairo_snippets_html: cairo_snippets_html.o $(OBJS)
--- 19,28 ----
  
  clean:
! 	rm -f $(COMPILE_PROGS) \
! 	      prepare_snippets \
! 		  snippets.html    \
! 		  snippets.ps      \
! 		  snippets.pdf     \
! 		  *.png *.eps *.o *~
  
  cairo_snippets_html: cairo_snippets_html.o $(OBJS)





More information about the cairo-commit mailing list