[cairo-commit] cairo-demo/quartz fdface.c, 1.1, 1.2 fdhand.c, 1.1, 1.2 fdlogo.c, 1.1, 1.2 main.c, 1.2, 1.3

Tim Rowley commit at pdx.freedesktop.org
Wed May 11 15:40:20 PDT 2005


Committed by: tor

Update of /cvs/cairo/cairo-demo/quartz
In directory gabe:/tmp/cvs-serv9211

Modified Files:
	fdface.c fdhand.c fdlogo.c main.c 
Log Message:
Update quartz demo to new api.


Index: fdface.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/quartz/fdface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- fdface.c	21 Jan 2005 04:00:33 -0000	1.1
+++ fdface.c	11 May 2005 22:40:18 -0000	1.2
@@ -29,9 +29,9 @@
 {
     cairo_save (cr);
     cairo_arc (cr, 0, 0, radius, 0, 2 * M_PI);
-    cairo_set_rgb_color (cr, 0.231, 0.502, 0.682);
+    cairo_set_source_rgb (cr, 0.231, 0.502, 0.682);
     cairo_fill (cr);
-    cairo_set_rgb_color (cr, 0.73, 0.73, 0.73);
+    cairo_set_source_rgb (cr, 0.73, 0.73, 0.73);
     cairo_set_line_width (cr, radius * 2 / 3);
     cairo_arc (cr, 0, 0, radius * 2, 0, 2 * M_PI);
     cairo_stroke (cr);
@@ -43,7 +43,7 @@
 {
     cairo_save (cr);
     cairo_arc (cr, 0, 0, radius, 0, 2 * M_PI);
-    cairo_set_rgb_color (cr, 0.73, 0.73, 0.73);
+    cairo_set_source_rgb (cr, 0.73, 0.73, 0.73);
     cairo_fill (cr);
     cairo_restore (cr);
 }

Index: fdhand.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/quartz/fdhand.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- fdhand.c	21 Jan 2005 04:00:33 -0000	1.1
+++ fdhand.c	11 May 2005 22:40:18 -0000	1.2
@@ -76,15 +76,14 @@
 draw_hand (cairo_t *cr, double noon_deg, double width, double length, double alt,
 	   void (*draw) (cairo_t *cr, double width, double length))
 {
-    cairo_matrix_t  *m = cairo_matrix_create ();
-    cairo_current_matrix (cr, m);
+    cairo_matrix_t m;
+    cairo_get_matrix (cr, &m);
     {
 	cairo_translate (cr, alt/2, alt);
 	cairo_rotate (cr, noon_deg * M_PI / 180.0 - M_PI_2);
 	(*draw) (cr, width, length);
     }
-    cairo_set_matrix (cr, m);
-    cairo_matrix_destroy (m);
+    cairo_set_matrix (cr, &m);
 }
 
 #define HOUR_WIDTH	0.03
@@ -122,12 +121,10 @@
 	if (seconds)
 	    draw_hand (cr, second_angle, SECOND_WIDTH, SECOND_LENGTH,
 		       SECOND_ALT, draw_second);
-	cairo_set_rgb_color (cr, 0, 0, 0);
-	cairo_set_alpha (cr, 0.3);
+	cairo_set_source_rgba (cr, 0, 0, 0, 0.3);
 	cairo_fill (cr);
 	
-	cairo_set_rgb_color (cr, 0, 0, 0);
-	cairo_set_alpha (cr, 1);
+	cairo_set_source_rgba (cr, 0, 0, 0, 1);
 	draw_hand (cr, hour_angle, HOUR_WIDTH, HOUR_LENGTH, 
 		   0.0, draw_hour);
 	cairo_fill (cr);

Index: fdlogo.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/quartz/fdlogo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- fdlogo.c	21 Jan 2005 04:00:33 -0000	1.1
+++ fdlogo.c	11 May 2005 22:40:18 -0000	1.2
@@ -56,7 +56,7 @@
 static void
 draw_outline (cairo_t *cr)
 {
-    cairo_set_rgb_color (cr, 0.73, 0.73, 0.73);
+    cairo_set_source_rgb (cr, 0.73, 0.73, 0.73);
     cairo_set_line_width (cr, 2);
     draw_boundary (cr);
     cairo_stroke (cr);
@@ -66,7 +66,7 @@
 draw_background (cairo_t *cr)
 {
     cairo_save (cr);
-    cairo_set_rgb_color (cr, 0.231, 0.502, 0.682);
+    cairo_set_source_rgb (cr, 0.231, 0.502, 0.682);
     cairo_translate (cr, 3.5, 3.5);
     cairo_scale (cr, 0.887, 0.848);
     draw_boundary (cr);
@@ -115,11 +115,11 @@
 	draw_window (cr);
 	cairo_save (cr);
 	{
-	    cairo_set_rgb_color (cr, 1, 1, 1);
+	    cairo_set_source_rgb (cr, 1, 1, 1);
 	    cairo_fill (cr);
 	}
 	cairo_restore (cr);
-	cairo_set_rgb_color (cr, 0.231, 0.502, 0.682);
+	cairo_set_source_rgb (cr, 0.231, 0.502, 0.682);
 	cairo_scale (cr, 1/scale, 1/scale);
 	cairo_stroke (cr);
     }
@@ -135,8 +135,7 @@
 	cairo_line_to (cr, 48.25, 20.375);
 	cairo_line_to (cr, 30.25, 35.825);
 	cairo_close_path (cr);
-	cairo_set_rgb_color (cr, 1, 1, 1);
-	cairo_set_alpha (cr, 0.5);
+	cairo_set_source_rgba (cr, 1, 1, 1, 0.5);
 	cairo_stroke (cr);
     }
     cairo_restore (cr);

Index: main.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/quartz/main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- main.c	21 Jan 2005 04:00:33 -0000	1.2
+++ main.c	11 May 2005 22:40:18 -0000	1.3
@@ -53,6 +53,7 @@
 	    {
 		CGContextRef	context;
 		cairo_t		*cr;
+		cairo_surface_t *surface;
 		int		width, height;
 
 
@@ -61,9 +62,8 @@
 
 		QDBeginCGContext(GetWindowPort(window), &context);
 
-		cr = cairo_create();
-
-		cairo_set_target_quartz_context(cr, context, width, height);
+		surface = cairo_quartz_surface_create(context, width, height);
+		cr = cairo_create(surface);
 
 
 	    #if 1
@@ -85,9 +85,9 @@
 		// Draw one of the Cairo snippets
 		cairo_scale(cr, width/1.0, height/1.0);
 		cairo_rectangle(cr, 0,0, 1.0, 1.0);
-		cairo_set_rgb_color(cr, 1,1,1);
+		cairo_set_source_rgb(cr, 1,1,1);
 		cairo_fill(cr);
-		cairo_set_rgb_color(cr, 0.0, 0.0, 0.0);
+		cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
 		cairo_set_line_width(cr, 0.04);
 		
 		#if 1
@@ -96,9 +96,11 @@
 		    const char *utf8 = "cairo";
 		    double x,y;
 
-		    cairo_select_font(cr, "Times", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+		    cairo_select_font_face(cr, "Times",
+					   CAIRO_FONT_SLANT_NORMAL,
+					   CAIRO_FONT_WEIGHT_NORMAL);
 
-		    cairo_scale_font(cr, 0.4);
+		    cairo_set_font_size(cr, 0.4);
 		    cairo_text_extents(cr, utf8, &extents);
 
 		    x=0.1;
@@ -108,8 +110,7 @@
 		    cairo_show_text(cr, utf8);
 
 		    // draw helping lines
-		    cairo_set_rgb_color(cr, 1,0.2,0.2);
-		    cairo_set_alpha(cr, 0.6);
+		    cairo_set_source_rgba(cr, 1,0.2,0.2,0.6);
 		    cairo_arc(cr, x, y, 0.05, 0, 2*M_PI);
 		    cairo_fill(cr);
 		    cairo_move_to(cr, x,y);




More information about the cairo-commit mailing list