initial setup of thesis repository
[cluster_expansion_thesis.git] / little_helpers / tikz / sketch-0.2.161 / Doc / sketch / Hello-world.html
blobd7d3bf6f128972f65d2e684761e81ac614ce9850
1 <html lang="en">
2 <head>
3 <title>Hello world - Sketch</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="Sketch">
6 <meta name="generator" content="makeinfo 4.7">
7 <link title="Top" rel="start" href="index.html#Top">
8 <link rel="up" href="Introduction-by-example.html#Introduction-by-example" title="Introduction by example">
9 <link rel="prev" href="Introduction-by-example.html#Introduction-by-example" title="Introduction by example">
10 <link rel="next" href="Drawing-options.html#Drawing-options" title="Drawing options">
11 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12 <!--
13 Copyright (C) 2005, 2006, 2007, 2008 Eugene K. Ressler.
15 This manual is for `sketch', version 0.2 (build 161),
16 Tuesday, September 08, 2009, a program that converts descriptions of simple
17 three-dimensional scenes into static drawings. This version generates
18 `PSTricks' or `PGF/TikZ' code suitable for use with the
19 TeX document processing system.
21 `Sketch' is free software; you can redistribute it and/or modify
22 it under the terms of the GNU General Public License as published by
23 the Free Software Foundation; either version 3, or (at your option)
24 any later version.
26 Sketch is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 GNU General Public License for more details.
31 You should have received a copy of the GNU General Public License
32 along with `sketch'; see the file COPYING.txt. If not, see
33 http://www.gnu.org/copyleft.-->
34 <meta http-equiv="Content-Style-Type" content="text/css">
35 <style type="text/css"><!--
36 pre.display { font-family:inherit }
37 pre.format { font-family:inherit }
38 pre.smalldisplay { font-family:inherit; font-size:smaller }
39 pre.smallformat { font-family:inherit; font-size:smaller }
40 pre.smallexample { font-size:smaller }
41 pre.smalllisp { font-size:smaller }
42 span.sc { font-variant:small-caps }
43 span.roman { font-family: serif; font-weight: normal; }
44 --></style>
45 </head>
46 <body>
47 <div class="node">
48 <p>
49 <a name="Hello-world"></a>Next:&nbsp;<a rel="next" accesskey="n" href="Drawing-options.html#Drawing-options">Drawing options</a>,
50 Previous:&nbsp;<a rel="previous" accesskey="p" href="Introduction-by-example.html#Introduction-by-example">Introduction by example</a>,
51 Up:&nbsp;<a rel="up" accesskey="u" href="Introduction-by-example.html#Introduction-by-example">Introduction by example</a>
52 <hr><br>
53 </div>
55 <!-- node-name, next, previous, up -->
56 <h3 class="section">2.1 Hello world</h3>
58 <p>The <code>sketch</code> program above is nearly the simplest one possible,
59 the equivalent of a &ldquo;hello world&rdquo;
60 <a name="index-hello-world-5"></a><a name="index-program_002c-hello-world-6"></a>program you might find at the start of a programming language text.
61 If it is saved in the file <span class="file">simple.sk</span>, then the command
62 <a name="index-command-line_002c-_0040code_007bsketch_007d-7"></a><a name="index-running-_0040code_007bsketch_007d-8"></a>
63 <pre class="verbatim">
64 sketch simple.sk -o simple.tex
65 </pre>
66 creates a file <span class="file">simple.tex</span> containing <code>PSTricks</code> commands to
67 draw these objects on paper. The contents of <span class="file">simple.tex</span>
68 look like this.
69 <pre class="verbatim">
70 \begin{pspicture}(-1,-1)(2,2)
71 \pstVerb{1 setlinejoin}
72 \psline(-1,-1)(.333,.333)
73 \pspolygon[fillstyle=solid,fillcolor=white](0,0)(1,0)(0,1)
74 \psline(.333,.333)(2,2)
75 \end{pspicture}
76 </pre>
77 The hidden surface algorithm
78 <a name="index-hidden-surface-algorithm-9"></a>of <code>sketch</code> has split
79 <a name="index-splitting_002c-line-and-surface-10"></a>the line into
80 two pieces and ordered the three resulting objects so that the correct
81 portion of the line is hidden.
83 <p>If you've noticed that the projection we are using seems equivalent to
84 erasing the z-coordinate of the three-dimensional input points,
85 pat yourself on the back. You are correct. This is called a
86 <dfn>parallel projection</dfn>.
87 <a name="index-parallel-projection-11"></a><a name="index-projection_002c-parallel-12"></a>The z-coordinate axis is pointing straight out of the paper at
88 us, while the x- and y-axes point to the right and up as
89 usual.
91 <p>The resulting picture file can be included in a LaTeX document with
92 <tt>\input{simple}</tt>. Alternately, adding the command line option
93 <span class="option">-T</span><a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
94 <a name="index-command-line-option-13"></a><a name="index-option_002c-command-line-14"></a>causes the <code>pspicture</code> to be wrapped in a short
95 but complete document, ready to run though LaTeX.
96 <a name="index-document-template-15"></a><a name="index-template_002c-document-16"></a>In a finished, typeset document, the picture looks like this. (The
97 axes have been added in light gray.)
99 <div align="center"><img src="ex020.png" alt="ex020.png"></div>
101 <p class="noindent">It is important to know that only the &ldquo;outside&rdquo;
102 <a name="index-outside-of-a-polygon-17"></a><a name="index-polygon_002c-outside-of-18"></a>of a polygon is
103 normally drawn. The <dfn>outside</dfn> is where the vertices given in the
104 <code>polygon</code>
105 <a name="index-polygon-19"></a>command appear in <em>counter-clockwise</em>
106 <a name="index-counter_002dclockwise-polygon-vertex-order-20"></a><a name="index-polygon-vertex-order-21"></a><a name="index-order_002c-polygon-vertex-22"></a>order. Thus, if the command above had been
107 <pre class="verbatim">
108 polygon(0,1,0)(1,0,0)(0,0,1)
109 </pre>
110 the polygon would not appear in the picture at all. It would have
111 been <dfn>culled</dfn>
112 <a name="index-culling-23"></a>from the scene. This culling behavior may seem
113 strange, but stay tuned.
115 <div class="footnote">
116 <hr>
117 <h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Or for European users of A4 size paper,
118 <span class="option">-Te</span>.</p>
120 <p><hr></div>
122 </body></html>