[Commit] papers/xr_ols2003 appendix.tex,1.9,1.10
Keith Packard
commit@keithp.com
Fri, 16 May 2003 13:13:13 -0700
Committed by: keithp
Update of /local/src/CVS/papers/xr_ols2003
In directory home.keithp.com:/tmp/cvs-serv27617
Modified Files:
appendix.tex
Log Message:
reorder and reformat examples
Index: appendix.tex
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/appendix.tex,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- appendix.tex 16 May 2003 19:55:44 -0000 1.9
+++ appendix.tex 16 May 2003 20:13:11 -0000 1.10
@@ -61,37 +61,6 @@
\begin{scriptsize}
\begin{verbatim}
void
-draw_spiral (XrState *xrs,
- int width, int height)
-{
- int wd = .02 * width;
- int hd = .02 * height;
- int i;
-
- width -= 2;
- height -= 2;
-
- XrMoveTo (xrs, width - 1, -hd - 1);
- 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);
- }
-
- XrSetRGBColor (xrs, 0, 0, 1);
- XrStroke (xrs);
-}
-\end{verbatim}
-\end{scriptsize}
-\caption{Source for nested box illusion}
-\label{fig:spiral_source}
-\end{figure}
-
-\begin{figure}[htbp]
-\begin{scriptsize}
-\begin{verbatim}
-void
stroke_v_twice (XrState *xrs,
int width, int height)
{
@@ -152,6 +121,77 @@
\begin{scriptsize}
\begin{verbatim}
void
+draw_spiral (XrState *xrs,
+ int width, int height)
+{
+ int wd = .02 * width;
+ int hd = .02 * height;
+ int i;
+
+ width -= 2;
+ height -= 2;
+
+ XrMoveTo (xrs, width - 1, -hd - 1);
+ 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);
+ }
+
+ XrSetRGBColor (xrs, 0, 0, 1);
+ XrStroke (xrs);
+}
+\end{verbatim}
+\end{scriptsize}
+\caption{Source for nested box illusion}
+\label{fig:spiral_source}
+\end{figure}
+
+\begin{figure}[htbp]
+\begin{scriptsize}
+\begin{verbatim}
+void
+draw_spline (XrState *xrs, double height)
+{
+ XrMoveTo (xrs, 0, .1 * height);
+ height = .8 * height;
+ XrRelCurveTo (xrs,
+ -height/2, height/2,
+ height/2, height/2,
+ 0, height);
+ XrStroke (xrs);
+}
+
+void
+draw_splines (XrState *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);
+
+ XrTranslate (xrs, gap, 0);
+ for (i=0; i < 5; i++) {
+ XrSetTolerance (xrs, tolerance[i]);
+ draw_spline (xrs, height);
+ XrTranslate (xrs, gap, 0);
+ }
+}
+\end{verbatim}
+\end{scriptsize}
+\caption{Source for splines drawn with varying tolerance}
+\label{fig:splines_tolerance_source}
+\end{figure}
+
+\begin{figure}[htbp]
+\begin{scriptsize}
+\begin{verbatim}
+void
star_path (XrState *xrs)
{
int i;
@@ -198,117 +238,122 @@
\label{fig:stars_source}
\end{figure}
-\begin{figure}[htbp]
+\begin{figure*}[t]
\begin{scriptsize}
+\begin{minipage}{.5\linewidth}
\begin{verbatim}
+XrSurface *
+make_gradient (XrState *xrs,
+ double width, double height)
+{
+ XrSurface *g;
+ XrMatrix *matrix;
+
+ XrSave (xrs);
+
+ g = XrSurfaceCreateNextTo (
+ XrGetTargetSurface (xrs),
+ XrFormatARGB32, 3, 2);
+ XrSetTargetSurface (xrs, g);
+
+ XrSetRGBColor (xrs, 0, 0, 0);
+ XrRectangle (xrs, 0, 0, 1, 2);
+ XrFill (xrs);
+
+ XrSetRGBColor (xrs, 1, 1, 1);
+ XrRectangle (xrs, 1, 0, 1, 2);
+ XrFill (xrs);
+
+ XrSetRGBColor (xrs, 0, 0, 0);
+ XrRectangle (xrs, 2, 0, 1, 2);
+ XrFill (xrs);
+
+ XrRestore (xrs);
+
+ matrix = XrMatrixCreate ();
+ XrMatrixScale (matrix,
+ 2.0/width, 1.0/height);
+ XrSurfaceSetMatrix (g, matrix);
+ XrSurfaceSetFilter (g, XrFilterBilinear);
+ XrMatrixDestroy (matrix);
+
+ return g;
+}
+
void
-draw_spline (XrState *xrs, double height)
+draw_gradients (XrState *xrs,
+ int img_width, int img_height)
{
- XrMoveTo (xrs, 0, .1 * height);
- height = .8 * height;
- XrRelCurveTo (xrs,
- -height/2, height/2,
- height/2, height/2,
- 0, height);
- XrStroke (xrs);
+ XrSurface *gradient;
+ double width, height, pad;
+
+ width = img_width / 4.0;
+ pad = (img_width - (3 * width)) / 2.0;
+ height = img_height;
+
+ gradient=make_gradient(xrs,width,height);
+
+ XrSetPattern (xrs, gradient);
+ draw_flat (xrs, width, height);
+ XrTranslate (xrs, width + pad, 0);
+ XrSetPattern (xrs, gradient);
+ draw_tent (xrs, width, height);
+ XrTranslate (xrs, width + pad, 0);
+ XrSetPattern (xrs, gradient);
+ draw_cylinder (xrs, width, height);
+
+ XrRestore (xrs);
+
+ XrSurfaceDestroy (gradient);
+}
+\end{verbatim}
+\end{minipage}
+\begin{minipage}{.5\linewidth}
+\begin{verbatim}
+void
+draw_flat (XrState *xrs, double w, double h)
+{
+ double hw = w / 2.0;
+
+ XrRectangle (xrs, 0, hw, w, h - hw);
+
+ XrFill (xrs);
}
void
-draw_splines (XrState *xrs,
- int width, int height)
+draw_tent (XrState *xrs, double w, double h)
{
- int i;
- double tolerance[5] = {.1,.5,1,5,10};
- double line_width = .08 * width;
- double gap = width / 6;
+ double hw = w / 2.0;
- XrSetRGBColor (xrs, 0, 0, 0);
- XrSetLineWidth (xrs, line_width);
+ XrMoveTo (xrs, 0, hw);
+ XrRelLineTo (xrs, hw, -hw);
+ XrRelLineTo (xrs, hw, hw);
+ XrRelLineTo (xrs, 0, h - hw);
+ XrRelLineTo (xrs, -hw, -hw);
+ XrRelLineTo (xrs, -hw, hw);
+ XrClosePath (xrs);
- XrTranslate (xrs, gap, 0);
- for (i=0; i < 5; i++) {
- XrSetTolerance (xrs, tolerance[i]);
- draw_spline (xrs, height);
- XrTranslate (xrs, gap, 0);
- }
+ XrFill (xrs);
+}
+
+void
+draw_cylinder (XrState *xrs, double w, double h)
+{
+ double hw = w / 2.0;
+
+ XrMoveTo (xrs, 0, hw);
+ XrRelCurveTo (xrs, 0, -hw,
+ w, -hw, w, 0);
+ XrRelLineTo (xrs, 0, h - hw);
+ XrRelCurveTo (xrs, 0, -hw,
+ -w, -hw, -w, 0);
+ XrClosePath (xrs);
+
+ XrFill (xrs);
}
\end{verbatim}
+\end{minipage}
\end{scriptsize}
-\caption{Source for splines drawn with varying tolerance}
-\label{fig:splines_tolerance_source}
-\end{figure}
-
-% This one may be a bit long, (and it's already incomplete).
-% I think we alrady have too many examples, let's drop this.
-% \begin{figure}[htbp]
-% \begin{scriptsize}
-% \begin{verbatim}
-% XrSurface *
-% make_gradient (XrState *xrs,
-% double width, double height)
-% {
-% XrSurface *g;
-% XrMatrix *matrix;
-%
-% XrSave (xrs);
-%
-% g = XrSurfaceCreateNextTo (
-% XrGetTargetSurface (xrs),
-% XrFormatARGB32, 3, 2);
-% XrSetTargetSurface (xrs, g);
-%
-% XrSetRGBColor (xrs, 0, 0, 0);
-% XrRectangle (xrs, 0, 0, 1, 2);
-% XrFill (xrs);
-%
-% XrSetRGBColor (xrs, 1, 1, 1);
-% XrRectangle (xrs, 1, 0, 1, 2);
-% XrFill (xrs);
-%
-% XrSetRGBColor (xrs, 0, 0, 0);
-% XrRectangle (xrs, 2, 0, 1, 2);
-% XrFill (xrs);
-%
-% XrRestore (xrs);
-%
-% matrix = XrMatrixCreate ();
-% XrMatrixScale (matrix,
-% 2.0/width, 1.0/height);
-% XrSurfaceSetMatrix (g, matrix);
-% XrSurfaceSetFilter (g, XrFilterBilinear);
-% XrMatrixDestroy (matrix);
-%
-% return g;
-% }
-%
-% void
-% draw_gradients (XrState *xrs,
-% int img_width, int img_height)
-% {
-% XrSurface *gradient;
-% double width, height, pad;
-%
-% width = img_width / 4.0;
-% pad = (img_width - (3 * width)) / 2.0;
-% height = img_height;
-%
-% gradient=make_gradient(xrs,width,height);
-%
-% XrSetPattern (xrs, gradient);
-% draw_flat (xrs, width, height);
-% XrTranslate (xrs, width + pad, 0);
-% XrSetPattern (xrs, gradient);
-% draw_tent (xrs, width, height);
-% XrTranslate (xrs, width + pad, 0);
-% XrSetPattern (xrs, gradient);
-% draw_cylinder (xrs, width, height);
-%
-% XrRestore (xrs);
-%
-% XrSurfaceDestroy (gradient);
-% }
-% \end{verbatim}
-% \end{scriptsize}
-% \caption{Source for 3 gradient-filled shapes}
-% \label{fig:outline_source}
-% \end{figure}
+\caption{Source for 3 gradient-filled shapes}
+\label{fig:outline_source}
+\end{figure*}