Anonymous user
Sierpinski arrowhead curve: Difference between revisions
m
→{{header|REXX}}: added/changed some comments.
m (→{{header|REXX}}: added some comments.) |
m (→{{header|REXX}}: added/changed some comments.) |
||
Line 869:
say '═════════════════════════════════════════' /* " " separator.*/
call init /*initialize a bunch of variables. */
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
if order==0 then
call curve order-1, len/2, -angle
end
/*──────────────────────────────────────────────────────────────────────────────────────*/
when heading== 60 then do; @.x.y= '/';
when heading==120 then do; x= x - 1; @.x.y= '\'; y=
when heading==180 then do; x= x - 1; @.x.y= '_';
when heading==240 then do; x= x - 1; y= y
/*──────────────────────────────────────────────────────────────────────────────────────*/
▲drawLine: select /*draw part of the curve using a char. */
!= 2e7+1;
▲ end /*select*/ /*curve character is based on direction*/
▲ minX= min(minX, X); maxX= max(maxX, X) /*save min and max of X. */
▲ minY= min(minY, Y); maxY= max(maxY, Y) /* " " " " " Y. */
▲ return
/*──────────────────────────────────────────────────────────────────────────────────────*/
▲init: $= '@. heading maxX maxY minX minY x y'; @.=" "; heading= 0
if heading<0 then
{{out|output|text= when using the default input value of: <tt> 5 </tt>}}▼
▲showGraph: do row=minY to maxY; _= /*show graph 1 row @ a time*/
▲ do col=minX to maxX; _= _ || @.col.row /*build a row of the graph.*/
▲ end /*col*/; say _ /*show " " " " " */
▲ end /*row*/
▲ return /*only show the used parts.*/
▲turn: parse arg angle; heading= (heading + angle)//360 /*normalize angle <360º (±)*/
▲ return</lang>
▲{{out|output|text= when using the default input:}}
<pre>
Sierpinski arrowhead curve of order 5
|