[cairo-commit] cairo/test ps-surface.c,1.3,1.4

Carl Worth commit at pdx.freedesktop.org
Thu Jan 12 13:36:39 PST 2006


Committed by: cworth

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv20396/test

Modified Files:
	ps-surface.c 
Log Message:

2006-01-12  Carl Worth  <cworth at cworth.org>

        Some fixes for the fact that multi-page output was totally broken
        for cairo_ps_surface_t (at least):

        * src/cairo-ps-surface.c: (_cairo_ps_surface_emit_header),
        (_cairo_ps_surface_emit_footer),
        (_cairo_ps_surface_create_for_stream_internal),
        (_cairo_ps_surface_start_page), (_cairo_ps_surface_end_page),
        (_cairo_ps_surface_copy_page), (_cairo_ps_surface_show_page),
        (_cairo_ps_surface_composite), (_cairo_ps_surface_fill_rectangles),
        (_cairo_ps_surface_composite_trapezoids),
        (_cairo_ps_surface_old_show_glyphs), (_cairo_ps_surface_fill):
        Move the Y-axis-flipping to be on a per-page basis (as it was
        before and as it must be). Put page number back in, (still missing
        th number of pages from the header).

        * test/ps-surface.c: (draw), (main): Add multi-page output for
        better testing.


Index: ps-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/test/ps-surface.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ps-surface.c	10 Oct 2005 16:36:39 -0000	1.3
+++ ps-surface.c	12 Jan 2006 21:36:37 -0000	1.4
@@ -39,12 +39,17 @@
 #define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
 
 static void
-draw (cairo_t *cr, double width, double height)
+draw (cairo_t *cr, double width, double height, double smile_ratio)
 {
 #define STROKE_WIDTH .04
-
     double size;
 
+    double theta = M_PI / 4 * smile_ratio;
+    double dx = sqrt (0.005) * cos (theta);
+    double dy = sqrt (0.005) * sin (theta);
+
+    cairo_save (cr);
+
     if (width > height)
 	size = height;
     else
@@ -72,12 +77,15 @@
     cairo_fill (cr);
 
     /* Mouth */
-    cairo_move_to (cr, 0.3, 0.7);
+    cairo_move_to (cr,
+		   0.35 - dx, 0.75 - dy);
     cairo_curve_to (cr,
-		    0.4, 0.8,
-		    0.6, 0.8,
-		    0.7, 0.7);
+		    0.35 + dx, 0.75 + dy,
+		    0.65 - dx, 0.75 + dy,
+		    0.65 + dx, 0.75 - dy);
     cairo_stroke (cr);
+
+    cairo_restore (cr);
 }
 
 int
@@ -86,6 +94,7 @@
     cairo_t *cr;
     const char *filename = "ps-surface.ps";
     cairo_surface_t *surface;
+    int i;
 
     printf("\n");
 
@@ -98,9 +107,11 @@
 
     cr = cairo_create (surface);
 
-    draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
-
-    cairo_show_page (cr);
+#define NUM_PAGES 5
+    for (i=0; i < NUM_PAGES; i++) {
+	draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS, (double) i / (NUM_PAGES - 1));
+	cairo_show_page (cr);
+    }
 
     cairo_destroy (cr);
     cairo_surface_destroy (surface);



More information about the cairo-commit mailing list