aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-02-02 23:03:55 +0000
committerCarl Worth <cworth@cworth.org>2006-02-02 23:03:55 +0000
commit1175bd52f83545cfb2560f4ee25e866974dfc8c4 (patch)
treeffa0dfc64472c7a7cfd789ba24c1b767c1ce0ecb
parentd671e983063b71cddc0a2034e51c1fa05d112dc4 (diff)
downloadlibtwin-1175bd52f83545cfb2560f4ee25e866974dfc8c4.tar.gz
Add x11 as a required package, (cairo no longer pulls this in by default).
Track changes in cairo API to bring forward to be compatible with cairo 1.0.x. Remove some unused variables. Add missing includes of cairo-xlib.h, X11/Xutil.h, and string.h. Add missing return value and remove unused variables.
-rw-r--r--ChangeLog16
-rw-r--r--twin_fedit/Makefile4
-rw-r--r--twin_fedit/twin-fedit.c41
-rw-r--r--twin_fedit/twin-fedit.h3
-rw-r--r--twin_fedit/twin-sfit.c7
5 files changed, 42 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ba1917..af08d0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2006-02-02 Carl Worth <cworth@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.
+
2004-10-29 Keith Packard <keithp@keithp.com>
* Makefile.am:
diff --git a/twin_fedit/Makefile b/twin_fedit/Makefile
index eb21671..7004bb6 100644
--- a/twin_fedit/Makefile
+++ b/twin_fedit/Makefile
@@ -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
diff --git a/twin_fedit/twin-fedit.c b/twin_fedit/twin-fedit.c
index b2de59e..d5325ff 100644
--- a/twin_fedit/twin-fedit.c
+++ b/twin_fedit/twin-fedit.c
@@ -32,6 +32,7 @@ int width = 512;
int height = 512;
double scale = 8;
cairo_t *cr;
+cairo_surface_t *surface;
int offset;
int offsets[1024];
@@ -64,7 +65,7 @@ init (int argc, char **argv)
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 @@ init (int argc, char **argv)
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 @@ read_char (void)
{
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 @@ read_char (void)
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 @@ dot (cairo_t *cr, double x, double y, double red, double blue, double green, dou
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 @@ draw_char (char_t *c)
{
double alpha;
double tx, ty;
- char buf[10];
if (cmd == c->first || cmd == c->last)
alpha = 1;
@@ -330,8 +330,7 @@ draw_char (char_t *c)
}
}
}
- 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 @@ draw_char (char_t *c)
{
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 @@ pos_to_cmd (char_t *c, cmd_t *start, int ix, int iy)
{
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 @@ void
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 @@ main (int argc, char **argv)
if (!init (argc, argv))
exit (1);
- while (c = read_char ())
+ while ((c = read_char ()))
{
play (c);
write_char (c);
diff --git a/twin_fedit/twin-fedit.h b/twin_fedit/twin-fedit.h
index ccc879d..cfb9b43 100644
--- a/twin_fedit/twin-fedit.h
+++ b/twin_fedit/twin-fedit.h
@@ -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;
diff --git a/twin_fedit/twin-sfit.c b/twin_fedit/twin-sfit.c
index d948e2a..31d8691 100644
--- a/twin_fedit/twin-sfit.c
+++ b/twin_fedit/twin-sfit.c
@@ -50,6 +50,8 @@ new_pts (void)
pts->n = 0;
pts->s = 0;
pts->pt = 0;
+
+ return pts;
}
void
@@ -66,7 +68,6 @@ add_pt (pts_t *pts, pt_t *pt)
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 @@ spline_t fit (pt_t *p, int n)
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;