[Commit] twin/twin_fedit Makefile, 1.1, 1.2 twin-fedit.c, 1.1, 1.2 twin-fedit.h, 1.1, 1.2 twin-sfit.c, 1.1, 1.2

Carl Worth commit at keithp.com
Thu Feb 2 15:03:58 PST 2006


Committed by: cworth

Update of /local/src/CVS/twin/twin_fedit
In directory home.keithp.com:/tmp/cvs-serv14555/twin_fedit

Modified Files:
	Makefile twin-fedit.c twin-fedit.h twin-sfit.c 
Log Message:

2006-02-02  Carl Worth  <cworth at cworth.org>

        * twin_fedit/Makefile: Add x11 as a required package, (cairo no
        longer pulls this in by default).

        * twin_fedit/twin-fedit.c: (init), (read_char), (dot), (spot),
        (draw_char), (pos_to_cmd), (replace_with_spline), (main): Track
        changes in cairo API to bring forward to be compatible with cairo
        1.0.x. Remove some unused variables.

        * twin_fedit/twin-fedit.h: Add missing includes of cairo-xlib.h,
        X11/Xutil.h, and string.h.

        * twin_fedit/twin-sfit.c: (new_pts), (add_pt), (fit): Add missing
        return value and remove unused variables.


Index: Makefile
===================================================================
RCS file: /local/src/CVS/twin/twin_fedit/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile	25 Oct 2004 19:09:36 -0000	1.1
+++ Makefile	2 Feb 2006 23:03:55 -0000	1.2
@@ -1,5 +1,5 @@
-CFLAGS=$(shell pkg-config --cflags cairo) -g
-LIBS=$(shell pkg-config --libs cairo)
+CFLAGS=$(shell pkg-config --cflags cairo x11) -g -Wall
+LIBS=$(shell pkg-config --libs cairo x11)
 
 OBJS=twin-fedit.o twin-sfit.o
 

Index: twin-fedit.c
===================================================================
RCS file: /local/src/CVS/twin/twin_fedit/twin-fedit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- twin-fedit.c	25 Oct 2004 19:09:36 -0000	1.1
+++ twin-fedit.c	2 Feb 2006 23:03:55 -0000	1.2
@@ -32,6 +32,7 @@
 int	height = 512;
 double	scale = 8;
 cairo_t	*cr;
+cairo_surface_t *surface;
 int	offset;
 
 int	offsets[1024];
@@ -64,7 +65,7 @@
     wm_name.value = (unsigned char *) argv[0];
     wm_name.encoding = XA_STRING;
     wm_name.format = 8;
-    wm_name.nitems = strlen (wm_name.value) + 1;
+    wm_name.nitems = strlen ((char *) wm_name.value) + 1;
     icon_name = wm_name;
 
     win = XCreateWindow (dpy, RootWindow (dpy, scr),
@@ -84,14 +85,18 @@
 
     XMapWindow (dpy, win);
 
-    cr = cairo_create ();
-    
-    cairo_set_target_drawable (cr, dpy, win);
+    surface = cairo_xlib_surface_create (dpy,
+					 win,
+					 visual,
+					 width,
+					 height);
+
+    cr = cairo_create (surface);
 
     cairo_translate (cr, 150, 420);
     cairo_scale (cr, scale, scale);
 
-    cairo_scale_font (cr, 2);
+    cairo_set_font_size (cr, 2);
     return 1;
 }
 
@@ -195,9 +200,7 @@
 {
     char_t  *c = malloc (sizeof (char_t));
     char    line[1024];
-    char    op;
     cmd_t   *cmd;
-    char    *comma;
 
     c->cmd = 0;
     c->stack = 0;
@@ -252,8 +255,7 @@
 void
 dot (cairo_t *cr, double x, double y, double red, double blue, double green, double alpha)
 {
-    cairo_set_rgb_color (cr, red, blue, green);
-    cairo_set_alpha (cr, alpha);
+    cairo_set_source_rgba (cr, red, blue, green, alpha);
     cairo_set_line_width (cr, 0.7);
     cairo_arc (cr, x, y, DOT_SIZE, 0, M_PI * 2);
     cairo_stroke (cr);
@@ -262,8 +264,7 @@
 void
 spot (cairo_t *cr, double x, double y, double red, double blue, double green, double alpha)
 {
-    cairo_set_rgb_color (cr, red, blue, green);
-    cairo_set_alpha (cr, alpha);
+    cairo_set_source_rgba (cr, red, blue, green, alpha);
     cairo_arc (cr, x, y, DOT_SIZE, 0, M_PI * 2);
     cairo_fill (cr);
 }
@@ -281,7 +282,6 @@
     {
 	double	alpha;
 	double	tx, ty;
-	char	buf[10];
 
 	if (cmd == c->first || cmd == c->last)
 	    alpha = 1;
@@ -330,8 +330,7 @@
 	    }
 	}
     }
-    cairo_set_rgb_color (cr, 0, 0, 0);
-    cairo_set_alpha (cr, 1);
+    cairo_set_source_rgb (cr, 0, 0, 0);
     cairo_set_line_width (cr, 0.5);
 
     for (cmd = c->cmd; cmd; cmd = cmd->next)
@@ -373,13 +372,12 @@
 	{
 	    cairo_save (cr);
 	    if (cmd == c->first)
-		cairo_set_rgb_color (cr, 0, .5, 0);
+		cairo_set_source_rgb (cr, 0, .5, 0);
 	    else if (cmd == c->last)
-		cairo_set_rgb_color (cr, 0, 0, .5);
+		cairo_set_source_rgb (cr, 0, 0, .5);
 	    else
-		cairo_set_rgb_color (cr, 0, .5, .5);
+		cairo_set_source_rgb (cr, 0, .5, .5);
 		
-	    cairo_set_alpha (cr, 1);
 	    cairo_move_to (cr, tx - 2, ty + 3);
 	    sprintf (buf, "%d", i);
 	    cairo_show_text (cr, buf);
@@ -393,9 +391,9 @@
 {
     double  x = ix, y = iy;
     double  best_err = 1;
-    cmd_t   *cmd, *best_cmd = 0, *next;
+    cmd_t   *cmd, *best_cmd = 0;
 
-    cairo_inverse_transform_point (cr, &x, &y);
+    cairo_device_to_user (cr, &x, &y);
     if (start)
 	start = start->next;
     if (!start)
@@ -447,7 +445,6 @@
 replace_with_spline (char_t *c, cmd_t *first, cmd_t *last)
 {
     pts_t	*pts = new_pts ();
-    int		n;
     spline_t	s;
     cmd_t	*cmd, *next, *save;
     
@@ -683,7 +680,7 @@
     
     if (!init (argc, argv))
 	exit (1);
-    while (c = read_char ())
+    while ((c = read_char ()))
     {
 	play (c);
 	write_char (c);

Index: twin-fedit.h
===================================================================
RCS file: /local/src/CVS/twin/twin_fedit/twin-fedit.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- twin-fedit.h	25 Oct 2004 19:09:36 -0000	1.1
+++ twin-fedit.h	2 Feb 2006 23:03:55 -0000	1.2
@@ -31,8 +31,11 @@
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 #include <cairo.h>
+#include <cairo-xlib.h>
 #include <math.h>
 #include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include <string.h>
 
 typedef enum _op { OpMove, OpLine, OpCurve, OpNoop } op_t;
 

Index: twin-sfit.c
===================================================================
RCS file: /local/src/CVS/twin/twin_fedit/twin-sfit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- twin-sfit.c	25 Oct 2004 19:09:36 -0000	1.1
+++ twin-sfit.c	2 Feb 2006 23:03:55 -0000	1.2
@@ -50,6 +50,8 @@
     pts->n = 0;
     pts->s = 0;
     pts->pt = 0;
+
+    return pts;
 }
 
 void
@@ -66,7 +68,6 @@
     if (pts->n == pts->s)
     {
 	int	ns = pts->s ? pts->s * 2 : 16;
-	pt_t	*npt;
 
 	if (pts->pt)
 	    pts->pt = realloc (pts->pt, ns * sizeof (pt_t));
@@ -279,10 +280,6 @@
 
     double	dist;
     
-    double	start_first;
-    double	stop_first;
-    double	start_last;
-    double	stop_last;
     double	tol = 0.5;
     double	best_err = 10000;
     double	sbx_min;



More information about the Commit mailing list