[Commit] papers/xr_ols2003 api.tex,1.3,1.4 appendix.tex,1.1,1.2
Carl Worth
commit@keithp.com
Thu, 15 May 2003 13:04:50 -0700
- Previous message: [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
- Next message: [Commit] papers/xr_ols2003/examples stars.c,NONE,1.1 Makefile,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /local/src/CVS/papers/xr_ols2003
In directory home.keithp.com:/tmp/cvs-serv16992
Modified Files:
api.tex appendix.tex
Log Message:
Added some figure references. Added stars example
Index: api.tex
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/api.tex,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- api.tex 15 May 2003 17:34:17 -0000 1.3
+++ api.tex 15 May 2003 20:04:48 -0000 1.4
@@ -78,13 +78,14 @@
surface as appropriate, (eg. write the image to a file, display the
graphics on the screen, etc.).
-Sections~\ref{sec:path_example}-\ref{sec:pattern_example} provide examples
+Sections~\ref{sec:transformations}-\ref{sec:patterns} provide examples
that build on this initial program. Each example consists of a single
function that accepts an XrState pointer and performs drawing
operations. Each example can be made into a complete program by simply
adding the new function call to the program of Figure~\ref{fig:source_minimal}.
\subsection{Transformations}
+\label{sec:transformations}
All coordinates passed from user code to Xr are in a coordinate system
known as ``user space''. These coordinates must be transformed to
@@ -108,7 +109,7 @@
Programs using a structured approach to drawing will modify graphics
state parameters in a hierarchical fashion. For example, a program may
-traverse a tree of objects to be drawn, modifying the CTM, current
+traverse a tree of objects to be drawn modifying the CTM, current
color, line width, etc. at each level of the hierarchy.
Xr supports this hierarchical approach to graphics by maintaing a
@@ -122,7 +123,8 @@
This model has proven effective within structured C programs. Most
drawing functions can be written with the following style:
\begin{verbatim}
-void draw_something (XrState *xrs)
+void
+draw_something (XrState *xrs)
{
XrSave (xrs);
@@ -136,7 +138,7 @@
to more readily reusable code. Sometimes a single function will
contain multiple sections of code framed by XrSave/XrRestore calls.
Some find it more readable to include a new indented block between the
-XrSave/XrRestore calls in this case. Figure~\ref{fig:caps_joins_code}
+XrSave/XrRestore calls in this case. Figure~\ref{fig:caps_joins_source}
contains an example of this style.
\subsection{Path Construction}
@@ -164,6 +166,18 @@
It is often convenient to specify path coordinates as relative offsets
from the current point rather than as aboslute coordinates. To allow
this, Xr provides XrRelMoveTo, XrRelLineTo, and XrRelCurveTo.
+Figure~\ref{fig:spiral} shows a rendering of a path constructed with
+one call to XrMoveTo and four calls to XrRelLineTo in a loop. The
+source code for this figure can be seen in
+Figure~\ref{fig:spiral_source}.
+\begin{figure}[htbp]
+ \begin{center}
+ \epsfxsize=2in
+ \epsfbox{examples/spiral}
+ \caption{Nested box illusion---constructed with XrMoveTo and XrRelLineTo}
+ \label{fig:spiral}
+ \end{center}
+\end{figure}
Finally, XrClosePath closes the current subpath. This operations
involves adding a straight line segment from the current point to the
@@ -173,7 +187,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:caps_joins_example} for more
+to be coincident). See Section~\ref{sec:path_drawing} for more
discussion of caps and joins.
As rectangular paths are commonly used, Xr provides a convenience
@@ -189,6 +203,7 @@
\end{verbatim}
\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).
@@ -202,25 +217,34 @@
different cap styles, (butt, square, or round), applied at either end
of the path. The cap style is set with the XrSetLineCap function.
+Figure~\ref{fig:caps_joins} demonstrates the three possible cap and
+join styles. The source code for this figure (see
+Figure~\ref{fig:caps_joins_source}) demonstrates the use of
+XrSetLineJoin and XrSetLineCap as well as XrTranslate, XrSave, and
+XrRestore.
+\begin{figure}[htbp]
+ \begin{center}
+ \epsfxsize=2in \epsfbox{examples/caps_joins}
+ \caption{Demonstration of cap and join styles}
+ \label{fig:caps_joins}
+ \end{center}
+\end{figure}
+
XrFill fills the area on the ``inside'' of the current path. Xr allows
either the winding rule or the even-odd rule to be used to determine
the area inside the path. This behavior is controlled by calling
XrSetFillRule with a value of XrFillRuleWinding or XrFillRuleEvenOdd.
-Figure~\ref{fig:spiral_code} shows an example of code using XrMoveTo
-and XrRelLineTo to construct a spiral-shaped path. XrStroke is used to
-draw the outline of this path. Figure~\ref{fig:spiral_result} shows
-the result of this code, (a figure that appears to be several nested
-squares but is in fact a single continuous path).
-
-% And yes, I'm having too much fun drawing optical illusions.
-
+Figure~\ref{fig:stars} demonstrates the effect of the fill rule given
+a star-shaped path. With the winding rule the entire star is filled
+in, while with the even-odd rule the center of the star is considered
+outside the path and is not filled. Figure~\ref{fig:stars_source}
+contains the source code for this example.
\begin{figure}[htbp]
\begin{center}
- \epsfxsize=2in
- \epsfbox{examples/spiral}
- \caption{Example showing XrStroke}
- \label{fig:spiral_result}
+ \epsfxsize=2in \epsfbox{examples/stars}
+ \caption{Demonstration of the effect of the fill rule}
+ \label{fig:stars}
\end{center}
\end{figure}
@@ -233,14 +257,6 @@
\begin{figure}[htbp]
\begin{center}
- \epsfxsize=2in \epsfbox{examples/caps_joins}
- \caption{Example showing cap and join styles}
- \label{fig:caps_joins_result}
- \end{center}
-\end{figure}
-
-\begin{figure}[htbp]
- \begin{center}
\epsfxsize=1in
\epsfbox{examples/hering}
\caption{Example showing XrTranslate, XrRotate and XrSetLineWidth}
@@ -249,7 +265,7 @@
\end{figure}
\subsection{Using Patterns}
-\label{sec:pattern_example}
+\label{sec:patterns}
\begin{figure}[htbp]
\begin{center}
Index: appendix.tex
===================================================================
RCS file: /local/src/CVS/papers/xr_ols2003/appendix.tex,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- appendix.tex 15 May 2003 17:34:17 -0000 1.1
+++ appendix.tex 15 May 2003 20:04:48 -0000 1.2
@@ -29,8 +29,8 @@
}
\end{verbatim}
\end{scriptsize}
-\caption{Using XrMoveTo, XrRelLineTo, and XrStroke}
-\label{fig:spiral_code}
+\caption{Source for nested box illusion}
+\label{fig:spiral_source}
\end{figure}
\begin{figure}[htbp]
@@ -89,7 +89,59 @@
}
\end{verbatim}
\end{scriptsize}
-\caption{Using XrSetLineCap, XrSetLineJoin, XrSave, and XrRestore}
-\label{fig:caps_joins_code}
+\caption{Source for cap and join demonstration}
+\label{fig:caps_joins_source}
\end{figure}
+\begin{figure}[htbp]
+\begin{scriptsize}
+\begin{verbatim}
+void
+star_path (XrState *xrs)
+{
+ int i;
+ double theta = 4 * M_PI / 5.0;
+
+ XrMoveTo (xrs, 0, 0);
+ for (i=0; i < 4; i++) {
+ XrRelLineTo (xrs, 1.0, 0);
+ XrRotate (xrs, theta);
+ }
+ XrRotate (xrs, theta);
+ XrRotate (xrs, theta);
+ XrRotate (xrs, theta);
+ XrClosePath (xrs);
+}
+
+void
+draw_stars (XrState *xrs,
+ int width, int height)
+{
+ XrSetRGBColor (xrs, 0, 0, 0);
+
+ XrSave (xrs);
+ {
+ XrTranslate (xrs, 5, height/2.6);
+ XrScale (xrs, height, height);
+ star_path (xrs);
+ XrSetFillRule (xrs, XrFillRuleWinding);
+ XrFill (xrs);
+ }
+ XrRestore (xrs);
+
+ XrSave (xrs);
+ {
+ XrTranslate (xrs,
+ width-height-5, height/2.6);
+ XrScale (xrs, height, height);
+ star_path (xrs);
+ XrSetFillRule (xrs, XrFillRuleEvenOdd);
+ XrFill (xrs);
+ }
+ XrRestore (xrs);
+}
+\end{verbatim}
+\end{scriptsize}
+\caption{Source for stars to demonstrate fill rule}
+\label{fig:stars_source}
+\end{figure}
- Previous message: [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
- Next message: [Commit] papers/xr_ols2003/examples stars.c,NONE,1.1 Makefile,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]