/usr/share/mozart/doc/demo/node22.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>A single 3D flower: Flowers3d.oz</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node21.html#code.flowers"><< Prev</A></TD><TD><A href="flowers.html">- Up -</A></TD></TR></TABLE><DIV class="unnumbered" id="code.flowers3d"><H3><A name="code.flowers3d">A single 3D flower: <CODE>Flowers3d.oz</CODE></A></H3><P class="margin"><A href="Flowers/Flowers3d.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR> <BR><SPAN class="keyword">import</SPAN> <BR> Tk<BR> Application<BR> <BR><SPAN class="keyword">define</SPAN> <BR> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">WindowClass</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> BaseObject</SPAN> <BR> <SPAN class="keyword">feat</SPAN> width height win view frame button1 button2<BR> <SPAN class="keyword">attr</SPAN> color<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Width Height Title Draw) View <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">self.</SPAN>width = {IntToFloat Width}<BR> <SPAN class="keyword">self.</SPAN>height = {IntToFloat Height}<BR> color <SPAN class="keyword"><-</SPAN> black<BR> <SPAN class="keyword">self.</SPAN>win = {New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit(title: <SPAN class="string">'3D Flowers'</SPAN> <BR> delete: <SPAN class="keyword">proc</SPAN>{<SPAN class="functionname">$</SPAN>}<BR> {<SPAN class="keyword">self.</SPAN>win tkClose}<BR> {Application<SPAN class="keyword">.</SPAN>exit 0}<BR> <SPAN class="keyword">end</SPAN>)}<BR> <SPAN class="keyword">self.</SPAN>view = {New Tk<SPAN class="keyword">.</SPAN>canvas tkInit(parent: <SPAN class="keyword">self.</SPAN>win bg: black <BR> width: Width height: Height)}<BR> View = <SPAN class="keyword">self.</SPAN>view<BR> {Tk<SPAN class="keyword">.</SPAN>send wm(title <SPAN class="keyword">self.</SPAN>win Title)}<BR> {Tk<SPAN class="keyword">.</SPAN>send wm(minsize <SPAN class="keyword">self.</SPAN>win 10 10)}<BR> <BR> <SPAN class="keyword">self.</SPAN>frame = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: <SPAN class="keyword">self.</SPAN>win<BR> bg: {TkColor blue})}<BR> <SPAN class="keyword">self.</SPAN>button1 = {New Tk<SPAN class="keyword">.</SPAN>button tkInit(parent: <SPAN class="keyword">self.</SPAN>frame action: Draw<BR> bg: green <BR> text:<SPAN class="string">"Start DrawingFlower"</SPAN>)}<BR> <SPAN class="keyword">self.</SPAN>button2 = {New Tk<SPAN class="keyword">.</SPAN>button tkInit(parent: <SPAN class="keyword">self.</SPAN>frame<BR> bg: {TkColor red}<BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} <BR> {View tk(delete(all))}<BR> <SPAN class="keyword">end</SPAN> <BR> text:<SPAN class="string">"Clear"</SPAN>)}<BR> {Tk<SPAN class="keyword">.</SPAN>send pack(<SPAN class="keyword">self.</SPAN>button1 <SPAN class="keyword">self.</SPAN>button2 side:left)}<BR> <BR> {Tk<SPAN class="keyword">.</SPAN>send pack(<SPAN class="keyword">self.</SPAN>frame <SPAN class="keyword">self.</SPAN>view)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">drawLine</SPAN>(X1 Y1 X2 Y2)<BR> {<SPAN class="keyword">self.</SPAN>view tk(crea line X1 (<SPAN class="keyword">self.</SPAN>height<SPAN class="keyword">-</SPAN>Y1)<BR> X2 (<SPAN class="keyword">self.</SPAN>height<SPAN class="keyword">-</SPAN>Y2) fill: <SPAN class="keyword">@</SPAN>color)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">ConvertPoints</SPAN>(In $)<BR> Height = <SPAN class="keyword">self.</SPAN>height<BR> <SPAN class="keyword">in</SPAN> <BR> b({FoldR In <SPAN class="keyword">fun</SPAN>{<SPAN class="functionname">$</SPAN> X<SPAN class="keyword">#</SPAN>Y In}X<SPAN class="keyword">|</SPAN>(Height<SPAN class="keyword">-</SPAN>Y)<SPAN class="keyword">|</SPAN>In <SPAN class="keyword">end</SPAN> nil})<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">filledPolygon</SPAN>(Points)<BR> {<SPAN class="keyword">self.</SPAN>view tk(crea polygon {<SPAN class="keyword">self</SPAN> ConvertPoints(Points $)}<BR> fill: <SPAN class="keyword">@</SPAN>color)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">setColor</SPAN>(Color)<BR> color <SPAN class="keyword"><-</SPAN> Color<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> % <SPAN class="comment">class WindowClass<BR></SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">TurtleObject</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> BaseObject</SPAN> <BR> <SPAN class="keyword">feat</SPAN> sw a win <BR> <SPAN class="keyword">attr</SPAN> x y pl tuX tuY tuZ tlX tlY tlZ thX thY thZ <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Win IState)<BR> x <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>start<SPAN class="keyword">.</SPAN>x <BR> y <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>start<SPAN class="keyword">.</SPAN>y<BR> pl <SPAN class="keyword"><-</SPAN> nil<BR> tuX <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>tu<SPAN class="keyword">.</SPAN>x<BR> tuY <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>tu<SPAN class="keyword">.</SPAN>y<BR> tuZ <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>tu<SPAN class="keyword">.</SPAN>z<BR> tlX <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>tl<SPAN class="keyword">.</SPAN>x<BR> tlY <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>tl<SPAN class="keyword">.</SPAN>y<BR> tlZ <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>tl<SPAN class="keyword">.</SPAN>z<BR> thX <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>th<SPAN class="keyword">.</SPAN>x<BR> thY <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>th<SPAN class="keyword">.</SPAN>y<BR> thZ <SPAN class="keyword"><-</SPAN> IState<SPAN class="keyword">.</SPAN>istate<SPAN class="keyword">.</SPAN>th<SPAN class="keyword">.</SPAN>z<BR> <SPAN class="keyword">self.</SPAN>sw = IState<SPAN class="keyword">.</SPAN>stepWidth<BR> <SPAN class="keyword">self.</SPAN>a = IState<SPAN class="keyword">.</SPAN>arc <BR> <SPAN class="keyword">self.</SPAN>win = Win <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init1</SPAN>(X Y PL TuX TuY TuZ TlX TlY TlZ ThX ThY ThZ SW Arc Win)<BR> x <SPAN class="keyword"><-</SPAN> X <BR> y <SPAN class="keyword"><-</SPAN> Y <BR> pl <SPAN class="keyword"><-</SPAN> PL<BR> tuX <SPAN class="keyword"><-</SPAN> TuX <BR> tuY <SPAN class="keyword"><-</SPAN> TuY <BR> tuZ <SPAN class="keyword"><-</SPAN> TuZ <BR> tlX <SPAN class="keyword"><-</SPAN> TlX <BR> tlY <SPAN class="keyword"><-</SPAN> TlY<BR> tlZ <SPAN class="keyword"><-</SPAN> TlZ <BR> thX <SPAN class="keyword"><-</SPAN> ThX<BR> thY <SPAN class="keyword"><-</SPAN> ThY<BR> thZ <SPAN class="keyword"><-</SPAN> ThZ<BR> <SPAN class="keyword">self.</SPAN>sw = SW<BR> <SPAN class="keyword">self.</SPAN>a = Arc <BR> <SPAN class="keyword">self.</SPAN>win = Win <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">duplicate</SPAN>($)<BR> {New TurtleObject init1(<SPAN class="keyword">@</SPAN>x <SPAN class="keyword">@</SPAN>y <SPAN class="keyword">@</SPAN>pl<BR> <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <BR> <SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ<BR> <SPAN class="keyword">self.</SPAN>sw <SPAN class="keyword">self.</SPAN>a <SPAN class="keyword">self.</SPAN>win)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">move</SPAN> <BR> x <SPAN class="keyword"><-</SPAN> (<SPAN class="keyword">@</SPAN>x <SPAN class="keyword">+</SPAN> <SPAN class="keyword">self.</SPAN>sw <SPAN class="keyword">*</SPAN> <SPAN class="keyword">@</SPAN>thX)<BR> y <SPAN class="keyword"><-</SPAN> (<SPAN class="keyword">@</SPAN>y <SPAN class="keyword">-</SPAN> <SPAN class="keyword">self.</SPAN>sw <SPAN class="keyword">*</SPAN> <SPAN class="keyword">@</SPAN>thY) <BR> pl <SPAN class="keyword"><-</SPAN> (<SPAN class="keyword">@</SPAN>x<SPAN class="keyword">#@</SPAN>y)<SPAN class="keyword">|@</SPAN>pl<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">openPoly</SPAN> <BR> pl <SPAN class="keyword"><-</SPAN> (<SPAN class="keyword">@</SPAN>x<SPAN class="keyword">#@</SPAN>y)<SPAN class="keyword">|@</SPAN>pl<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">closePoly</SPAN>(C)<BR> {<SPAN class="keyword">self.</SPAN>win setColor(C)}<BR> {<SPAN class="keyword">self.</SPAN>win filledPolygon(<SPAN class="keyword">@</SPAN>pl)}<BR> pl <SPAN class="keyword"><-</SPAN> nil<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">draw</SPAN>(C) X = <SPAN class="keyword">@</SPAN>x Y = <SPAN class="keyword">@</SPAN>y <SPAN class="keyword">in</SPAN> <BR> x <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>x <SPAN class="keyword">+</SPAN> <SPAN class="keyword">self.</SPAN>sw <SPAN class="keyword">*</SPAN> <SPAN class="keyword">@</SPAN>thX<BR> y <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>y <SPAN class="keyword">-</SPAN> <SPAN class="keyword">self.</SPAN>sw <SPAN class="keyword">*</SPAN> <SPAN class="keyword">@</SPAN>thY <BR> {<SPAN class="keyword">self.</SPAN>win setColor(C)}<BR> {<SPAN class="keyword">self.</SPAN>win drawLine(X Y <SPAN class="keyword">@</SPAN>x <SPAN class="keyword">@</SPAN>y)}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">VM</SPAN>(X1 Y1 Z1 X2 Y2 Z2 A B XR YR ZR)<BR> XR <SPAN class="keyword"><-</SPAN> A <SPAN class="keyword">*</SPAN> X1 <SPAN class="keyword">+</SPAN> B <SPAN class="keyword">*</SPAN> X2<BR> YR <SPAN class="keyword"><-</SPAN> A <SPAN class="keyword">*</SPAN> Y1 <SPAN class="keyword">+</SPAN> B <SPAN class="keyword">*</SPAN> Y2<BR> ZR <SPAN class="keyword"><-</SPAN> A <SPAN class="keyword">*</SPAN> Z1 <SPAN class="keyword">+</SPAN> B <SPAN class="keyword">*</SPAN> Z2<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">turnU</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <SPAN class="keyword">~</SPAN>1<SPAN class="keyword">.</SPAN>0 0<SPAN class="keyword">.</SPAN>0 thX thY thZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ 0<SPAN class="keyword">.</SPAN>0 <SPAN class="keyword">~</SPAN>1<SPAN class="keyword">.</SPAN>0 tlX tlY tlZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rotUpos</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ {Cos <SPAN class="keyword">self.</SPAN>a} <SPAN class="keyword">~</SPAN>{Sin <SPAN class="keyword">self.</SPAN>a} thX thY thZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ {Sin <SPAN class="keyword">self.</SPAN>a} {Cos <SPAN class="keyword">self.</SPAN>a} tlX tlY tlZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rotUneg</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ {Cos <SPAN class="keyword">self.</SPAN>a} {Sin <SPAN class="keyword">self.</SPAN>a} thX thY thZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <SPAN class="keyword">~</SPAN>{Sin <SPAN class="keyword">self.</SPAN>a} {Cos <SPAN class="keyword">self.</SPAN>a} tlX tlY tlZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rotLpos</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ {Cos <SPAN class="keyword">self.</SPAN>a} {Sin <SPAN class="keyword">self.</SPAN>a} thX thY thZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ <SPAN class="keyword">~</SPAN>{Sin <SPAN class="keyword">self.</SPAN>a} {Cos <SPAN class="keyword">self.</SPAN>a} tuX tuY tuZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rotLneg</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ {Cos <SPAN class="keyword">self.</SPAN>a} <SPAN class="keyword">~</SPAN>{Sin <SPAN class="keyword">self.</SPAN>a} thX thY thZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>thX <SPAN class="keyword">@</SPAN>thY <SPAN class="keyword">@</SPAN>thZ <SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ {Sin <SPAN class="keyword">self.</SPAN>a} {Cos <SPAN class="keyword">self.</SPAN>a} tuX tuY tuZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rotHpos</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ {Cos <SPAN class="keyword">self.</SPAN>a} {Sin <SPAN class="keyword">self.</SPAN>a} tlX tlY tlZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ <SPAN class="keyword">~</SPAN>{Sin <SPAN class="keyword">self.</SPAN>a} {Cos <SPAN class="keyword">self.</SPAN>a} tuX tuY tuZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">rotHneg</SPAN> <BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ {Cos <SPAN class="keyword">self.</SPAN>a} <SPAN class="keyword">~</SPAN>{Sin <SPAN class="keyword">self.</SPAN>a} tlX tlY tlZ)<BR> TurtleObject<SPAN class="keyword">,</SPAN>VM(<SPAN class="keyword">@</SPAN>tlX <SPAN class="keyword">@</SPAN>tlY <SPAN class="keyword">@</SPAN>tlZ <SPAN class="keyword">@</SPAN>tuX <SPAN class="keyword">@</SPAN>tuY <SPAN class="keyword">@</SPAN>tuZ {Sin <SPAN class="keyword">self.</SPAN>a} {Cos <SPAN class="keyword">self.</SPAN>a} tuX tuY tuZ)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> % <SPAN class="comment">class TurtleObject<BR></SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Flower3D</SPAN> Turtle IState}<BR> Start = IState<SPAN class="keyword">.</SPAN>start Grammar = IState<SPAN class="keyword">.</SPAN>grammar<BR> Colors = IState<SPAN class="keyword">.</SPAN>colors RecDepth = IState<SPAN class="keyword">.</SPAN>recDepth<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Interpret</SPAN> Color Turtle N ComList}<BR> <SPAN class="keyword">if</SPAN> N <SPAN class="keyword">></SPAN> 0 <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> ComList<BR> <SPAN class="keyword">of</SPAN> H<SPAN class="keyword">|</SPAN>T <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> H <BR> <SPAN class="keyword">of</SPAN> <SPAN class="string">'+'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle rotUpos}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'-'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle rotUneg}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'|'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle turnU} <BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'\&'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle rotLpos}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'^'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle rotLneg}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'\\'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle rotHpos}<BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'/'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle rotHneg}<BR> <SPAN class="keyword">[]</SPAN> _<SPAN class="keyword">|</SPAN>_ <SPAN class="keyword">then</SPAN> NewTurtle = {Turtle duplicate($)} <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">thread</SPAN> {Interpret Color NewTurtle N H} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'F'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle draw(Color)} <BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'f'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle move} <BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'{'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle openPoly} <BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">'}'</SPAN> <SPAN class="keyword">then</SPAN> {Turtle closePoly(Color)}<BR> <SPAN class="keyword">else</SPAN> <BR> {Interpret Colors<SPAN class="keyword">.</SPAN>H Turtle N<SPAN class="keyword">-</SPAN>1 Grammar<SPAN class="keyword">.</SPAN>H}<BR> <SPAN class="keyword">end</SPAN> <BR> {Interpret Color Turtle N T}<BR> <SPAN class="keyword">else</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">else</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> {Interpret Colors<SPAN class="keyword">.</SPAN>Start Turtle RecDepth Grammar<SPAN class="keyword">.</SPAN>Start}<BR> <SPAN class="keyword">end</SPAN> % <SPAN class="comment">proc Flower3D<BR></SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">TkColor</SPAN> C} <SPAN class="keyword">if</SPAN> Tk<SPAN class="keyword">.</SPAN>isColor <SPAN class="keyword">then</SPAN> C <SPAN class="keyword">else</SPAN> white <SPAN class="keyword">end</SPAN> <SPAN class="keyword">end</SPAN> <BR> <BR> Plant = plant(start : plant<BR> grammar: grammar(<BR> plant: [internode <SPAN class="string">'+'</SPAN> [plant <SPAN class="string">'+'</SPAN> flower]<SPAN class="string">'-'</SPAN> <BR> <SPAN class="string">'-'</SPAN> <SPAN class="string">'/'</SPAN> <SPAN class="string">'/'</SPAN> [<SPAN class="string">'-'</SPAN> <SPAN class="string">'-'</SPAN>leaf] internode<BR> [<SPAN class="string">'+'</SPAN> <SPAN class="string">'+'</SPAN>leaf]<SPAN class="string">'-'</SPAN> [plant <SPAN class="string">'-'</SPAN> <SPAN class="string">'-'</SPAN> <BR> flower]<SPAN class="string">'+'</SPAN> <BR> <SPAN class="string">'+'</SPAN> plant flower]<BR> internode: [<SPAN class="string">'F'</SPAN> seg [<SPAN class="string">'/'</SPAN> <SPAN class="string">'/'</SPAN> <SPAN class="string">'&' '&'</SPAN> leaf]<BR> [<SPAN class="string">'/'</SPAN>leaf <SPAN class="string">'/'</SPAN> <SPAN class="string">'^'</SPAN> <SPAN class="string">'^'</SPAN>leaf]<BR> <SPAN class="string">'F'</SPAN> seg]<BR> seg: [seg <SPAN class="string">'F'</SPAN> seg]<BR> leaf: [[<SPAN class="string">'{'</SPAN> <SPAN class="string">'+'</SPAN>f f<SPAN class="string">'-'</SPAN>f f f<SPAN class="string">'-'</SPAN>f f<SPAN class="string">'+'</SPAN> <SPAN class="string">'|'</SPAN> <BR> <SPAN class="string">'+'</SPAN>f<SPAN class="string">'-'</SPAN>f f<SPAN class="string">'-'</SPAN>f<SPAN class="string">'}'</SPAN>]]<BR> flower: [[<SPAN class="string">'&' '&'</SPAN> <SPAN class="string">'&'pedicel'</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">'wedge<BR> '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">'<BR> wedge'</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">'wedge<BR> '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">'<BR> wedge'</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' '</SPAN><SPAN class="keyword">/</SPAN><SPAN class="string">' wedge]]<BR> pedicel: ['</SPAN>F<SPAN class="string">' '</SPAN>F<SPAN class="string">']<BR> wedge: [stamen['</SPAN>{<SPAN class="string">' '&'</SPAN> <SPAN class="string">'&' '&'</SPAN> <SPAN class="string">'&' <BR> '</SPAN><SPAN class="keyword">-</SPAN><SPAN class="string">'f f f f'</SPAN><SPAN class="keyword">+</SPAN><SPAN class="string">'f f f'</SPAN><SPAN class="keyword">|</SPAN><SPAN class="string">'<BR> '</SPAN><SPAN class="keyword">-</SPAN><SPAN class="string">'f f f'</SPAN><SPAN class="keyword">+</SPAN><SPAN class="string">'f f f f'</SPAN>}<SPAN class="string">']]<BR> stamen: [['</SPAN>^<SPAN class="string">' '</SPAN>{<SPAN class="string">' '</SPAN><SPAN class="keyword">-</SPAN><SPAN class="string">' f f f '</SPAN><SPAN class="keyword">+</SPAN><SPAN class="string">'f f '</SPAN><SPAN class="keyword">|</SPAN><SPAN class="string">'<BR> '</SPAN><SPAN class="keyword">-</SPAN><SPAN class="string">' f f f '</SPAN><SPAN class="keyword">+</SPAN><SPAN class="string">'f f '</SPAN>}<SPAN class="string">']]<BR> )<BR> colors: colors(plant : {TkColor green}<BR> internode: {TkColor brown}<BR> seg : {TkColor brown}<BR> leaf : {TkColor darkgreen}<BR> flower : {TkColor brown}<BR> pedicel : {TkColor brown}<BR> wedge : {TkColor red}<BR> stamen : {TkColor yellow})<BR> istate:state(start: start(x: 100.0 y: 20.0)<BR> tu: tu(x: ~10.0 y: ~2.0 z: 3.0)<BR> tl: tl(x: 6.0 y: 2.0 z: ~5.0)<BR> th: th(x: 1.0 y: ~10.0 z: 0.0))<BR> arc : 0.31<BR> stepWidth: 1.2<BR> recDepth : 5<BR> ) % Plant<BR> <BR> proc {TkFlowers3D} Win in<BR> Win = {New WindowClass init(450 750 '</SPAN>Lindenmayer Flower <SPAN class="string">'<BR> proc {$}<BR> {Flower3D {New TurtleObject<BR> init(Win Plant)} Plant}<BR> end)}<BR> end<BR> <BR> {TkFlowers3D}<BR> <BR>end <BR></SPAN></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node21.html#code.flowers"><< Prev</A></TD><TD><A href="flowers.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|