[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 06:29:18 -0700


Committed by: cworth

Update of /local/src/CVS/papers/xr_ols2003
In directory home.keithp.com:/tmp/cvs-serv24246

Modified Files:
	api.tex appendix.tex 
Log Message:
Added reference to Hering figure with source code.
(Had to implement this twice as I screwed up and let cvsup blow away my change the first time)

Index: api.tex
===================================================================
RCS file: /local/src/CVS/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 13:29:16 -0000	1.9
@@ -117,6 +117,19 @@
 XrDefaultMatrix function can be used to restore the CTM to its
 original state.
 
+In Figure~\ref{fig:hering}, each of the radial lines was drawn using
+identical path coordinates. The different angles were achieved by
+calling XrRotate before drawing each line. The source code 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 with 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 +215,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 +232,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 +260,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
@@ -366,7 +382,7 @@
 onto the target surface. This functionality is similar to the notion
 of transparency groups in PDF 1.4 and can be achieved with the
 following idiom:
-\begin{small}
+\begin{scriptsize}
 \begin{verbatim}
 XrSave (xrs);
 XrSetTargetSurface (xrs, intermediate);
@@ -375,7 +391,7 @@
 XrRestore (xrs);
 XrShowSurface (xrs, surface);
 \end{verbatim}
-\end{small}
+\end{scriptsize}
 In this example an intermediate surface is installed as the target
 surface, and then graphics are drawn on the intermediate surface. When
 XrRestore is called, the original target surface is restored and the
@@ -385,14 +401,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: /local/src/CVS/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 13:29:16 -0000	1.6
@@ -6,6 +6,54 @@
 \begin{scriptsize}
 \begin{verbatim}
 void
+draw_hering (XrState *xrs,
+             int width, int height)
+{
+#define LINES 32.0
+#define MAX_THETA (.80 * M_PI_2)
+#define THETA (2 * MAX_THETA / (LINES-1))
+
+  int i;
+
+  XrSetRGBColor (xrs, 0, 0, 0);
+  XrSetLineWidth (xrs, 2.0);
+
+  XrSave (xrs);
+  {
+    XrTranslate (xrs, width / 2, height / 2);
+    XrRotate (xrs, MAX_THETA);
+       
+    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)
 {
@@ -187,8 +235,8 @@
 \begin{scriptsize}
 \begin{verbatim}
 XrSurface *
-create_gradient (XrState *xrs,
-                 double width, double height)
+make_gradient (XrState *xrs,
+               double width, double height)
 {
     XrSurface *g;
     XrMatrix *matrix;
@@ -226,7 +274,7 @@
 
 void
 draw_gradients (XrState *xrs,
-                  int img_width, int img_height)
+                int img_width, int img_height)
 {
     XrSurface *gradient;
     double width, height, pad;
@@ -235,7 +283,7 @@
     pad = (img_width - (3 * width)) / 2.0;
     height = img_height;
 
-    gradient = create_gradient (xrs, width, height);
+    gradient=make_gradient(xrs,width,height);
 
     XrSetPattern (xrs, gradient);
     draw_flat (xrs, width, height);