[Commit] papers/xr_ols2003/examples canada.c, NONE, 1.1 Makefile,
1.5, 1.6 caps_joins.c, 1.1, 1.2 hering.c, 1.2, 1.3 outline.c,
1.3, 1.4 spiral.c, 1.3, 1.4 splines_tolerance.c, 1.1,
1.2 stars.c, 1.2, 1.3
Carl Worth
commit at keithp.com
Wed Jul 30 15:30:03 PDT 2003
- Previous message: [Commit] libic/src .cvsignore,1.2,1.3
- Next message: [Commit] grrobot/src/svg cell1.svg, NONE, 1.1 cell2.svg, NONE,
1.1 grr_icon_svg.h, 1.5, 1.6 target_blue_square.svg, 1.4,
1.5 target_green_square.svg, 1.4, 1.5 target_red_square.svg,
1.3, 1.4 target_yellow_square.svg, 1.4, 1.5 cell.svg, 1.3, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /local/src/CVS/papers/xr_ols2003/examples
In directory home.keithp.com:/tmp/cvs-serv24984
Modified Files:
Makefile caps_joins.c hering.c outline.c spiral.c
splines_tolerance.c stars.c
Added Files:
canada.c
Log Message:
Converted everything from XrNames to cairo_names.
Added a maple leaf gradient example (canda.c)
--- NEW FILE: canada.c ---
#include <cairo.h>
#include "write_png.h"
void
draw_leaf (cairo_t *xrs, int surface_width, int surface_height);
void
draw_half_leaf (cairo_t *xrs);
cairo_surface_t *
create_gradient (cairo_t *xrs, double width, double height);
#define WIDTH 240
#define HEIGHT 240
#define STRIDE (WIDTH * 4)
char image[STRIDE*HEIGHT];
int
main (void)
{
cairo_t *xrs;
xrs = cairo_create ();
cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
draw_leaf (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "canada.png", WIDTH, HEIGHT, STRIDE);
cairo_destroy (xrs);
return 0;
}
cairo_surface_t *
create_gradient (cairo_t *xrs, double width, double height)
{
cairo_surface_t *gradient;
cairo_matrix_t *matrix;
cairo_save (xrs);
gradient = cairo_surface_create_similar (cairo_get_target_surface (xrs),
CAIRO_FORMAT_ARGB32,
3, 2);
cairo_set_target_surface (xrs, gradient);
cairo_set_rgb_color (xrs, 1, 0, 0);
cairo_rectangle (xrs, 0, 0, 1, 2);
cairo_fill (xrs);
cairo_set_rgb_color (xrs, 1, 1, 1);
cairo_rectangle (xrs, 1, 0, 1, 2);
cairo_fill (xrs);
cairo_set_rgb_color (xrs, 1, 0, 0);
cairo_rectangle (xrs, 2, 0, 1, 2);
cairo_fill (xrs);
cairo_restore (xrs);
matrix = cairo_matrix_create ();
cairo_matrix_scale (matrix, 0.5/width, 1.0/height);
cairo_surface_set_matrix (gradient, matrix);
cairo_surface_set_filter (gradient, CAIRO_FILTER_BILINEAR);
cairo_matrix_destroy (matrix);
return gradient;
}
void
draw_leaf (cairo_t *xrs, int surface_width, int surface_height)
{
cairo_surface_t *gradient;
double width, height, pad;
width = surface_width / 4.0;
pad = (surface_width - (3 * width)) / 2.0;
height = surface_height;
gradient = create_gradient (xrs, width, height);
cairo_set_pattern (xrs, gradient);
cairo_scale (xrs, 2, 2);
cairo_translate (xrs, -94, -12);
draw_half_leaf (xrs);
cairo_translate (xrs, 308, 0);
cairo_scale (xrs, -1, 1);
draw_half_leaf (xrs);
cairo_surface_destroy (gradient);
}
void
draw_half_leaf (cairo_t *xrs)
{
cairo_move_to (xrs, 154, 139);
cairo_line_to (xrs, 156, 139);
cairo_line_to (xrs, 156, 107);
cairo_line_to (xrs, 185, 112);
cairo_line_to (xrs, 181, 104);
cairo_line_to (xrs, 214, 76);
cairo_line_to (xrs, 204, 72);
cairo_line_to (xrs, 210, 52);
cairo_line_to (xrs, 195, 56);
cairo_line_to (xrs, 188, 46);
cairo_line_to (xrs, 171, 63);
cairo_line_to (xrs, 177, 26);
cairo_line_to (xrs, 165, 33);
cairo_line_to (xrs, 154, 12);
cairo_fill (xrs);
}
Index: Makefile
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile 16 May 2003 04:56:02 -0000 1.5
+++ Makefile 30 Jul 2003 21:30:00 -0000 1.6
@@ -1,8 +1,8 @@
-EXAMPLES = outline.eps spiral.eps hering.eps caps_joins.eps stars.eps splines_tolerance.eps
-.PRECIOUS: outline.png spiral.png hering.png caps_joins.png stars.png splines_tolerance.png
+EXAMPLES = outline.eps spiral.eps hering.eps caps_joins.eps stars.eps splines_tolerance.eps canada.eps
+.PRECIOUS: outline.png spiral.png hering.png caps_joins.png stars.png splines_tolerance.png canada.png
-CFLAGS=-g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls `pkg-config --cflags Xr`
-LDFLAGS=`pkg-config --libs Xr` -lpng
+CFLAGS=-g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls `pkg-config --cflags cairo`
+LDFLAGS=`pkg-config --libs cairo` -lpng
all: ${EXAMPLES}
Index: caps_joins.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/caps_joins.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- caps_joins.c 15 May 2003 17:34:17 -0000 1.1
+++ caps_joins.c 30 Jul 2003 21:30:00 -0000 1.2
@@ -1,15 +1,15 @@
-#include <Xr.h>
+#include <cairo.h>
#include "write_png.h"
void
-draw_caps_joins (XrState *xrs, int width, int height);
+draw_caps_joins (cairo_t *xrs, int width, int height);
void
-stroke_v_twice (XrState *xrs, int dx, int dy);
+stroke_v_twice (cairo_t *xrs, int dx, int dy);
void
-draw_three_vs (XrState *xrs, int width, int height, int line_width);
+draw_three_vs (cairo_t *xrs, int width, int height, int line_width);
#define WIDTH 600
#define HEIGHT 600
@@ -20,73 +20,72 @@
int
main (void)
{
- XrState *xrs;
+ cairo_t *xrs;
- xrs = XrCreate ();
+ xrs = cairo_create ();
- XrSetTargetImage (xrs, image, XrFormatARGB32,
+ cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
- XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrFill (xrs);
+ cairo_rectangle (xrs, 0, 0, WIDTH, HEIGHT);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_fill (xrs);
draw_caps_joins (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "caps_joins.png", WIDTH, HEIGHT, STRIDE);
- XrDestroy (xrs);
+ cairo_destroy (xrs);
return 0;
}
void
-stroke_v_twice (XrState *xrs, int width, int height)
+stroke_v_twice (cairo_t *xrs, int width, int height)
{
- XrMoveTo (xrs, 0, 0);
- XrRelLineTo (xrs, width / 2, height / 2);
- XrRelLineTo (xrs, width / 2, - height / 2);
+ cairo_move_to (xrs, 0, 0);
+ cairo_rel_line_to (xrs, width / 2, height / 2);
+ cairo_rel_line_to (xrs, width / 2, - height / 2);
- XrSave (xrs);
- XrStroke (xrs);
- XrRestore (xrs);
+ cairo_save (xrs);
+ cairo_stroke (xrs);
+ cairo_restore (xrs);
- XrSave (xrs);
+ cairo_save (xrs);
{
- XrSetLineWidth (xrs, 2.0);
- XrSetLineCap (xrs, XrLineCapButt);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrStroke (xrs);
+ cairo_set_line_width (xrs, 2.0);
+ cairo_set_line_cap (xrs, CAIRO_LINE_CAP_BUTT);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_stroke (xrs);
}
- XrRestore (xrs);
+ cairo_restore (xrs);
- XrNewPath (xrs);
+ cairo_new_path (xrs);
}
void
-draw_caps_joins (XrState *xrs, int width, int height)
+draw_caps_joins (cairo_t *xrs, int width, int height)
{
- static double dashes[2] = {10, 20};
int line_width = height / 12 & (~1);
- XrSetLineWidth (xrs, line_width);
- XrSetRGBColor (xrs, 0, 0, 0);
+ cairo_set_line_width (xrs, line_width);
+ cairo_set_rgb_color (xrs, 0, 0, 0);
- XrTranslate (xrs, line_width, line_width);
+ cairo_translate (xrs, line_width, line_width);
width -= 2 *line_width;
- XrSetLineJoin (xrs, XrLineJoinBevel);
- XrSetLineCap (xrs, XrLineCapButt);
+ cairo_set_line_join (xrs, CAIRO_LINE_JOIN_BEVEL);
+ cairo_set_line_cap (xrs, CAIRO_LINE_CAP_BUTT);
stroke_v_twice (xrs, width, height);
- XrTranslate (xrs, 0, height / 4 - line_width);
- XrSetLineJoin (xrs, XrLineJoinMiter);
- XrSetLineCap (xrs, XrLineCapSquare);
+ cairo_translate (xrs, 0, height / 4 - line_width);
+ cairo_set_line_join (xrs, CAIRO_LINE_JOIN_MITER);
+ cairo_set_line_cap (xrs, CAIRO_LINE_CAP_SQUARE);
stroke_v_twice (xrs, width, height);
- XrTranslate (xrs, 0, height / 4 - line_width);
- XrSetLineJoin (xrs, XrLineJoinRound);
- XrSetLineCap (xrs, XrLineCapRound);
+ cairo_translate (xrs, 0, height / 4 - line_width);
+ cairo_set_line_join (xrs, CAIRO_LINE_JOIN_ROUND);
+ cairo_set_line_cap (xrs, CAIRO_LINE_CAP_ROUND);
stroke_v_twice (xrs, width, height);
}
Index: hering.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/hering.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hering.c 15 May 2003 17:34:17 -0000 1.2
+++ hering.c 30 Jul 2003 21:30:00 -0000 1.3
@@ -1,10 +1,10 @@
-#include <Xr.h>
+#include <cairo.h>
#include <math.h>
#include "write_png.h"
void
-draw_hering (XrState *xrs, int width, int height);
+draw_hering (cairo_t *xrs, int width, int height);
#define WIDTH 300
#define HEIGHT 600
@@ -15,28 +15,28 @@
int
main (void)
{
- XrState *xrs;
+ cairo_t *xrs;
- xrs = XrCreate ();
+ xrs = cairo_create ();
- XrSetTargetImage (xrs, image, XrFormatARGB32,
+ cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
- XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrFill (xrs);
+ cairo_rectangle (xrs, 0, 0, WIDTH, HEIGHT);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_fill (xrs);
draw_hering (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "hering.png", WIDTH, HEIGHT, STRIDE);
- XrDestroy (xrs);
+ cairo_destroy (xrs);
return 0;
}
void
-draw_hering (XrState *xrs, int width, int height)
+draw_hering (cairo_t *xrs, int width, int height)
{
#define LINES 32
#define MAX_THETA (.80 * M_PI_2)
@@ -44,32 +44,32 @@
int i;
- XrSetRGBColor (xrs, 0, 0, 0);
- XrSetLineWidth (xrs, 2.0);
+ cairo_set_rgb_color (xrs, 0, 0, 0);
+ cairo_set_line_width (xrs, 2.0);
- XrSave (xrs);
+ cairo_save (xrs);
{
- XrTranslate (xrs, width / 2, height / 2);
- XrRotate (xrs, MAX_THETA);
+ cairo_translate (xrs, width / 2, height / 2);
+ cairo_rotate (xrs, MAX_THETA);
for (i=0; i < LINES; i++) {
- XrMoveTo (xrs, -2 * width, 0);
- XrLineTo (xrs, 2 * width, 0);
- XrStroke (xrs);
+ cairo_move_to (xrs, -2 * width, 0);
+ cairo_line_to (xrs, 2 * width, 0);
+ cairo_stroke (xrs);
- XrRotate (xrs, - THETA_INC);
+ cairo_rotate (xrs, - THETA_INC);
}
}
- XrRestore (xrs);
+ cairo_restore (xrs);
- XrSetLineWidth (xrs, 6);
- XrSetRGBColor (xrs, 1, 0, 0);
+ cairo_set_line_width (xrs, 6);
+ cairo_set_rgb_color (xrs, 1, 0, 0);
- XrMoveTo (xrs, width / 4, 0);
- XrRelLineTo (xrs, 0, height);
- XrStroke (xrs);
+ cairo_move_to (xrs, width / 4, 0);
+ cairo_rel_line_to (xrs, 0, height);
+ cairo_stroke (xrs);
- XrMoveTo (xrs, 3 * width / 4, 0);
- XrRelLineTo (xrs, 0, height);
- XrStroke (xrs);
+ cairo_move_to (xrs, 3 * width / 4, 0);
+ cairo_rel_line_to (xrs, 0, height);
+ cairo_stroke (xrs);
}
Index: outline.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/outline.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- outline.c 15 May 2003 17:34:17 -0000 1.3
+++ outline.c 30 Jul 2003 21:30:00 -0000 1.4
@@ -1,21 +1,21 @@
-#include <Xr.h>
+#include <cairo.h>
#include "write_png.h"
void
-draw_outlines (XrState *xrs, int surface_width, int surface_height);
+draw_outlines (cairo_t *xrs, int surface_width, int surface_height);
void
-draw_flat (XrState *xrs, double width, double height);
+draw_flat (cairo_t *xrs, double width, double height);
void
-draw_tent (XrState *xrs, double width, double height);
+draw_tent (cairo_t *xrs, double width, double height);
void
-draw_cylinder (XrState *xrs, double width, double height);
+draw_cylinder (cairo_t *xrs, double width, double height);
-XrSurface *
-create_gradient (XrState *xrs, double width, double height);
+cairo_surface_t *
+create_gradient (cairo_t *xrs, double width, double height);
#define WIDTH 750
#define HEIGHT 500
@@ -26,68 +26,68 @@
int
main (void)
{
- XrState *xrs;
+ cairo_t *xrs;
- xrs = XrCreate ();
+ xrs = cairo_create ();
- XrSetTargetImage (xrs, image, XrFormatARGB32,
+ cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
- XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrFill (xrs);
+ cairo_rectangle (xrs, 0, 0, WIDTH, HEIGHT);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_fill (xrs);
draw_outlines (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "outline.png", WIDTH, HEIGHT, STRIDE);
- XrDestroy (xrs);
+ cairo_destroy (xrs);
return 0;
}
-XrSurface *
-create_gradient (XrState *xrs, double width, double height)
+cairo_surface_t *
+create_gradient (cairo_t *xrs, double width, double height)
{
- XrSurface *gradient;
- XrMatrix *matrix;
+ cairo_surface_t *gradient;
+ cairo_matrix_t *matrix;
- XrSave (xrs);
+ cairo_save (xrs);
- gradient = XrSurfaceCreateNextTo (XrGetTargetSurface (xrs),
- XrFormatARGB32,
+ gradient = cairo_surface_create_similar (cairo_get_target_surface (xrs),
+ CAIRO_FORMAT_ARGB32,
3, 2);
- XrSetTargetSurface (xrs, gradient);
+ cairo_set_target_surface (xrs, gradient);
- XrSetRGBColor (xrs, 0, 0, 0);
- XrRectangle (xrs, 0, 0, 1, 2);
- XrFill (xrs);
+ cairo_set_rgb_color (xrs, 0, 0, 0);
+ cairo_rectangle (xrs, 0, 0, 1, 2);
+ cairo_fill (xrs);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrRectangle (xrs, 1, 0, 1, 2);
- XrFill (xrs);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_rectangle (xrs, 1, 0, 1, 2);
+ cairo_fill (xrs);
- XrSetRGBColor (xrs, 0, 0, 0);
- XrRectangle (xrs, 2, 0, 1, 2);
- XrFill (xrs);
+ cairo_set_rgb_color (xrs, 0, 0, 0);
+ cairo_rectangle (xrs, 2, 0, 1, 2);
+ cairo_fill (xrs);
- XrRestore (xrs);
+ cairo_restore (xrs);
- matrix = XrMatrixCreate ();
- XrMatrixScale (matrix,
+ matrix = cairo_matrix_create ();
+ cairo_matrix_scale (matrix,
2.0 / width,
1.0 / height);
- XrSurfaceSetMatrix (gradient, matrix);
- XrSurfaceSetFilter (gradient, XrFilterBilinear);
- XrMatrixDestroy (matrix);
+ cairo_surface_set_matrix (gradient, matrix);
+ cairo_surface_set_filter (gradient, CAIRO_FILTER_BILINEAR);
+ cairo_matrix_destroy (matrix);
return gradient;
}
void
-draw_outlines (XrState *xrs, int surface_width, int surface_height)
+draw_outlines (cairo_t *xrs, int surface_width, int surface_height)
{
- XrSurface *gradient;
+ cairo_surface_t *gradient;
double width, height, pad;
width = surface_width / 4.0;
@@ -96,64 +96,64 @@
gradient = create_gradient (xrs, width, height);
- XrSetPattern (xrs, gradient);
+ cairo_set_pattern (xrs, gradient);
draw_flat (xrs, width, height);
- XrTranslate (xrs, width + pad, 0);
- XrSetPattern (xrs, gradient);
+ cairo_translate (xrs, width + pad, 0);
+ cairo_set_pattern (xrs, gradient);
draw_tent (xrs, width, height);
- XrTranslate (xrs, width + pad, 0);
- XrSetPattern (xrs, gradient);
+ cairo_translate (xrs, width + pad, 0);
+ cairo_set_pattern (xrs, gradient);
draw_cylinder (xrs, width, height);
- XrRestore (xrs);
+ cairo_restore (xrs);
- XrSurfaceDestroy (gradient);
+ cairo_surface_destroy (gradient);
}
void
-draw_flat (XrState *xrs, double width, double height)
+draw_flat (cairo_t *xrs, double width, double height)
{
double hwidth = width / 2.0;
- XrRectangle (xrs, 0, hwidth, width, height - hwidth);
+ cairo_rectangle (xrs, 0, hwidth, width, height - hwidth);
- XrFill (xrs);
+ cairo_fill (xrs);
}
void
-draw_tent (XrState *xrs, double width, double height)
+draw_tent (cairo_t *xrs, double width, double height)
{
double hwidth = width / 2.0;
- XrMoveTo (xrs, 0, hwidth);
- XrRelLineTo (xrs, hwidth, -hwidth);
- XrRelLineTo (xrs, hwidth, hwidth);
- XrRelLineTo (xrs, 0, height - hwidth);
- XrRelLineTo (xrs, -hwidth, -hwidth);
- XrRelLineTo (xrs, -hwidth, hwidth);
- XrClosePath (xrs);
+ cairo_move_to (xrs, 0, hwidth);
+ cairo_rel_line_to (xrs, hwidth, -hwidth);
+ cairo_rel_line_to (xrs, hwidth, hwidth);
+ cairo_rel_line_to (xrs, 0, height - hwidth);
+ cairo_rel_line_to (xrs, -hwidth, -hwidth);
+ cairo_rel_line_to (xrs, -hwidth, hwidth);
+ cairo_close_path (xrs);
- XrFill (xrs);
+ cairo_fill (xrs);
}
void
-draw_cylinder (XrState *xrs, double width, double height)
+draw_cylinder (cairo_t *xrs, double width, double height)
{
double hwidth = width / 2.0;
- XrMoveTo (xrs, 0, hwidth);
- XrRelCurveTo (xrs,
+ cairo_move_to (xrs, 0, hwidth);
+ cairo_rel_curve_to (xrs,
0, -hwidth,
width, -hwidth,
width, 0);
- XrRelLineTo (xrs, 0, height - hwidth);
- XrRelCurveTo (xrs,
+ cairo_rel_line_to (xrs, 0, height - hwidth);
+ cairo_rel_curve_to (xrs,
0, -hwidth,
-width, -hwidth,
-width, 0);
- XrClosePath (xrs);
+ cairo_close_path (xrs);
- XrFill (xrs);
+ cairo_fill (xrs);
}
Index: spiral.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/spiral.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- spiral.c 15 May 2003 17:34:17 -0000 1.3
+++ spiral.c 30 Jul 2003 21:30:00 -0000 1.4
@@ -1,12 +1,12 @@
-#include <Xr.h>
-
+#include <cairo.h>
+#include <math.h>
#include "write_png.h"
void
-draw_spiral (XrState *xrs, int width, int height);
+draw_spiral (cairo_t *xrs, int width, int height);
-#define WIDTH 600
-#define HEIGHT 600
+#define WIDTH 512
+#define HEIGHT 212
#define STRIDE (WIDTH * 4)
char image[STRIDE*HEIGHT];
@@ -14,28 +14,38 @@
int
main (void)
{
- XrState *xrs;
+ cairo_t *xrs;
- xrs = XrCreate ();
+ xrs = cairo_create ();
- XrSetTargetImage (xrs, image, XrFormatARGB32,
+ cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
- XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrFill (xrs);
+ draw_spiral (xrs, 150, 150);
- draw_spiral (xrs, WIDTH, HEIGHT);
+ cairo_translate (xrs, 200, 0);
+
+ cairo_save (xrs);
+ cairo_scale (xrs, 0.5, 1);
+ draw_spiral (xrs, 150, 150);
+ cairo_restore (xrs);
+
+ cairo_translate (xrs, 200, 0);
+ cairo_save (xrs);
+ cairo_rotate (xrs, M_PI / 4);
+ draw_spiral (xrs, 150, 150);
+ cairo_restore (xrs);
+
write_png_argb32 (image, "spiral.png", WIDTH, HEIGHT, STRIDE);
- XrDestroy (xrs);
+ cairo_destroy (xrs);
return 0;
}
void
-draw_spiral (XrState *xrs, int width, int height)
+draw_spiral (cairo_t *xrs, int width, int height)
{
int wd = .02 * width;
int hd = .02 * height;
@@ -44,14 +54,14 @@
width -= 2;
height -= 2;
- XrMoveTo (xrs, width + 1, 1-hd);
+ cairo_move_to (xrs, width + 1, 1-hd);
for (i=0; i < 9; i++) {
- XrRelLineTo (xrs, 0, height - hd * (2 * i - 1));
- XrRelLineTo (xrs, - (width - wd * (2 *i)), 0);
- XrRelLineTo (xrs, 0, - (height - hd * (2*i)));
- XrRelLineTo (xrs, width - wd * (2 * i + 1), 0);
+ cairo_rel_line_to (xrs, 0, height - hd * (2 * i - 1));
+ cairo_rel_line_to (xrs, - (width - wd * (2 *i)), 0);
+ cairo_rel_line_to (xrs, 0, - (height - hd * (2*i)));
+ cairo_rel_line_to (xrs, width - wd * (2 * i + 1), 0);
}
- XrSetRGBColor (xrs, 0, 0, 1);
- XrStroke (xrs);
+ cairo_set_rgb_color (xrs, 0xcb/255.0, 0x16/255.0, 0x16/255.0);
+ cairo_stroke (xrs);
}
Index: splines_tolerance.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/splines_tolerance.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- splines_tolerance.c 16 May 2003 06:47:09 -0000 1.1
+++ splines_tolerance.c 30 Jul 2003 21:30:00 -0000 1.2
@@ -1,12 +1,12 @@
-#include <Xr.h>
+#include <cairo.h>
#include "write_png.h"
void
-draw_spline (XrState *xrs, double height);
+draw_spline (cairo_t *xrs, double height);
void
-draw_splines (XrState *xrs, int width, int height);
+draw_splines (cairo_t *xrs, int width, int height);
#define WIDTH 600
#define HEIGHT 300
@@ -17,53 +17,53 @@
int
main (void)
{
- XrState *xrs;
+ cairo_t *xrs;
- xrs = XrCreate ();
+ xrs = cairo_create ();
- XrSetTargetImage (xrs, image, XrFormatARGB32,
+ cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
- XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrFill (xrs);
+ cairo_rectangle (xrs, 0, 0, WIDTH, HEIGHT);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_fill (xrs);
draw_splines (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "splines_tolerance.png", WIDTH, HEIGHT, STRIDE);
- XrDestroy (xrs);
+ cairo_destroy (xrs);
return 0;
}
void
-draw_spline (XrState *xrs, double height)
+draw_spline (cairo_t *xrs, double height)
{
- XrMoveTo (xrs, 0, .1 * height);
+ cairo_move_to (xrs, 0, .1 * height);
height = .8 * height;
- XrRelCurveTo (xrs,
+ cairo_rel_curve_to (xrs,
-height/2, height/2,
height/2, height/2,
0, height);
- XrStroke (xrs);
+ cairo_stroke (xrs);
}
void
-draw_splines (XrState *xrs, int width, int height)
+draw_splines (cairo_t *xrs, int width, int height)
{
int i;
double tolerance[5] = {.1, .5, 1, 5, 10};
double line_width = .08 * width;
double gap = width / 6;
- XrSetRGBColor (xrs, 0, 0, 0);
- XrSetLineWidth (xrs, line_width);
+ cairo_set_rgb_color (xrs, 0, 0, 0);
+ cairo_set_line_width (xrs, line_width);
- XrTranslate (xrs, gap, 0);
+ cairo_translate (xrs, gap, 0);
for (i=0; i < 5; i++) {
- XrSetTolerance (xrs, tolerance[i]);
+ cairo_set_tolerance (xrs, tolerance[i]);
draw_spline (xrs, height);
- XrTranslate (xrs, gap, 0);
+ cairo_translate (xrs, gap, 0);
}
}
Index: stars.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/stars.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- stars.c 15 May 2003 20:20:22 -0000 1.2
+++ stars.c 30 Jul 2003 21:30:00 -0000 1.3
@@ -1,13 +1,13 @@
-#include <Xr.h>
+#include <cairo.h>
#include <math.h>
#include "write_png.h"
void
-draw_stars (XrState *xrs, int width, int height);
+draw_stars (cairo_t *xrs, int width, int height);
void
-star_path (XrState *xrs);
+star_path (cairo_t *xrs);
#define WIDTH 600
#define HEIGHT 275
@@ -18,62 +18,64 @@
int
main (void)
{
- XrState *xrs;
+ cairo_t *xrs;
- xrs = XrCreate ();
+ xrs = cairo_create ();
- XrSetTargetImage (xrs, image, XrFormatARGB32,
+ cairo_set_target_image (xrs, image, CAIRO_FORMAT_ARGB32,
WIDTH, HEIGHT, STRIDE);
- XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
- XrSetRGBColor (xrs, 1, 1, 1);
- XrFill (xrs);
+/*
+ cairo_rectangle (xrs, 0, 0, WIDTH, HEIGHT);
+ cairo_set_rgb_color (xrs, 1, 1, 1);
+ cairo_fill (xrs);
+*/
draw_stars (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "stars.png", WIDTH, HEIGHT, STRIDE);
- XrDestroy (xrs);
+ cairo_destroy (xrs);
return 0;
}
void
-star_path (XrState *xrs)
+star_path (cairo_t *xrs)
{
int i;
double theta = 4 * M_PI / 5.0;
- XrMoveTo (xrs, 0, 0);
+ cairo_move_to (xrs, 0, 0);
for (i=0; i < 4; i++) {
- XrRelLineTo (xrs, 1.0, 0);
- XrRotate (xrs, theta);
+ cairo_rel_line_to (xrs, 1.0, 0);
+ cairo_rotate (xrs, theta);
}
- XrClosePath (xrs);
+ cairo_close_path (xrs);
}
void
-draw_stars (XrState *xrs, int width, int height)
+draw_stars (cairo_t *xrs, int width, int height)
{
- XrSetRGBColor (xrs, 0, 0, 0);
+ cairo_set_rgb_color (xrs, 0, 0, 0);
- XrSave (xrs);
+ cairo_save (xrs);
{
- XrTranslate (xrs, 5, height / 2.6);
- XrScale (xrs, height, height);
+ cairo_translate (xrs, 5, height / 2.6);
+ cairo_scale (xrs, height, height);
star_path (xrs);
- XrSetFillRule (xrs, XrFillRuleWinding);
- XrFill (xrs);
+ cairo_set_fill_rule (xrs, CAIRO_FILL_RULE_WINDING);
+ cairo_fill (xrs);
}
- XrRestore (xrs);
+ cairo_restore (xrs);
- XrSave (xrs);
+ cairo_save (xrs);
{
- XrTranslate (xrs, width - height - 5, height / 2.6);
- XrScale (xrs, height, height);
+ cairo_translate (xrs, width - height - 5, height / 2.6);
+ cairo_scale (xrs, height, height);
star_path (xrs);
- XrSetFillRule (xrs, XrFillRuleEvenOdd);
- XrFill (xrs);
+ cairo_set_fill_rule (xrs, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_fill (xrs);
}
- XrRestore (xrs);
+ cairo_restore (xrs);
}
- Previous message: [Commit] libic/src .cvsignore,1.2,1.3
- Next message: [Commit] grrobot/src/svg cell1.svg, NONE, 1.1 cell2.svg, NONE,
1.1 grr_icon_svg.h, 1.5, 1.6 target_blue_square.svg, 1.4,
1.5 target_green_square.svg, 1.4, 1.5 target_red_square.svg,
1.3, 1.4 target_yellow_square.svg, 1.4, 1.5 cell.svg, 1.3, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commit
mailing list