[Commit] papers/xr_ols2003 api.tex,1.8,1.9 appendix.tex,1.5,1.6

Carl Worth commit@keithp.com
Fri, 16 May 2003 03:02:05 -0400


Committed by: cworth

Update of /mirrors/keithp/papers/xr_ols2003
In directory brudder:/home/cworth/papers/xr_ols2003

Modified Files:
	api.tex appendix.tex 
Log Message:
Added reference to Hering figure and source code

Index: api.tex
===================================================================
RCS file: /mirrors/keithp/papers/xr_ols2003/api.tex,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- api.tex	16 May 2003 06:38:37 -0000	1.8
+++ api.tex	16 May 2003 07:02:02 -0000	1.9
@@ -117,6 +117,20 @@
 XrDefaultMatrix function can be used to restore the CTM to its
 original state.
 
+In Figure~\ref{fig:hering}, each of the radial lines is drawn using
+the same coordinates. They are each positioned by using XrTranslate to
+place the origin at the center of the image, and then calling XrRotate
+before constructing the path for each line. The source for this image
+is in Figure~\ref{fig:hering_source}.
+\begin{figure}[htbp]
+  \begin{center}
+  \epsfxsize=1in
+  \epsfbox{examples/hering}
+  \caption{Hering Illusion: Radial lines positioned using XrTranslate and XrRotate}
+  \label{fig:hering}
+  \end{center}
+\end{figure}
+
 \subsection{Save/Restore of Graphics State}
 
 Programs using a structured approach to drawing will modify graphics
@@ -202,7 +216,7 @@
 XrRelLineTo. The distinction is that a closed subpath will have a join
 at the junction of the final coincident point while an unclosed path
 will have caps on either end of the path, (even if the two ends happen
-to be coincident). See Section~\ref{sec:path_drawing} for more
+to be coincident). See Section~\ref{sec:path_stroking} for more
 discussion of caps and joins.
 
 As rectangular paths are commonly used, Xr provides a convenience
@@ -219,12 +233,12 @@
 \end{verbatim}
 \end{small}
 
-\subsection{Path Drawing}
-\label{sec:path_drawing}
-
 After a path is constructed, it can be drawn in one of two ways:
 stroking its outline (XrStroke) or filling its interior (XrFill).
 
+\subsection{Path Stroking}
+\label{sec:path_stroking}
+
 XrStroke draws the outline formed by stroking the path with a pen of
 the current line width.  The line width is set with the XrSetLineWidth
 function. As subsequent segments within a subpath are drawn, they are
@@ -247,6 +261,9 @@
   \end{center}
 \end{figure}
 
+\subsection{Path Filling}
+\label{sec:path_filling}
+
 XrFill fills the area on the ``inside'' of the current path. Xr can
 apply either the winding rule or the even-odd rule to determine the
 meaning of ``inside''. This behavior is controlled by calling
@@ -297,7 +314,7 @@
   \begin{center}
   \epsfxsize=2in
   \epsfbox{examples/splines_tolerance}
-  \caption{Spline drawn with tolerance of .1, .5, 1, 5, and 10}
+  \caption{Splines drawn with tolerance values of .1, .5, 1, 5, and 10}
   \label{fig:splines_tolerance}
   \end{center}
 \end{figure}
@@ -338,7 +355,7 @@
   \begin{center}
   \epsfxsize=2.5in
   \epsfbox{examples/outline}
-  \caption{An example showing XrFill with XrSetPattern used to create a gradient}
+  \caption{3D Depth from Shading and Outline: XrFill with XrSetPattern used to create a gradient}
   \label{fig:outline}
   \end{center}
 \end{figure}
@@ -369,9 +386,9 @@
 \begin{small}
 \begin{verbatim}
 XrSave (xrs);
-XrSetTargetSurface (xrs, intermediate);
-/* draw to intermediate surface with 
-   any Xr operations */
+XrSetTargetSurface (xrs, surface);
+/* draw to intermediate surface
+   with any Xr operations */
 XrRestore (xrs);
 XrShowSurface (xrs, surface);
 \end{verbatim}
@@ -385,14 +402,5 @@
 This technique can be applied recursively with any number of levels of
 intermediate surfaces each receiving the results of its ``child''
 surfaces before being composited into its ``parent'' surface.
-
-\begin{figure}[htbp]
-  \begin{center}
-  \epsfxsize=1in
-  \epsfbox{examples/hering}
-  \caption{Example showing XrTranslate, XrRotate and XrSetLineWidth}
-  \label{fig:line_width_example}
-  \end{center}
-\end{figure}
 
 

Index: appendix.tex
===================================================================
RCS file: /mirrors/keithp/papers/xr_ols2003/appendix.tex,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- appendix.tex	16 May 2003 06:38:37 -0000	1.5
+++ appendix.tex	16 May 2003 07:02:02 -0000	1.6
@@ -6,6 +6,53 @@
 \begin{scriptsize}
 \begin{verbatim}
 void
+draw_hering (XrState *xrs, int width, int height)
+{
+#define LINES 32.0
+#define MAX (.80 * M_PI_2)
+#define THETA (2 * MAX / (LINES-1))
+
+  int i;
+
+  XrSetRGBColor (xrs, 0, 0, 0);
+  XrSetLineWidth (xrs, 2.0);
+
+  XrSave (xrs);
+  {
+    XrTranslate (xrs, width / 2, height / 2);
+    XrRotate (xrs, MAX);
+        
+    for (i=0; i < LINES; i++) {
+      XrMoveTo (xrs, -2 * width, 0);
+      XrLineTo (xrs, 2 * width, 0);
+      XrStroke (xrs);
+            
+      XrRotate (xrs, - THETA);
+    }
+  }
+  XrRestore (xrs);
+
+  XrSetLineWidth (xrs, 6);
+  XrSetRGBColor (xrs, 1, 0, 0);
+
+  XrMoveTo (xrs, width / 4, 0);
+  XrRelLineTo (xrs, 0, height);
+  XrStroke (xrs);
+
+  XrMoveTo (xrs, 3 * width / 4, 0);
+  XrRelLineTo (xrs, 0, height);
+  XrStroke (xrs);
+}
+\end{verbatim}
+\end{scriptsize}
+\caption{Source for Hering illusion}
+\label{fig:hering_source}
+\end{figure}
+
+\begin{figure}[htbp]
+\begin{scriptsize}
+\begin{verbatim}
+void
 draw_spiral (XrState *xrs,
              int width, int height)
 {
@@ -226,29 +273,29 @@
 
 void
 draw_gradients (XrState *xrs,
-                  int img_width, int img_height)
+                int img_width, int img_height)
 {
-    XrSurface *gradient;
+    XrSurface *grad;
     double width, height, pad;
 
     width = img_width / 4.0;
     pad = (img_width - (3 * width)) / 2.0;
     height = img_height;
 
-    gradient = create_gradient (xrs, width, height);
+    grad = create_gradient (xrs,width,height);
 
-    XrSetPattern (xrs, gradient);
+    XrSetPattern (xrs, grad);
     draw_flat (xrs, width, height);
     XrTranslate (xrs, width + pad, 0);
-    XrSetPattern (xrs, gradient);
+    XrSetPattern (xrs, grad);
     draw_tent (xrs, width, height);
     XrTranslate (xrs, width + pad, 0);
-    XrSetPattern (xrs, gradient);
+    XrSetPattern (xrs, grad);
     draw_cylinder (xrs, width, height);
 
     XrRestore (xrs);
 
-    XrSurfaceDestroy (gradient);
+    XrSurfaceDestroy (grad);
 }
 \end{verbatim}
 \end{scriptsize}