[Commit] xrtest Makefile, 1.3, 1.4 xrfreq.c, 1.2, 1.3 xrknockout.c, 1.9, 1.10 xrspline.c, 1.9, 1.10 xrtest.c, 1.8, 1.9

Carl Worth commit at keithp.com
Fri Jul 18 12:35:25 PDT 2003


Committed by: cworth

Update of /local/src/CVS/xrtest
In directory home.keithp.com:/tmp/cvs-serv11925

Modified Files:
	Makefile xrfreq.c xrknockout.c xrspline.c xrtest.c 
Log Message:
Updated to work with Cairo rather than Xr

Index: Makefile
===================================================================
RCS file: /local/src/CVS/xrtest/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile	7 Jul 2003 11:07:33 -0000	1.3
+++ Makefile	18 Jul 2003 18:35:23 -0000	1.4
@@ -1,5 +1,5 @@
-CFLAGS=-g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls `pkg-config --cflags xr`
-LDFLAGS=`pkg-config --libs xr`
+CFLAGS=-g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls `pkg-config --cflags cairo`
+LDFLAGS=`pkg-config --libs cairo`
 
 PROGS=xrtest xrspline xrknockout xrfreq
 

Index: xrfreq.c
===================================================================
RCS file: /local/src/CVS/xrtest/xrfreq.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- xrfreq.c	25 Apr 2003 20:31:20 -0000	1.2
+++ xrfreq.c	18 Jul 2003 18:35:23 -0000	1.3
@@ -3,7 +3,7 @@
 #include <unistd.h>
 #include <math.h>
 
-#include <Xr.h>
+#include <cairo.h>
 
 #define EPSILON (1.0 / (2<<16))
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
@@ -98,15 +98,15 @@
     double cx, cy;
     double radius, theta, theta_inc;
 
-    XrState *xrs;
+    cairo_t *xrs;
     Drawable drawable = win->pix;
 
     XFillRectangle(dpy, win->pix, win->gc, 0, 0, win->width, win->height);
 
-    xrs = XrCreate();
+    xrs = cairo_create();
 
-    XrSetTargetDrawable(xrs, dpy, drawable);
-    XrSetRGBColor(xrs, 1, 1, 1);
+    cairo_set_target_drawable(xrs, dpy, drawable);
+    cairo_set_rgb_color(xrs, 1, 1, 1);
 
     cx = win->width / 2.0;
     cy = win->height / 2.0;
@@ -117,14 +117,14 @@
 
     theta_inc = 2 * M_PI / FINS;
     for (theta=0; theta < 2 * M_PI; theta += theta_inc) {
-	XrMoveTo(xrs, cx, cy);
-	XrLineTo(xrs, cx + radius * cos(theta), cy + radius * sin(theta));
-	XrLineTo(xrs, cx + radius * cos(theta + FIN_WIDTH), cy + radius * sin(theta + FIN_WIDTH));
-	XrClosePath(xrs);
-	XrFill(xrs);
+	cairo_move_to(xrs, cx, cy);
+	cairo_line_to(xrs, cx + radius * cos(theta), cy + radius * sin(theta));
+	cairo_line_to(xrs, cx + radius * cos(theta + FIN_WIDTH), cy + radius * sin(theta + FIN_WIDTH));
+	cairo_close_path(xrs);
+	cairo_fill(xrs);
     }
 
-    XrDestroy(xrs);
+    cairo_destroy(xrs);
 
     XCopyArea(win->dpy, win->pix, win->win, win->gc,
 	      0, 0, win->width, win->height,

Index: xrknockout.c
===================================================================
RCS file: /local/src/CVS/xrtest/xrknockout.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- xrknockout.c	7 Jul 2003 11:07:33 -0000	1.9
+++ xrknockout.c	18 Jul 2003 18:35:23 -0000	1.10
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
 /* Small example demonstrating emulating knockout-groups as in PDF-1.4
- * using XrSetOperator().
+ * using cairo_set_operator().
  *
  * Owen Taylor,
 
@@ -10,26 +10,26 @@
  * v0.3  17 April    2003 - Tracking changes in Xr, (Removal of Xr{Push,Pop}Group)
  */
 #include <X11/Xlib.h>
-#include <Xr.h>
+#include <cairo.h>
 #include <math.h>
 #include <stdio.h>
 
 /* Create a rectangular path
  */
 static void
-rect_path (XrState *r,
+rect_path (cairo_t *r,
            double x,     double y,
            double width, double height)
 {
-    XrNewPath (r);
-    XrMoveTo (r, x, y);
+    cairo_new_path (r);
+    cairo_move_to (r, x, y);
     
-    XrRelLineTo (r, 0, height);
-    XrRelLineTo (r, width, 0);
-    XrRelLineTo (r, 0, -height);
-    XrRelLineTo (r, -width, 0);
+    cairo_rel_line_to (r, 0, height);
+    cairo_rel_line_to (r, width, 0);
+    cairo_rel_line_to (r, 0, -height);
+    cairo_rel_line_to (r, -width, 0);
     
-    XrClosePath (r);
+    cairo_close_path (r);
 }
 
 /* Create a path that is roughly a circular oval with
@@ -38,14 +38,14 @@
  * (max of about 0.02%)
  */
 static void
-oval_path (XrState *r,
+oval_path (cairo_t *r,
            double xc, double yc,
            double xr, double yr)
 {
     int i;
     
-    XrNewPath (r);
-    XrMoveTo (r, xc + xr, yc);
+    cairo_new_path (r);
+    cairo_move_to (r, xc + xr, yc);
 
 #define TANGENT_MULT (1.65591 / 3.)
     
@@ -66,174 +66,174 @@
             double x2 = x3 + xr * sin (angle2) * TANGENT_MULT;
             double y2 = y3 + yr * cos (angle2) * TANGENT_MULT;
             
-            XrCurveTo (r, x1, y1, x2, y2, x3, y3);
+            cairo_curve_to (r, x1, y1, x2, y2, x3, y3);
         }
     
-    XrClosePath (r);
+    cairo_close_path (r);
 }
 
 /* Fill the given area with checks in the standard style
  * for showing compositing effects.
  */
 static void
-fill_checks (XrState *r,
+fill_checks (cairo_t *r,
              int x,     int y,
              int width, int height)
 {
-    XrSurface *check;
+    cairo_surface_t *check;
     
-    XrSave (r);
+    cairo_save (r);
 
 #define CHECK_SIZE 32
 
-    check = XrSurfaceCreateNextTo (XrGetTargetSurface (r),
-                                   XrFormatRGB24,
+    check = cairo_surface_create_similar (cairo_get_target_surface (r),
+                                   CAIRO_FORMAT_RGB24,
                                    2 * CHECK_SIZE, 2 * CHECK_SIZE);
-    XrSurfaceSetRepeat (check, 1);
+    cairo_surface_set_repeat (check, 1);
 
     /* Draw the check */
     {
-        XrSave (r);
+        cairo_save (r);
 
-        XrSetTargetSurface (r, check);
+        cairo_set_target_surface (r, check);
 
-        XrSetOperator (r, XrOperatorSrc);
+        cairo_set_operator (r, CAIRO_OPERATOR_SRC);
 
-        XrSetRGBColor (r, 0.4, 0.4, 0.4);
+        cairo_set_rgb_color (r, 0.4, 0.4, 0.4);
 
         rect_path (r, 0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
-        XrFill (r);
+        cairo_fill (r);
 
-        XrSetRGBColor (r, 0.7, 0.7, 0.7);
+        cairo_set_rgb_color (r, 0.7, 0.7, 0.7);
 
         rect_path (r, x, y, CHECK_SIZE, CHECK_SIZE);
-        XrFill (r);
+        cairo_fill (r);
         rect_path (r, x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
-        XrFill (r);
+        cairo_fill (r);
 
-        XrRestore (r);
+        cairo_restore (r);
     }
 
     /* Fill the whole surface with the check */
 
-    XrSetPattern (r, check);
+    cairo_set_pattern (r, check);
     rect_path (r, 0, 0, width, height);
-    XrFill (r);
+    cairo_fill (r);
 
-    XrSurfaceDestroy (check);
+    cairo_surface_destroy (check);
 
-    XrRestore (r);
+    cairo_restore (r);
 }
 
 /* Draw a red, green, and blue circle equally spaced inside
  * the larger circle of radius r at (xc, yc)
  */
 static void
-draw_3circles (XrState *r,
+draw_3circles (cairo_t *r,
                double xc, double yc,
                double radius)
 {
     double subradius = radius * (2 / 3. - 0.1);
     
-    XrSetRGBColor (r, 1., 0., 0.);
+    cairo_set_rgb_color (r, 1., 0., 0.);
     oval_path (r,
                xc + radius / 3. * cos (M_PI * (0.5)),
                yc - radius / 3. * sin (M_PI * (0.5)),
                subradius, subradius);
-    XrFill (r);
+    cairo_fill (r);
     
-    XrSetRGBColor (r, 0., 1., 0.);
+    cairo_set_rgb_color (r, 0., 1., 0.);
     oval_path (r,
                xc + radius / 3. * cos (M_PI * (0.5 + 2/.3)),
                yc - radius / 3. * sin (M_PI * (0.5 + 2/.3)),
                subradius, subradius);
-    XrFill (r);
+    cairo_fill (r);
     
-    XrSetRGBColor (r, 0., 0., 1.);
+    cairo_set_rgb_color (r, 0., 0., 1.);
     oval_path (r,
                xc + radius / 3. * cos (M_PI * (0.5 + 4/.3)),
                yc - radius / 3. * sin (M_PI * (0.5 + 4/.3)),
                subradius, subradius);
-    XrFill (r);
+    cairo_fill (r);
 }
 
 static void
-draw (XrState *r,
+draw (cairo_t *r,
       int      width,
       int      height)
 {
-    XrSurface *overlay, *punch, *circles;
+    cairo_surface_t *overlay, *punch, *circles;
 
     /* Fill the background */
     double radius = 0.5 * (width < height ? width : height) - 10;
     double xc = width / 2.;
     double yc = height / 2.;
 
-    overlay = XrSurfaceCreateNextTo (XrGetTargetSurface (r),
-                                     XrFormatARGB32,
+    overlay = cairo_surface_create_similar (cairo_get_target_surface (r),
+                                     CAIRO_FORMAT_ARGB32,
                                      width, height);
     if (overlay == NULL)
         return;
 
-    punch = XrSurfaceCreateNextTo (XrGetTargetSurface (r),
-                                   XrFormatA8,
+    punch = cairo_surface_create_similar (cairo_get_target_surface (r),
+                                   CAIRO_FORMAT_A8,
                                    width, height);
     if (punch == NULL)
         return;
 
-    circles = XrSurfaceCreateNextTo (XrGetTargetSurface (r),
-                                     XrFormatARGB32,
+    circles = cairo_surface_create_similar (cairo_get_target_surface (r),
+                                     CAIRO_FORMAT_ARGB32,
                                      width, height);
     if (circles == NULL)
         return;
     
     fill_checks (r, 0, 0, width, height);
 
-    XrSave (r);
-    XrSetTargetSurface (r, overlay);
+    cairo_save (r);
+    cairo_set_target_surface (r, overlay);
 
     /* Draw a black circle on the overlay
      */
-    XrSetRGBColor (r, 0., 0., 0.);
+    cairo_set_rgb_color (r, 0., 0., 0.);
     oval_path (r, xc, yc, radius, radius);
-    XrFill (r);
+    cairo_fill (r);
 
-    XrSave (r);
-    XrSetTargetSurface (r, punch);
+    cairo_save (r);
+    cairo_set_target_surface (r, punch);
 
     /* Draw 3 circles to the punch surface, then cut
      * that out of the main circle in the overlay
      */
     draw_3circles (r, xc, yc, radius);
 
-    XrRestore (r);
+    cairo_restore (r);
 
-    XrSetOperator (r, XrOperatorOutReverse);
-    XrShowSurface (r, punch, width, height);
+    cairo_set_operator (r, CAIRO_OPERATOR_OUT_REVERSE);
+    cairo_show_surface (r, punch, width, height);
 
     /* Now draw the 3 circles in a subgroup again
      * at half intensity, and use OperatorAdd to join up
      * without seams.
      */
-    XrSave (r);
-    XrSetTargetSurface (r, circles);
+    cairo_save (r);
+    cairo_set_target_surface (r, circles);
 
-    XrSetAlpha (r, 0.5);
-    XrSetOperator (r, XrOperatorOver);
+    cairo_set_alpha (r, 0.5);
+    cairo_set_operator (r, CAIRO_OPERATOR_OVER);
     draw_3circles (r, xc, yc, radius);
 
-    XrRestore (r);
+    cairo_restore (r);
 
-    XrSetOperator (r, XrOperatorAdd);
-    XrShowSurface (r, circles, width, height);
+    cairo_set_operator (r, CAIRO_OPERATOR_ADD);
+    cairo_show_surface (r, circles, width, height);
 
-    XrRestore (r);
+    cairo_restore (r);
 
-    XrShowSurface (r, overlay, width, height);
+    cairo_show_surface (r, overlay, width, height);
 
-    XrSurfaceDestroy (overlay);
-    XrSurfaceDestroy (punch);
-    XrSurfaceDestroy (circles);
+    cairo_surface_destroy (overlay);
+    cairo_surface_destroy (punch);
+    cairo_surface_destroy (circles);
 
 }
 
@@ -246,25 +246,25 @@
                Region   region)
 {
     Pixmap p;
-    XrState *r;
+    cairo_t *r;
     XRectangle clip;
     GC gc;
 
     /* Create an offscreen pixmap of the size of the
-     * area we need to repaint, and a XrState object
+     * area we need to repaint, and a cairo_t object
      * directed to that pixmap.
      */
     XClipBox (region, &clip);
     p = XCreatePixmap (dpy, win, clip.width, clip.height, DefaultDepth (dpy, screen));
 
-    r = XrCreate ();
+    r = cairo_create ();
 
-    XrSetTargetDrawable (r, dpy, p);
+    cairo_set_target_drawable (r, dpy, p);
 
     /* By adding a translation, we hide the partial
      * pixmap from our drawing routine
      */
-    XrTranslate (r, -clip.x, -clip.y);
+    cairo_translate (r, -clip.x, -clip.y);
 
     /* It would be nice to be able to set 'region' as
      * clip for our drawing, then only copy that portion
@@ -285,7 +285,7 @@
     XFreeGC (dpy, gc);
     
     XFreePixmap (dpy, p);
-    XrDestroy (r);
+    cairo_destroy (r);
 }
 
 int

Index: xrspline.c
===================================================================
RCS file: /local/src/CVS/xrtest/xrspline.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- xrspline.c	17 Apr 2003 20:41:17 -0000	1.9
+++ xrspline.c	18 Jul 2003 18:35:23 -0000	1.10
@@ -3,7 +3,7 @@
 #include <unistd.h>
 #include <math.h>
 
-#include <Xr.h>
+#include <cairo.h>
 
 #define EPSILON (1.0 / (2<<16))
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
@@ -40,7 +40,7 @@
 
     double tolerance;
     double line_width;
-    XrLineCap line_cap;
+    cairo_line_cap_t line_cap;
     spline_t spline;
     double zoom;
     double xtrans;
@@ -112,7 +112,7 @@
 static const double DEFAULT_YTRANS = 0.0;
 static const double DEFAULT_TOLERANCE = .1;
 static const double DEFAULT_LINE_WIDTH = 142;
-static const XrLineCap DEFAULT_LINE_CAP = XrLineCapButt;
+static const cairo_line_cap_t DEFAULT_LINE_CAP = CAIRO_LINE_CAP_BUTT;
 
 /* This was breaking the polygon tessellation code. All fixed now. */
 static const spline_t polygon_killer = {
@@ -323,54 +323,54 @@
 }
 
 static void
-draw_control_line(XrState *xrs, pt_t *a, pt_t *b, double width)
+draw_control_line(cairo_t *xrs, pt_t *a, pt_t *b, double width)
 {
-    XrSave(xrs);
+    cairo_save(xrs);
 
-    XrSetRGBColor(xrs, 0, 0, 1);
-    XrSetLineWidth(xrs, width);
+    cairo_set_rgb_color(xrs, 0, 0, 1);
+    cairo_set_line_width(xrs, width);
 
-    XrMoveTo(xrs, a->x, a->y);
-    XrLineTo(xrs, b->x, b->y);
-    XrStroke(xrs);
+    cairo_move_to(xrs, a->x, a->y);
+    cairo_line_to(xrs, b->x, b->y);
+    cairo_stroke(xrs);
 
-    XrRestore(xrs);
+    cairo_restore(xrs);
 }
 
 static void
-draw_handle(XrState *xrs, pt_t *p, int is_active, double size, double width)
+draw_handle(cairo_t *xrs, pt_t *p, int is_active, double size, double width)
 {
-    XrSave(xrs);
+    cairo_save(xrs);
 
     if (is_active)
-	XrSetRGBColor(xrs, 0, 1, 0);
+	cairo_set_rgb_color(xrs, 0, 1, 0);
     else
-	XrSetRGBColor(xrs, 1, 0, 0);
+	cairo_set_rgb_color(xrs, 1, 0, 0);
 
-    XrSetLineWidth(xrs, width);
+    cairo_set_line_width(xrs, width);
 
-    XrMoveTo(xrs, p->x - size / 2.0, p->y - size / 2.0);
-    XrRelLineTo(xrs, size, 0);
-    XrRelLineTo(xrs, 0, size);
-    XrRelLineTo(xrs, -size, 0);
-    XrRelLineTo(xrs, 0, -size);
-    XrStroke(xrs);
+    cairo_move_to(xrs, p->x - size / 2.0, p->y - size / 2.0);
+    cairo_rel_line_to(xrs, size, 0);
+    cairo_rel_line_to(xrs, 0, size);
+    cairo_rel_line_to(xrs, -size, 0);
+    cairo_rel_line_to(xrs, 0, -size);
+    cairo_stroke(xrs);
 
-    XrRestore(xrs);
+    cairo_restore(xrs);
 }
 
 static void
-draw_spline(XrState *xrs, win_t *win)
+draw_spline(cairo_t *xrs, win_t *win)
 {
     spline_t *spline = &win->spline;
     double zoom = win->zoom;
 
     int i;
 
-    XrSave(xrs);
+    cairo_save(xrs);
 
-    XrMoveTo(xrs, spline->pt[0].x, spline->pt[0].y);
-    XrCurveTo(xrs,
+    cairo_move_to(xrs, spline->pt[0].x, spline->pt[0].y);
+    cairo_curve_to(xrs,
 	      spline->pt[1].x, spline->pt[1].y,
 	      spline->pt[2].x, spline->pt[2].y,
 	      spline->pt[3].x, spline->pt[3].y);
@@ -378,18 +378,18 @@
 	setenv("XRDEBUG_DUMP_TRAPS","",1);
     else
 	unsetenv("XRDEBUG_DUMP_TRAPS");
-    XrStroke(xrs);
+    cairo_stroke(xrs);
     win->dump_traps = 0;
 
     if (win->show_path) {
-	XrSetLineWidth(xrs, 1 / zoom);
-	XrSetRGBColor(xrs, 1, 1, 1);
-	XrMoveTo(xrs, spline->pt[0].x, spline->pt[0].y);
-	XrCurveTo(xrs,
+	cairo_set_line_width(xrs, 1 / zoom);
+	cairo_set_rgb_color(xrs, 1, 1, 1);
+	cairo_move_to(xrs, spline->pt[0].x, spline->pt[0].y);
+	cairo_curve_to(xrs,
 		  spline->pt[1].x, spline->pt[1].y,
 		  spline->pt[2].x, spline->pt[2].y,
 		  spline->pt[3].x, spline->pt[3].y);
-	XrStroke(xrs);
+	cairo_stroke(xrs);
     }
 
     draw_control_line(xrs, &spline->pt[0], &spline->pt[1], 2.0 / zoom);
@@ -399,7 +399,7 @@
 	draw_handle(xrs, &spline->pt[i], i == win->active, 5.0 / zoom, 1.0 / zoom);
     }
 
-    XrRestore(xrs);
+    cairo_restore(xrs);
 }
 
 static void
@@ -407,37 +407,37 @@
 {
     Display *dpy = win->dpy;
 
-    XrState *xrs;
-    XrStatus status;
+    cairo_t *xrs;
+    cairo_status_t status;
     Drawable drawable = win->pix;
 
     XFillRectangle(dpy, win->pix, win->gc, 0, 0, win->width, win->height);
 
-    xrs = XrCreate();
+    xrs = cairo_create();
 
     /*
     if (win->restrict_traps)
-	XrRestrictSplineTraps(xrs, win->trap_start, win->trap_stop);
+	cairo_restrict_spline_traps(xrs, win->trap_start, win->trap_stop);
     */
 
-    XrSetTargetDrawable (xrs, dpy, drawable);
+    cairo_set_target_drawable (xrs, dpy, drawable);
 
-    XrSetRGBColor(xrs, 0, 0, 0);
+    cairo_set_rgb_color(xrs, 0, 0, 0);
 
-    XrSetLineWidth(xrs, win->line_width);
-    XrSetLineCap(xrs, win->line_cap);
-    XrTranslate(xrs, win->xtrans, win->ytrans);
-    XrScale(xrs, win->zoom, win->zoom);
-    XrSetTolerance(xrs, win->tolerance);
+    cairo_set_line_width(xrs, win->line_width);
+    cairo_set_line_cap(xrs, win->line_cap);
+    cairo_translate(xrs, win->xtrans, win->ytrans);
+    cairo_scale(xrs, win->zoom, win->zoom);
+    cairo_set_tolerance(xrs, win->tolerance);
 
     draw_spline(xrs, win);
 
-    status = XrGetStatus(xrs);
+    status = cairo_get_status(xrs);
     if (status) {
-	fprintf(stderr, "Xr is unhappy: %s\n", XrGetStatusString(xrs));
+	fprintf(stderr, "Xr is unhappy: %s\n", cairo_get_status_string(xrs));
     }
 
-    XrDestroy(xrs);
+    cairo_destroy(xrs);
 
     XCopyArea(win->dpy, win->pix, win->win, win->gc,
 	      0, 0, win->width, win->height,

Index: xrtest.c
===================================================================
RCS file: /local/src/CVS/xrtest/xrtest.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- xrtest.c	12 May 2003 16:49:06 -0000	1.8
+++ xrtest.c	18 Jul 2003 18:35:23 -0000	1.9
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <math.h>
 
-#include <Xr.h>
+#include <cairo.h>
 
 typedef struct win {
     Display *dpy;
@@ -13,9 +13,9 @@
     KeyCode quit_code;
 } win_t;
 
-static void triangle(XrState *xrs);
-static void square(XrState *xrs);
-static void bowtie(XrState *xrs);
+static void triangle(cairo_t *xrs);
+static void square(cairo_t *xrs);
+static void bowtie(cairo_t *xrs);
 static void win_init(win_t *win, Display *dpy);
 static void win_deinit(win_t *win);
 static void win_draw(win_t *win);
@@ -51,141 +51,141 @@
 
 #define SIZE 40
 static void
-triangle(XrState *xrs)
+triangle(cairo_t *xrs)
 {
-    XrMoveTo(xrs, SIZE, 0);
-    XrRelLineTo(xrs, SIZE,  2*SIZE);
-    XrRelLineTo(xrs, -2*SIZE, 0);
-    XrClosePath(xrs);
+    cairo_move_to(xrs, SIZE, 0);
+    cairo_rel_line_to(xrs, SIZE,  2*SIZE);
+    cairo_rel_line_to(xrs, -2*SIZE, 0);
+    cairo_close_path(xrs);
 }
 
 static void
-square(XrState *xrs)
+square(cairo_t *xrs)
 {
-    XrMoveTo(xrs, 0, 0);
-    XrRelLineTo(xrs,  2*SIZE,   0);
-    XrRelLineTo(xrs,   0,  2*SIZE);
-    XrRelLineTo(xrs, -2*SIZE,   0); 
-    XrClosePath(xrs);
+    cairo_move_to(xrs, 0, 0);
+    cairo_rel_line_to(xrs,  2*SIZE,   0);
+    cairo_rel_line_to(xrs,   0,  2*SIZE);
+    cairo_rel_line_to(xrs, -2*SIZE,   0); 
+    cairo_close_path(xrs);
 }
 
 static void
-bowtie(XrState *xrs)
+bowtie(cairo_t *xrs)
 {
-    XrMoveTo(xrs, 0, 0);
-    XrRelLineTo(xrs,  2*SIZE,  2*SIZE);
-    XrRelLineTo(xrs, -2*SIZE,   0); 
-    XrRelLineTo(xrs,  2*SIZE, -2*SIZE);
-    XrClosePath(xrs);
+    cairo_move_to(xrs, 0, 0);
+    cairo_rel_line_to(xrs,  2*SIZE,  2*SIZE);
+    cairo_rel_line_to(xrs, -2*SIZE,   0); 
+    cairo_rel_line_to(xrs,  2*SIZE, -2*SIZE);
+    cairo_close_path(xrs);
 }
 
 static void
-inf(XrState *xrs)
+inf(cairo_t *xrs)
 {
-    XrMoveTo(xrs, 0, SIZE);
-    XrRelCurveTo(xrs,
+    cairo_move_to(xrs, 0, SIZE);
+    cairo_rel_curve_to(xrs,
 		 0, SIZE,
 		 SIZE, SIZE,
 		 2*SIZE, 0);
-    XrRelCurveTo(xrs,
+    cairo_rel_curve_to(xrs,
 		 SIZE, -SIZE,
 		 2*SIZE, -SIZE,
 		 2*SIZE, 0);
-    XrRelCurveTo(xrs,
+    cairo_rel_curve_to(xrs,
 		 0, SIZE,
 		 -SIZE, SIZE,
 		 -2*SIZE, 0);
-    XrRelCurveTo(xrs,
+    cairo_rel_curve_to(xrs,
 		 -SIZE, -SIZE,
 		 -2*SIZE, -SIZE,
 		 -2*SIZE, 0);
-    XrClosePath(xrs);
+    cairo_close_path(xrs);
 }
 
 static void
-draw_shapes(XrState *xrs, int x, int y, int fill)
+draw_shapes(cairo_t *xrs, int x, int y, int fill)
 {
-    XrSave(xrs);
+    cairo_save(xrs);
 
-    XrNewPath(xrs);
-    XrTranslate(xrs, x+SIZE, y+SIZE);
+    cairo_new_path(xrs);
+    cairo_translate(xrs, x+SIZE, y+SIZE);
     bowtie(xrs);
     if (fill)
-	XrFill(xrs);
+	cairo_fill(xrs);
     else
-	XrStroke(xrs);
+	cairo_stroke(xrs);
 
-    XrNewPath(xrs);
-    XrTranslate(xrs, 4*SIZE, 0);
+    cairo_new_path(xrs);
+    cairo_translate(xrs, 4*SIZE, 0);
     square(xrs);
     if (fill)
-	XrFill(xrs);
+	cairo_fill(xrs);
     else
-	XrStroke(xrs);
+	cairo_stroke(xrs);
 
-    XrNewPath(xrs);
-    XrTranslate(xrs, 4*SIZE, 0);
+    cairo_new_path(xrs);
+    cairo_translate(xrs, 4*SIZE, 0);
     triangle(xrs);
     if (fill)
-	XrFill(xrs);
+	cairo_fill(xrs);
     else
-	XrStroke(xrs);
+	cairo_stroke(xrs);
 
-    XrNewPath(xrs);
-    XrTranslate(xrs, 4*SIZE, 0);
+    cairo_new_path(xrs);
+    cairo_translate(xrs, 4*SIZE, 0);
     inf(xrs);
     if (fill)
-	XrFill(xrs);
+	cairo_fill(xrs);
     else
-	XrStroke(xrs);
+	cairo_stroke(xrs);
 
-    XrRestore(xrs);
+    cairo_restore(xrs);
 }
 
 static void
-fill_shapes(XrState *xrs, int x, int y)
+fill_shapes(cairo_t *xrs, int x, int y)
 {
     draw_shapes(xrs, x, y, 1);
 }
 
 static void
-stroke_shapes(XrState *xrs, int x, int y)
+stroke_shapes(cairo_t *xrs, int x, int y)
 {
     draw_shapes(xrs, x, y, 0);
 }
 
 /*
 static void
-draw_broken_shapes(XrState *xrs)
+draw_broken_shapes(cairo_t *xrs)
 {
-    XrSave(xrs);
+    cairo_save(xrs);
 
-    XrSetLineWidth(xrs, 1);
-    XrSetLineJoin(xrs, XrLineJoinBevel);
-    XrSetRGBColor(xrs, 1, 1, 1);
+    cairo_set_line_width(xrs, 1);
+    cairo_set_line_join(xrs, CAIRO_LINE_JOIN_BEVEL);
+    cairo_set_rgb_color(xrs, 1, 1, 1);
 
-    XrMoveTo(xrs, 19.153717041015625, 144.93951416015625);
-    XrLineTo(xrs, 412.987396240234375, 99.407318115234375);
-    XrLineTo(xrs, 412.99383544921875, 99.4071807861328125);
-    XrLineTo(xrs, 413.15008544921875, 99.5634307861328125);
-    XrLineTo(xrs, 413.082489013671875, 99.6920928955078125);
-    XrLineTo(xrs, 413.000274658203125, 99.71954345703125);
-    XrLineTo(xrs, 273.852630615234375, 138.1925201416015625);
-    XrLineTo(xrs, 273.934844970703125, 138.165069580078125);
-    XrLineTo(xrs, 16.463653564453125, 274.753662109375);
-    XrLineTo(xrs, 16.286346435546875, 274.496337890625);
-    XrLineTo(xrs, 273.757537841796875, 137.907745361328125);
-    XrLineTo(xrs, 273.839752197265625, 137.8802947998046875);
-    XrLineTo(xrs, 412.987396240234375, 99.407318115234375);
-    XrLineTo(xrs, 412.99383544921875, 99.4071807861328125);
-    XrLineTo(xrs, 413.15008544921875, 99.5634307861328125);
-    XrLineTo(xrs, 413.082489013671875, 99.6920928955078125);
-    XrLineTo(xrs, 413.000274658203125, 99.71954345703125);
-    XrLineTo(xrs, 19.166595458984375, 145.251739501953125);
+    cairo_move_to(xrs, 19.153717041015625, 144.93951416015625);
+    cairo_line_to(xrs, 412.987396240234375, 99.407318115234375);
+    cairo_line_to(xrs, 412.99383544921875, 99.4071807861328125);
+    cairo_line_to(xrs, 413.15008544921875, 99.5634307861328125);
+    cairo_line_to(xrs, 413.082489013671875, 99.6920928955078125);
+    cairo_line_to(xrs, 413.000274658203125, 99.71954345703125);
+    cairo_line_to(xrs, 273.852630615234375, 138.1925201416015625);
+    cairo_line_to(xrs, 273.934844970703125, 138.165069580078125);
+    cairo_line_to(xrs, 16.463653564453125, 274.753662109375);
+    cairo_line_to(xrs, 16.286346435546875, 274.496337890625);
+    cairo_line_to(xrs, 273.757537841796875, 137.907745361328125);
+    cairo_line_to(xrs, 273.839752197265625, 137.8802947998046875);
+    cairo_line_to(xrs, 412.987396240234375, 99.407318115234375);
+    cairo_line_to(xrs, 412.99383544921875, 99.4071807861328125);
+    cairo_line_to(xrs, 413.15008544921875, 99.5634307861328125);
+    cairo_line_to(xrs, 413.082489013671875, 99.6920928955078125);
+    cairo_line_to(xrs, 413.000274658203125, 99.71954345703125);
+    cairo_line_to(xrs, 19.166595458984375, 145.251739501953125);
 
-    XrFill(xrs);
+    cairo_fill(xrs);
 
-    XrRestore(xrs);
+    cairo_restore(xrs);
 }
 */
 
@@ -195,60 +195,60 @@
 #define NUM_DASH 2
     static double dash[NUM_DASH] = {SIZE/4.0, SIZE/4.0};
     Display *dpy = win->dpy;
-    XrState *xrs;
+    cairo_t *xrs;
     Drawable drawable = win->win;
 
     XClearWindow(dpy, win->win);
 
-    xrs = XrCreate();
-    XrSetTargetDrawable (xrs, dpy, drawable);
-    XrSetRGBColor(xrs, 1, 1, 1);
+    xrs = cairo_create();
+    cairo_set_target_drawable (xrs, dpy, drawable);
+    cairo_set_rgb_color(xrs, 1, 1, 1);
 
 /*
-    XrScale(xrs, 5, 5);
+    cairo_scale(xrs, 5, 5);
     inf(xrs);
-    XrTranslate(xrs, 0, 2 * SIZE);
+    cairo_translate(xrs, 0, 2 * SIZE);
     inf(xrs);
-    XrTranslate(xrs, 0, - 2 * SIZE);
-    XrClip(xrs);
-    XrScale(xrs, 1/5.0, 1/5.0);
+    cairo_translate(xrs, 0, - 2 * SIZE);
+    cairo_clip(xrs);
+    cairo_scale(xrs, 1/5.0, 1/5.0);
 */
 
     /* This is handy for examining problems more closely */
-/*    XrScale(xrs, 8, 8); */
+/*    cairo_scale(xrs, 8, 8); */
 
 #if XXX_JOINS_ARE_BROKEN_AFTER_SOME_TRANSFORMS
-    XrScale(xrs, 2, -2);
-    XrTranslate(xrs, 0, -200);
+    cairo_scale(xrs, 2, -2);
+    cairo_translate(xrs, 0, -200);
 #endif
-    XrSetLineWidth(xrs, SIZE / 4);
+    cairo_set_line_width(xrs, SIZE / 4);
 
-    XrSetTolerance(xrs, .1);
+    cairo_set_tolerance(xrs, .1);
 
-    XrSetLineJoin(xrs, XrLineJoinRound);
-    XrSetDash(xrs, dash, NUM_DASH, 0);
+    cairo_set_line_join(xrs, CAIRO_LINE_JOIN_ROUND);
+    cairo_set_dash(xrs, dash, NUM_DASH, 0);
     stroke_shapes(xrs, 0, 0);
 
-    XrSetDash(xrs, NULL, 0, 0);
+    cairo_set_dash(xrs, NULL, 0, 0);
     stroke_shapes(xrs, 0, 4*SIZE);
 
-    XrSetLineJoin(xrs, XrLineJoinBevel);
+    cairo_set_line_join(xrs, CAIRO_LINE_JOIN_BEVEL);
     stroke_shapes(xrs, 0, 8*SIZE);
 
-    XrSetLineJoin(xrs, XrLineJoinMiter);
+    cairo_set_line_join(xrs, CAIRO_LINE_JOIN_MITER);
     stroke_shapes(xrs, 0, 12*SIZE);
 
     fill_shapes(xrs, 0, 16*SIZE);
 
-    XrSetLineJoin(xrs, XrLineJoinBevel);
+    cairo_set_line_join(xrs, CAIRO_LINE_JOIN_BEVEL);
     fill_shapes(xrs, 0, 20*SIZE);
-    XrSetRGBColor(xrs, 1, 0, 0);
+    cairo_set_rgb_color(xrs, 1, 0, 0);
     stroke_shapes(xrs, 0, 20*SIZE);
 /*
     draw_broken_shapes(xrs);
 */
 
-    XrDestroy(xrs);
+    cairo_destroy(xrs);
 }
 
 static void




More information about the Commit mailing list