[cairo-commit] cairo-5c/examples draw.5c, 1.3, 1.4 fob.5c, 1.1, 1.2 graph.5c, 1.4, 1.5 grid.5c, 1.3, 1.4 led.5c, 1.1, 1.2 pie-new.5c, 1.1, 1.2 pie.5c, 1.6, 1.7 rottext.5c, 1.5, 1.6 sin.5c, 1.3, 1.4 spin-cairo.5c, 1.1, 1.2 spin.5c, 1.1, 1.2 spinman.5c, 1.1, 1.2 test.5c, 1.3, 1.4 text45.5c, 1.1, 1.2

Keith Packard commit at pdx.freedesktop.org
Mon May 2 13:24:41 PDT 2005


Committed by: keithp

Update of /cvs/cairo/cairo-5c/examples
In directory gabe:/tmp/cvs-serv16744/examples

Modified Files:
	draw.5c fob.5c graph.5c grid.5c led.5c pie-new.5c pie.5c 
	rottext.5c sin.5c spin-cairo.5c spin.5c spinman.5c test.5c 
	text45.5c 
Log Message:
2005-05-02  Keith Packard  <keithp at keithp.com>

	* cairo-5c.h:
	* cairo.5c:
	* cairo.c: (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable),
	(do_Cairo_get_target_surface):
	* event.c: (do_Cairo_Surface_open_event):
	* gstate.c: (do_Cairo_set_source_rgb), (do_Cairo_set_source_rgba),
	(do_Cairo_get_matrix), (do_Cairo_concat_matrix),
	(do_Cairo_set_matrix), (do_Cairo_get_operator),
	(do_Cairo_get_tolerance), (do_Cairo_get_current_point),
	(do_Cairo_get_fill_rule), (do_Cairo_get_line_width),
	(do_Cairo_get_line_cap), (do_Cairo_get_line_join),
	(do_Cairo_get_miter_limit):
	* gtk.c: (delete_drawing_area), (motion_notify_event),
	(button_press_event), (button_release_event),
	(gtk_repaint_timeout), (gtk_thread_main), (gtk_global_free),
	(create_gtk_global), (cairo_5c_tool_dirty), (cairo_5c_tool_enable):
	* init.c: (init_types), (nickle_init):
	* matrix.c: (cairo_matrix_part), (new_cairo_matrix):
	* pattern.c: (do_Cairo_set_source), (do_Cairo_get_source),
	(do_Cairo_Pattern_set_matrix), (do_Cairo_Pattern_get_matrix):
	* surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark),
	(cairo_5c_surface_destroy), (do_Cairo_Surface_create_image),
	(do_Cairo_Surface_write_to_png):
	* text.c: (do_Cairo_set_font), (do_Cairo_set_font_size),
	(do_Cairo_set_font_matrix), (do_Cairo_font_extents):
	Match cairo API as of today.

	* examples/draw.5c:
	* examples/fob.5c:
	* examples/graph.5c:
	* examples/grid.5c:
	* examples/led.5c:
	* examples/pie-new.5c:
	* examples/pie.5c:
	* examples/rottext.5c:
	* examples/sin.5c:
	* examples/spin-cairo.5c:
	* examples/spin.5c:
	* examples/spinman.5c:
	* examples/test.5c:
	* examples/text45.5c:
	Update examples to match API changes


Index: draw.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/draw.5c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- draw.5c	23 Dec 2004 22:39:40 -0000	1.3
+++ draw.5c	2 May 2005 20:24:39 -0000	1.4
@@ -67,7 +67,7 @@
 		break;
 	    case 2:
 		save (cr);
-		set_rgb_color (cr, 1, 0, 0);
+		set_source_rgb (cr, 1, 0, 0);
 		move_to (cr, ox - 10, oy - 10);
 		line_to (cr, ox + 10, oy + 10);
 		move_to (cr, ox - 10, oy + 10);
@@ -78,7 +78,7 @@
 	    case 3:
 		save (cr);
 		identity_matrix (cr);
-		set_rgb_color (cr, 1, 1, 1);
+		set_source_rgb (cr, 1, 1, 1);
 		move_to (cr, 0, 0);
 		line_to (cr, width(cr), 0);
 		line_to (cr, width(cr), height(cr));

Index: fob.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/fob.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- fob.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ fob.5c	2 May 2005 20:24:39 -0000	1.2
@@ -52,7 +52,7 @@
 	pattern_t pat = Pattern::create_radial (12, 12, 0, 9, 9, 7);
 	Pattern::add_color_stop (pat, 0, 1, 1, 1, 1);
 	Pattern::add_color_stop (pat, 1, 1, .8, .6, 1);
-	set_pattern (cr, pat);
+	set_source (cr, pat);
 	fill (cr);
 	restore (cr);
 	scale (cr, 1/3.5, 1/4);
@@ -64,7 +64,7 @@
     {
 	save (cr);
 	translate (cr, x, y);
-	set_rgb_color (cr, 1, 1, 1);
+	set_source_rgb (cr, 1, 1, 1);
 	arc (cr, 0, 0, 4, 0, 2*pi);
 	fill (cr);
 	restore (cr);
@@ -74,7 +74,7 @@
     {
 	save (cr);
 	translate (cr, x, y);
-	set_rgb_color (cr, .5, .5, 1);
+	set_source_rgb (cr, .5, .5, 1);
 	arc (cr, 0, 0, 2.5, 0, 2*pi);
 	fill (cr);
 	restore (cr);
@@ -84,7 +84,7 @@
     {
 	save (cr);
 	translate (cr, x, y);
-	set_rgb_color (cr, 0, 0, 0);
+	set_source_rgb (cr, 0, 0, 0);
 	arc (cr, 0, 0, 1.8, 0, 2*pi);
 	fill (cr);
 	restore (cr);
@@ -98,7 +98,7 @@
 	Pattern::add_color_stop (pat, 0, 1, 1, 1, .5);
 	Pattern::add_color_stop (pat, .5, 0, 0, 0, 0);
 	Pattern::add_color_stop (pat, 1, 0, 0, 0, 0);
-	set_pattern (cr, pat);
+	set_source (cr, pat);
 	arc (cr, 0, 0, 4, 0, 2*pi);
 	fill (cr);
 	restore (cr);
@@ -129,7 +129,7 @@
 		pattern_t pat = Pattern::create_linear (0, 0, 11, 11);
 		Pattern::add_color_stop (pat, 0, .4, .4, .4, 1);
 		Pattern::add_color_stop (pat, 1, 1, 1, 1, 1);
-		set_pattern (cr, pat);
+		set_source (cr, pat);
 	    }
 	    else
 	    {
@@ -137,7 +137,7 @@
 							6.5, 6.5, 8);
 		Pattern::add_color_stop (pat, 0, 1, 1, 1, 1);
 		Pattern::add_color_stop (pat, 1, .3, .3, .3, 1);
-		set_pattern (cr, pat);
+		set_source (cr, pat);
 	    }
 	    fill (cr); 
 	    restore (cr);
@@ -149,7 +149,7 @@
     {
 	save (cr);
 	select_font (cr, "sans", font_slant_t.NORMAL, font_weight_t.NORMAL);
-	scale_font (cr, 40);
+	set_font_size (cr, 40);
 	rotate (cr, 90 * pi / 180);
 	translate (cr, 12, -20);
 	move_to (cr, 0, 0);
@@ -165,8 +165,9 @@
 	save (cr);
 	set_line_width (cr, 3);
 	move_to (cr, 12, 20);
-	set_rgb_color (cr, 0, 0, 0);
-	rel_curve_to (cr, 3, 0, 2, 3, 5, 6);
+	set_source_rgba (cr, 0, 0, 0, 1);
+#	rel_curve_to (cr, 3, 0, 2, 3, 5, 6);
+	curve_to (cr, 15, 20, 14, 23, 17, 26);
 	stroke (cr);
 	restore (cr);
     }
@@ -180,33 +181,39 @@
     earpiece (cr);
 }
 
-if (true)
+void
+fob_to_png (cairo_t cr, string filename)
 {
-    cairo_t cr = new_png ("fob.png", 80, 90);
-    fob (cr);
+    fob (cr); write_to_png (cr, filename);
+}
+
+if (false)
+{
+    cairo_t cr = new_image (80, 90);
+    fob_to_png (cr, "fob.png");
     destroy (cr);
     
-    cairo_t cr = new_png ("fob-450.png", 400, 450);
+    cairo_t cr = new_image (400, 450);
     scale (cr, 5, 5);
-    fob (cr);
+    fob_to_png (cr, "fob-450.png");
     destroy (cr);
     
-    cairo_t cr = new_png ("fob-16.png", 16, 16);
+    cairo_t cr = new_image (16, 16);
     scale (cr, 0.1{7}, 0.1{7});
     translate (cr, 5, 0);
-    fob (cr);
+    fob_to_png (cr, "fob-16.png");
     destroy (cr);
 
-    cairo_t cr = new_png ("fob-32.png", 32, 32);
+    cairo_t cr = new_image (32, 32);
     scale (cr, 0.3{5}, 0.3{5});
     translate (cr, 5, 0);
-    fob (cr);
+    fob_to_png (cr, "fob-32.png");
     destroy (cr);
     
-    cairo_t cr = new_png ("fob-48.png", 48, 48);
+    cairo_t cr = new_image (48, 48);
     scale (cr, 0.5{3}, 0.5{3});
     translate (cr, 5, 0);
-    fob (cr);
+    fob_to_png (cr, "fob-48.png");
     destroy (cr);
 }
 else

Index: graph.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/graph.5c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- graph.5c	14 Mar 2005 21:43:06 -0000	1.4
+++ graph.5c	2 May 2005 20:24:39 -0000	1.5
@@ -89,7 +89,7 @@
 	    rel_line_to (cr, 0, 10);
 	}
 	stroke (cr);
-        font_extents_t  f = current_font_extents (cr);
+        font_extents_t  f = font_extents (cr);
 	printf ("font extents: %v\n", f);
 	for (real major = axis.scale.low; major <= axis.scale.high; major += axis.major)
 	{
@@ -108,9 +108,14 @@
 	axis_draw (cr, g.bottom);
 	restore (cr);
 	save (cr);
-	transform_font (cr, (matrix_t) { { 1, 0 }, { 0, -1 }, { 0, 0 } });
-	set_matrix (cr, Matrix::multiply ((matrix_t) { { 0, 1 }, 
-	    { 1, 0 }, { 0, 0 } }, current_matrix (cr)));
+	set_font_matrix (cr, (matrix_t) {
+	    xx = 1, yx = 0,
+	    xy = 0, yy = -1,
+	    x0 = 0, y0 = 0 });
+	set_matrix (cr, Matrix::multiply ((matrix_t) { 
+	    xx = 0, yx = 1,
+	    xy = 1, yy = 0,
+	    x0 = 0, y0 = 0 }, get_matrix (cr)));
 				  
 	axis_draw (cr, g.left);
 	restore (cr);
@@ -118,7 +123,10 @@
         
     public graph_t new (cairo_t cr) {
 	set_font (cr, "sans-12");
-	transform_font (cr, (matrix_t) { { 1, 0 }, { 0, -1 }, { 0, 0 } });
+	set_font_matrix (cr, (matrix_t) {
+	    xx = 1, yx = 0,
+	    xy = 0, yy = -1,
+	    x0 = 0, y0 = 0 });
 	translate (cr, 0, height(cr));
 	Cairo::scale (cr, 1, -1);
 	

Index: grid.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/grid.5c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- grid.5c	14 Mar 2005 21:52:22 -0000	1.3
+++ grid.5c	2 May 2005 20:24:39 -0000	1.4
@@ -71,7 +71,7 @@
 void
 grid_png (string filename, int width, int height, real major, real x_minor, y_minor)
 {
-    cairo_t cr = new_png (filename, width, height);
+    cairo_t cr = new_image (width, height);
     set_line_width (cr, 2);
     grid (cr, 
 	  (grid_t) { min = 0, max = width, space = major },
@@ -81,6 +81,7 @@
 	  (grid_t) { min = 0.5 + x_minor//2, max = width + 0.5, space = x_minor },
 	  (grid_t) { min = 0.5 + y_minor//2, max = height + 0.5, space = y_minor },
 	  major / 20);
+    write_to_png (cr, filename);
     destroy (cr);
 }
 

Index: led.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/led.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- led.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ led.5c	2 May 2005 20:24:39 -0000	1.2
@@ -48,7 +48,7 @@
     
     if (true)
     {
-	set_rgb_color (cr, red *.4, green *.4, blue *.4);
+	set_source_rgb (cr, red *.4, green *.4, blue *.4);
 	move_to (cr, 1, 1/2);
 	arc (cr, .5, .5, .5, 0, pi*2);
 	fill (cr);
@@ -62,7 +62,7 @@
 	Pattern::add_color_stop (led, 0, red, green, blue, 1);
 	Pattern::add_color_stop (led, .5, red, green, blue, .8);
 	Pattern::add_color_stop (led, 1, red, green, blue, 0);
-	set_pattern (cr, led);
+	set_source (cr, led);
 	move_to (cr, 1, 1/2);
 	arc (cr, .5, .5, .5, 0, pi*2);
 	fill (cr);
@@ -75,7 +75,7 @@
 	Pattern::add_color_stop (ring, 0, 0, 0, 0, 1);
 	Pattern::add_color_stop (ring, .5, 0, 0, 0, 1);
 	Pattern::add_color_stop (ring, 1, .5, .5, .5, 1);
-	set_pattern (cr, ring);
+	set_source (cr, ring);
 	move_to (cr, 1, 1/2);
 	arc (cr, .5, .5, .5, 0, pi*2);
 	move_to (cr, 1, 1/2);
@@ -89,7 +89,7 @@
 	pattern_t	room = Pattern::create_radial (1/3, 1/3, 0, 1/3, 1/3, 1/2);
 	Pattern::add_color_stop (room, 0, 1, 1, 1, .4);
 	Pattern::add_color_stop (room, 1, 1, 1, 1, 0);
-	set_pattern (cr, room);
+	set_source (cr, room);
 	move_to (cr, 1, 1/2);
 	arc (cr, .5, .5, .5, 0, pi*2);
 	fill (cr);
@@ -104,11 +104,13 @@
 
 void do_one (string name, real red, real green, real blue, bool on)
 {
-    cairo_t cr = new_png (name, diameter, diameter);
+    cairo_t cr = new_image (diameter, diameter);
     
     translate (cr, -width(cr)/2, -height(cr)/2);
     scale (cr, width(cr), height(cr));
     led (cr, red, green, blue, on);
+    write_to_png (cr, name);
+    destroy (cr);
 }
 
 void doit ()

Index: pie-new.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/pie-new.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pie-new.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ pie-new.5c	2 May 2005 20:24:39 -0000	1.2
@@ -41,58 +41,6 @@
  * http://research.compaq.com/SRC/m3sources/html/color/src/Color.i3.html
  */
 
-real[3] to_hsv(real r, real g, real b)
-{
-    real minimum = min (r, g, b);
-    real maximum = max (r, g, b);
-    real v = maximum;
-    real s = (maximum == 0) ? 0 : (maximum - minimum) / maximum;
-    real h = 0;
-    if (s != 0)
-    {
-	switch (maximum) {
-	case r:	h =       (g - b) / (maximum - minimum);  break;
-	case g:	h = 2.0 + (b - r) / (maximum - minimum);  break;
-	case b:	h = 4.0 + (r - g) / (maximum - minimum);  break;
-	}
-	h = h / 6;
-    }
-    return (real[3]) { h, s, v };
-}
-
-/* convert hsv to rgb */
-
-real[3] from_hsv(real h, real s, real v)
-{
-    if (v == 0.0)
-	return (real[3]) { 0 ... };
-    else if (s == 0.0) {
-	return (real[3]) { v ... };
-    } else {
-	real h6 = (h * 6) % 6;
-	int  i = floor (h6);
-	real f = h6 - i;
-	real p = v * (1 - s);
-	real q = v * (1 - (s * f));
-	real t = v * (1 - (s * (1 - f)));
-
-	switch(i) {
-	default:return (real[3]) { v, t, p };
-	case 1: return (real[3]) { q, v, p };
-	case 2: return (real[3]) { p, v, t };
-	case 3: return (real[3]) { p, q, v };
-	case 4: return (real[3]) { t, p, v };
-	case 5: return (real[3]) { v, p, q };
-	}
-    }
-}
-
-void set_hsv_color (foreign cr, real h, real s, real v)
-{
-    real[3] rgb = from_hsv (h, s, v);
-    Cairo::set_rgb_color (cr, rgb[0], rgb[1], rgb[2]);
-}
-
 real π = pi;
 real text_width (cairo_t cr, string text) = text_extents (cr, text).width;
 real text_height(cairo_t cr, string text) = text_extents (cr, text).height;
@@ -153,7 +101,7 @@
 
 	save (cr);
 	rotate (cr, θ + π ÷ 2);
-	set_hsv_color (cr, θ / (2 * pi), 1, 0.7);
+	set_source_hsv (cr, θ / (2 * pi), 1, 0.7);
 	
 	translate (cr, 0, -radius);
 /*	translate   (cr, -width ÷ 2, -radius); */
@@ -191,7 +139,7 @@
 
 	save (cr);
 	rotate (cr, θ + π ÷ 2);
-	set_hsv_color (cr, θ / (2 * pi), 1, 0.7);
+	set_source_hsv (cr, θ / (2 * pi), 1, 0.7);
 	
 	move_to (cr, 0, 0);
 	line_to (cr, 0, -radius);

Index: pie.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/pie.5c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pie.5c	19 Dec 2004 00:06:26 -0000	1.6
+++ pie.5c	2 May 2005 20:24:39 -0000	1.7
@@ -36,63 +36,6 @@
 
 autoimport Cairo;
 
-/*
- * Adapted from algorithms found at
- * http://research.compaq.com/SRC/m3sources/html/color/src/Color.i3.html
- */
-
-real[3] to_hsv(real r, real g, real b)
-{
-    real minimum = min (r, g, b);
-    real maximum = max (r, g, b);
-    real v = maximum;
-    real s = (maximum == 0) ? 0 : (maximum - minimum) / maximum;
-    real h = 0;
-    if (s != 0)
-    {
-	switch (maximum) {
-	case r:	h =       (g - b) / (maximum - minimum);  break;
-	case g:	h = 2.0 + (b - r) / (maximum - minimum);  break;
-	case b:	h = 4.0 + (r - g) / (maximum - minimum);  break;
-	}
-	h = h / 6;
-    }
-    return (real[3]) { h, s, v };
-}
-
-/* convert hsv to rgb */
-
-real[3] from_hsv(real h, real s, real v)
-{
-    if (v == 0.0)
-	return (real[3]) { 0 ... };
-    else if (s == 0.0) {
-	return (real[3]) { v ... };
-    } else {
-	real h6 = (h * 6) % 6;
-	int  i = floor (h6);
-	real f = h6 - i;
-	real p = v * (1 - s);
-	real q = v * (1 - (s * f));
-	real t = v * (1 - (s * (1 - f)));
-
-	switch(i) {
-	default:return (real[3]) { v, t, p };
-	case 1: return (real[3]) { q, v, p };
-	case 2: return (real[3]) { p, v, t };
-	case 3: return (real[3]) { p, q, v };
-	case 4: return (real[3]) { t, p, v };
-	case 5: return (real[3]) { v, p, q };
-	}
-    }
-}
-
-void set_hsv_color (foreign cr, real h, real s, real v)
-{
-    real[3] rgb = from_hsv (h, s, v);
-    Cairo::set_rgb_color (cr, rgb[0], rgb[1], rgb[2]);
-}
-
 real π = pi;
 real text_width (cairo_t cr, string text) = text_extents (cr, text).width;
 real text_height(cairo_t cr, string text) = text_extents (cr, text).height;
@@ -147,7 +90,7 @@
 
 	save (cr);
 	rotate (cr, θ + π ÷ 2);
-	set_hsv_color (cr, θ / (2 * pi), 1, 0.7);
+	set_source_hsv (cr, θ / (2 * pi), 1, 0.7);
 	
 	translate   (cr, -width ÷ 2, -radius);
 	

Index: rottext.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/rottext.5c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rottext.5c	23 Dec 2004 22:39:40 -0000	1.5
+++ rottext.5c	2 May 2005 20:24:39 -0000	1.6
@@ -39,7 +39,7 @@
 void rottext () {
     cairo_t	cr = new ();
     set_font (cr, "sans-20");
-    set_rgb_color (cr, 0, 0, 0);
+    set_source_rgb (cr, 0, 0, 0);
     
     for (real a = 0; a < 2 * pi; a += pi / 10) {
 	save (cr);

Index: sin.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/sin.5c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sin.5c	17 Dec 2004 02:09:46 -0000	1.3
+++ sin.5c	2 May 2005 20:24:39 -0000	1.4
@@ -38,7 +38,7 @@
 void clear (foreign cr) {
     save (cr);
     identity_matrix (cr);
-    set_rgb_color (cr, 1, 1, 1);
+    set_source_rgb (cr, 1, 1, 1);
     int w = width (cr);
     int h = height (cr);
     move_to (cr, 0, 0);
@@ -50,19 +50,19 @@
 }
 
 void draw_sin (foreign cr) {
+    clear (cr);
     set_line_width (cr, sqrt (width(cr)**2 + height(cr)**2) * 0.01);
-    real[3,2] m = current_matrix (cr);
+    save (cr);
     translate (cr, width(cr)/2, height(cr)/2);
     scale (cr, .95 * width(cr) / (2 * pi), .95 * height(cr) / 2);
     move_to (cr, -pi, 0);
     for (real a = -pi; a <= pi; a += pi/100) {
 	line_to (cr, a, sin(a));
     }
-    set_matrix (cr, m);
-    clear (cr);
+    restore (cr);
     stroke (cr);
 }
 
-foreign cr = new ();
+cairo_t cr = new ();
 draw_sin (cr);
 while (true) sleep (1000);

Index: spin-cairo.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/spin-cairo.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- spin-cairo.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ spin-cairo.5c	2 May 2005 20:24:39 -0000	1.2
@@ -50,7 +50,7 @@
 	    twixt (save (cr); restore (cr)) 
 	    {
 		identity_matrix (cr);
-		set_rgb_color (cr, 1, 1, 1);
+		set_source_rgb (cr, 1, 1, 1);
 		rectangle (cr, 0, 0, width(cr), height(cr));
 		fill (cr);
 	    }
@@ -58,7 +58,7 @@
 	    {
 		translate (cr, off_x, off_x);
 		rotate (cr, t * pi / 60);
-		set_rgb_color (cr, 0, 0, 0);
+		set_source_rgb (cr, 0, 0, 0);
 		move_to (cr, -off_x, -off_y);
 		show_text (cr, "CAIRO");
 	    }

Index: spin.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/spin.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- spin.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ spin.5c	2 May 2005 20:24:39 -0000	1.2
@@ -41,7 +41,7 @@
 void clear (cairo_t cr) {
     save (cr);
     identity_matrix (cr);
-    set_rgb_color (cr, 1, 1, 1);
+    set_source_rgb (cr, 1, 1, 1);
     rectangle (cr, 0, 0, width(cr), height(cr));
     fill (cr);
     restore (cr);
@@ -51,7 +51,7 @@
 {
     save (cr);
     
-    set_rgb_color (cr, 0, 0, 0);
+    set_source_rgb (cr, 0, 0, 0);
     move_to (cr, off_x, off_y);
 #    show_text (cr, "nickle and cairo together");
     text_path (cr, "C");
@@ -60,12 +60,12 @@
     
     move_to (cr, off_x, off_y);
     rel_line_to (cr, 250, 0);
-    set_rgb_color (cr, 0, 0, 1);
+    set_source_rgb (cr, 0, 0, 1);
     stroke (cr);
     
     move_to (cr, 5, 0);
     arc (cr, 5, 0, 5, 0, 10);
-    set_rgb_color (cr, 1, 0, 0);
+    set_source_rgb (cr, 1, 0, 0);
     fill (cr);
     restore (cr);
 }
@@ -79,16 +79,16 @@
 void animate (cairo_t cr)
 {
     cairo_t crl = create ();
-    set_target_surface (crl, current_target_surface (cr));
+    set_target_surface (crl, get_target_surface (cr));
     set_font (crl, "sans-12");
-    set_rgb_color (crl, 0, 0, 0);
+    set_source_rgb (crl, 0, 0, 0);
     real t = 0;
     for (;;)
     {
 	disable (cr);
 	save (cr);
 	translate (cr, 100, 100);
-	set_rgb_color (cr, 1, 1, 1);
+	set_source_rgb (cr, 1, 1, 1);
 	clear (cr);
 	move_to (crl, 3, 20);
 	show_text (crl, sprintf ("%5.2f", t));

Index: spinman.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/spinman.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- spinman.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ spinman.5c	2 May 2005 20:24:39 -0000	1.2
@@ -41,7 +41,7 @@
 void clear (cairo_t cr) {
     save (cr);
     identity_matrix (cr);
-    set_rgb_color (cr, 1, 1, 1);
+    set_source_rgb (cr, 1, 1, 1);
     rectangle (cr, 0, 0, width(cr), height(cr));
     fill (cr);
     restore (cr);
@@ -51,19 +51,19 @@
 {
     save (cr);
     
-    set_rgb_color (cr, 0, 0, 0);
+    set_source_rgb (cr, 0, 0, 0);
     move_to (cr, off_x, off_y);
 #    show_text (cr, "nickle and cairo together");
     show_text (cr, "CAIRO");
     
     move_to (cr, off_x, off_y);
     rel_line_to (cr, 250, 0);
-    set_rgb_color (cr, 0, 0, 1);
+    set_source_rgb (cr, 0, 0, 1);
     stroke (cr);
     
     move_to (cr, 5, 0);
     arc (cr, 5, 0, 5, 0, 10);
-    set_rgb_color (cr, 1, 0, 0);
+    set_source_rgb (cr, 1, 0, 0);
     fill (cr);
     restore (cr);
 }
@@ -126,9 +126,9 @@
 void animate (cairo_t cr)
 {
     cairo_t crl = create ();
-    set_target_surface (crl, current_target_surface (cr));
+    set_target_surface (crl, get_target_surface (cr));
     set_font (crl, "sans-12");
-    set_rgb_color (crl, 0, 0, 0);
+    set_source_rgb (crl, 0, 0, 0);
     translate (cr, 150, 150);
     real t = 0;
     bool down = false;

Index: test.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/test.5c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test.5c	17 Dec 2004 02:09:46 -0000	1.3
+++ test.5c	2 May 2005 20:24:39 -0000	1.4
@@ -35,15 +35,14 @@
     
 autoimport Cairo;
 
-typedef foreign cairo_t;
-
-cr = new ();
-set_rgb_color (cr,0,0,0);
+cairo_t cr = new ();
+set_source_rgb (cr,0,0,0);
 move_to (cr, 10, 10);
 line_to (cr, 100, 100);
 stroke (cr);
 move_to (cr, 50, 50);
-set_rgb_color (cr, 0.8, 0, 0.5);
+set_source_rgb (cr, 0.8, 0, 0.5);
 set_alpha (cr, 0.5);
 scale_font (cr, 12);
 show_text (cr, "Hello, cairo");
+sleep (100000);

Index: text45.5c
===================================================================
RCS file: /cvs/cairo/cairo-5c/examples/text45.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- text45.5c	14 Mar 2005 21:52:22 -0000	1.1
+++ text45.5c	2 May 2005 20:24:39 -0000	1.2
@@ -39,7 +39,7 @@
 void text45 () {
     cairo_t	cr = new ();
     set_font (cr, "sans-20");
-    set_rgb_color (cr, 0, 0, 0);
+    set_source_rgb (cr, 0, 0, 0);
     
     save (cr);
     translate (cr, 150, 150);




More information about the cairo-commit mailing list