[Commit] papers/xr_ols2003/examples caps_joins.c,NONE,1.1 Makefile,1.2,1.3 hering.c,1.1,1.2 outline.c,1.2,1.3 spiral.c,1.2,1.3
Carl Worth
commit@keithp.com
Thu, 15 May 2003 10:34:19 -0700
- Previous message: [Commit] papers/xr_ols2003 appendix.tex,NONE,1.1 api.tex,1.2,1.3 introduction.tex,1.3,1.4 xr_ols2003.tex,1.3,1.4
- Next message: [Commit] papers/xr_ols2003 api.tex,1.3,1.4 appendix.tex,1.1,1.2
- 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-serv16062/examples
Modified Files:
Makefile hering.c outline.c spiral.c
Added Files:
caps_joins.c
Log Message:
Spewed some text on how to use the API
--- NEW FILE: caps_joins.c ---
#include <Xr.h>
#include "write_png.h"
void
draw_caps_joins (XrState *xrs, int width, int height);
void
stroke_v_twice (XrState *xrs, int dx, int dy);
void
draw_three_vs (XrState *xrs, int width, int height, int line_width);
#define WIDTH 600
#define HEIGHT 600
#define STRIDE (WIDTH * 4)
char image[STRIDE*HEIGHT];
int
main (void)
{
XrState *xrs;
xrs = XrCreate ();
XrSetTargetImage (xrs, image, XrFormatARGB32,
WIDTH, HEIGHT, STRIDE);
XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
XrSetRGBColor (xrs, 1, 1, 1);
XrFill (xrs);
draw_caps_joins (xrs, WIDTH, HEIGHT);
write_png_argb32 (image, "caps_joins.png", WIDTH, HEIGHT, STRIDE);
XrDestroy (xrs);
return 0;
}
void
stroke_v_twice (XrState *xrs, int width, int height)
{
XrMoveTo (xrs, 0, 0);
XrRelLineTo (xrs, width / 2, height / 2);
XrRelLineTo (xrs, width / 2, - height / 2);
XrSave (xrs);
XrStroke (xrs);
XrRestore (xrs);
XrSave (xrs);
{
XrSetLineWidth (xrs, 2.0);
XrSetLineCap (xrs, XrLineCapButt);
XrSetRGBColor (xrs, 1, 1, 1);
XrStroke (xrs);
}
XrRestore (xrs);
XrNewPath (xrs);
}
void
draw_caps_joins (XrState *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);
XrTranslate (xrs, line_width, line_width);
width -= 2 *line_width;
XrSetLineJoin (xrs, XrLineJoinBevel);
XrSetLineCap (xrs, XrLineCapButt);
stroke_v_twice (xrs, width, height);
XrTranslate (xrs, 0, height / 4 - line_width);
XrSetLineJoin (xrs, XrLineJoinMiter);
XrSetLineCap (xrs, XrLineCapSquare);
stroke_v_twice (xrs, width, height);
XrTranslate (xrs, 0, height / 4 - line_width);
XrSetLineJoin (xrs, XrLineJoinRound);
XrSetLineCap (xrs, XrLineCapRound);
stroke_v_twice (xrs, width, height);
}
Index: Makefile
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile 15 May 2003 02:00:28 -0000 1.2
+++ Makefile 15 May 2003 17:34:17 -0000 1.3
@@ -1,11 +1,12 @@
-EXAMPLES=outline.eps spiral.eps hering.eps
+EXAMPLES = outline.eps spiral.eps hering.eps caps_joins.eps
+.PRECIOUS: outline.png spiral.png hering.png caps_joins.png
CFLAGS=-g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls `pkg-config --cflags Xr`
LDFLAGS=`pkg-config --libs Xr` -lpng
all: ${EXAMPLES}
-.PRECIOUS: outline.png spiral.png hering.png
+
%.eps: %.png
pngtopnm $< | pnmtops -noturn -dpi 300 -equalpixels > $@
Index: hering.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/hering.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hering.c 15 May 2003 02:00:28 -0000 1.1
+++ hering.c 15 May 2003 17:34:17 -0000 1.2
@@ -16,14 +16,11 @@
main (void)
{
XrState *xrs;
- XrSurface *s;
xrs = XrCreate ();
- s = XrSurfaceCreateForImage (image, XrFormatARGB32,
- WIDTH, HEIGHT, STRIDE);
-
- XrSetTargetSurface (xrs, s);
+ XrSetTargetImage (xrs, image, XrFormatARGB32,
+ WIDTH, HEIGHT, STRIDE);
XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
XrSetRGBColor (xrs, 1, 1, 1);
@@ -33,7 +30,6 @@
write_png_argb32 (image, "hering.png", WIDTH, HEIGHT, STRIDE);
- XrSurfaceDestroy (s);
XrDestroy (xrs);
return 0;
@@ -49,7 +45,7 @@
int i;
XrSetRGBColor (xrs, 0, 0, 0);
- XrSetLineWidth (xrs, 1.0);
+ XrSetLineWidth (xrs, 2.0);
XrSave (xrs);
{
@@ -57,8 +53,8 @@
XrRotate (xrs, MAX_THETA);
for (i=0; i < LINES; i++) {
- XrMoveTo (xrs, -5 * width, 0);
- XrLineTo (xrs, 5 * width, 0);
+ XrMoveTo (xrs, -2 * width, 0);
+ XrLineTo (xrs, 2 * width, 0);
XrStroke (xrs);
XrRotate (xrs, - THETA_INC);
@@ -66,7 +62,7 @@
}
XrRestore (xrs);
- XrSetLineWidth (xrs, 4);
+ XrSetLineWidth (xrs, 6);
XrSetRGBColor (xrs, 1, 0, 0);
XrMoveTo (xrs, width / 4, 0);
Index: outline.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/outline.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- outline.c 15 May 2003 02:00:28 -0000 1.2
+++ outline.c 15 May 2003 17:34:17 -0000 1.3
@@ -27,14 +27,11 @@
main (void)
{
XrState *xrs;
- XrSurface *s;
xrs = XrCreate ();
- s = XrSurfaceCreateForImage (image, XrFormatARGB32,
- WIDTH, HEIGHT, STRIDE);
-
- XrSetTargetSurface (xrs, s);
+ XrSetTargetImage (xrs, image, XrFormatARGB32,
+ WIDTH, HEIGHT, STRIDE);
XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
XrSetRGBColor (xrs, 1, 1, 1);
@@ -44,7 +41,6 @@
write_png_argb32 (image, "outline.png", WIDTH, HEIGHT, STRIDE);
- XrSurfaceDestroy (s);
XrDestroy (xrs);
return 0;
Index: spiral.c
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/examples/spiral.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- spiral.c 15 May 2003 02:00:28 -0000 1.2
+++ spiral.c 15 May 2003 17:34:17 -0000 1.3
@@ -15,14 +15,11 @@
main (void)
{
XrState *xrs;
- XrSurface *s;
xrs = XrCreate ();
- s = XrSurfaceCreateForImage (image, XrFormatARGB32,
- WIDTH, HEIGHT, STRIDE);
-
- XrSetTargetSurface (xrs, s);
+ XrSetTargetImage (xrs, image, XrFormatARGB32,
+ WIDTH, HEIGHT, STRIDE);
XrRectangle (xrs, 0, 0, WIDTH, HEIGHT);
XrSetRGBColor (xrs, 1, 1, 1);
@@ -32,7 +29,6 @@
write_png_argb32 (image, "spiral.png", WIDTH, HEIGHT, STRIDE);
- XrSurfaceDestroy (s);
XrDestroy (xrs);
return 0;
@@ -45,11 +41,10 @@
int hd = .02 * height;
int i;
- XrTranslate (xrs, 1, 1);
width -= 2;
height -= 2;
- XrMoveTo (xrs, width, -hd);
+ XrMoveTo (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);
- Previous message: [Commit] papers/xr_ols2003 appendix.tex,NONE,1.1 api.tex,1.2,1.3 introduction.tex,1.3,1.4 xr_ols2003.tex,1.3,1.4
- Next message: [Commit] papers/xr_ols2003 api.tex,1.3,1.4 appendix.tex,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]