KTurtle/Examples: Difference between revisions

From KDE Wiki Sandbox
(Marked this version for translation)
(note for translators)
 
(2 intermediate revisions by the same user not shown)
Line 6: Line 6:
<!--T:1-->
<!--T:1-->
{{Tip|1=Script formatting results from the ''HTML export'' of '''KTurtle'''.}}  
{{Tip|1=Script formatting results from the ''HTML export'' of '''KTurtle'''.}}  
 
<!--No need to translate this:-->{{Note|2=Note for translators|1=If you want to translate the scripts the best way is probably to create the  script in KTurtle, export it as HTML, and insert the exported HTML in the respective Input templates. Alternatively, simply leave the scripts untranslated. A simpler solution using the syntaxhighlight tag is currently being investigated}}




Line 15: Line 15:


<!--T:4-->
<!--T:4-->
Logo script:</translate>
Logo script:
 
<!--T:19-->
{{Input|1=<span style="color: #a0a0a4;"># Koch curve</span><br /><br /><span style="color: #000080;">reset</span><br /><span style="color: #000080;">canvassize</span>&nbsp;<span style="color: #800000;">850</span>,&nbsp;<span style="color: #800000;">550</span><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">125</span>,&nbsp;<span style="color: #800000;">350</span><br /><span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #800080; font-weight: bold;">$t</span><span style="color: #5a64ff; font-weight: bold;">&gt;</span><span style="color: #800000;">0</span> &nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><span style="color: #000000; font-weight: bold;">=</span><span style="color: #800080; font-weight: bold;">$t</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #800080; font-weight: bold;">$x</span><span style="color: #000000; font-weight: bold;">=</span><span style="color: #800080; font-weight: bold;">$x</span><span style="color: #808080; font-weight: bold;">/</span><span style="color: #800000;">3</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">60</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">120</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">60</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span>&nbsp;<span style="color: #000000; font-weight: bold;">else</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800000;">3</span><span style="color: #808080; font-weight: bold;">*</span><span style="color: #800080; font-weight: bold;">$x</span>&nbsp;<br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br />koch&nbsp;<span style="color: #800000;">200</span>,&nbsp;<span style="color: #800000;">6</span>}}
{{Input|1=<span style="color: #a0a0a4;"># Koch curve</span><br /><br /><span style="color: #000080;">reset</span><br /><span style="color: #000080;">canvassize</span>&nbsp;<span style="color: #800000;">850</span>,&nbsp;<span style="color: #800000;">550</span><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">125</span>,&nbsp;<span style="color: #800000;">350</span><br /><span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #800080; font-weight: bold;">$t</span><span style="color: #5a64ff; font-weight: bold;">&gt;</span><span style="color: #800000;">0</span> &nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><span style="color: #000000; font-weight: bold;">=</span><span style="color: #800080; font-weight: bold;">$t</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #800080; font-weight: bold;">$x</span><span style="color: #000000; font-weight: bold;">=</span><span style="color: #800080; font-weight: bold;">$x</span><span style="color: #808080; font-weight: bold;">/</span><span style="color: #800000;">3</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">60</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">120</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">60</span><br />&nbsp;&nbsp;&nbsp;&nbsp;koch&nbsp;<span style="color: #800080; font-weight: bold;">$x</span>,&nbsp;<span style="color: #800080; font-weight: bold;">$t</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span>&nbsp;<span style="color: #000000; font-weight: bold;">else</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800000;">3</span><span style="color: #808080; font-weight: bold;">*</span><span style="color: #800080; font-weight: bold;">$x</span>&nbsp;<br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br />koch&nbsp;<span style="color: #800000;">200</span>,&nbsp;<span style="color: #800000;">6</span>}}
<translate>
 
<!--T:5-->
<!--T:5-->
Result:
Result:
Line 30: Line 32:


<!--T:9-->
<!--T:9-->
Logo script:</translate>
Logo script:
 
<!--T:20-->
{{Input|1=<span style="color: #a0a0a4;"># Sierpinski triangle</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;sierp&nbsp;<span style="color: #800080; font-weight: bold;">$l</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span>&nbsp;<span style="color: #800080; font-weight: bold;">$l</span>&nbsp;<span style="color: #5a64ff; font-weight: bold;">&gt;</span>&nbsp;<span style="color: #800000;">2</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">repeat</span>&nbsp;<span style="color: #800000;">3</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sierp&nbsp;<span style="color: #800080; font-weight: bold;">$l</span><span style="color: #808080; font-weight: bold;">/</span><span style="color: #800000;">2</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$l</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">120</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br /><br /><span style="color: #000080;">reset</span><br /><span style="color: #000080;">canvassize</span>&nbsp;<span style="color: #800000;">600</span>,&nbsp;<span style="color: #800000;">533</span><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">50</span>,&nbsp;<span style="color: #800000;">483</span><br /><span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br />sierp&nbsp;<span style="color: #800000;">500</span>}}
{{Input|1=<span style="color: #a0a0a4;"># Sierpinski triangle</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;sierp&nbsp;<span style="color: #800080; font-weight: bold;">$l</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span>&nbsp;<span style="color: #800080; font-weight: bold;">$l</span>&nbsp;<span style="color: #5a64ff; font-weight: bold;">&gt;</span>&nbsp;<span style="color: #800000;">2</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">repeat</span>&nbsp;<span style="color: #800000;">3</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sierp&nbsp;<span style="color: #800080; font-weight: bold;">$l</span><span style="color: #808080; font-weight: bold;">/</span><span style="color: #800000;">2</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$l</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">120</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br /><br /><span style="color: #000080;">reset</span><br /><span style="color: #000080;">canvassize</span>&nbsp;<span style="color: #800000;">600</span>,&nbsp;<span style="color: #800000;">533</span><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">50</span>,&nbsp;<span style="color: #800000;">483</span><br /><span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br />sierp&nbsp;<span style="color: #800000;">500</span>}}
<translate>
 
<!--T:10-->
<!--T:10-->
Result:
Result:
Line 45: Line 49:


<!--T:14-->
<!--T:14-->
Logo script:</translate>
Logo script:
 
<!--T:21-->
{{Input|1=<span style="color: #a0a0a4;"># Heighway dragon</span><br /><br /><span style="color: #000080;">reset</span><br /><span style="color: #000080;">canvassize</span>&nbsp;<span style="color: #800000;">500</span>,&nbsp;<span style="color: #800000;">500</span><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">320</span>,&nbsp;<span style="color: #800000;">400</span><br /><span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br /><span style="color: #800080; font-weight: bold;">$size</span>&nbsp;<span style="color: #000000; font-weight: bold;">=</span>&nbsp;<span style="color: #800000;">7</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;X&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span>&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #5a64ff; font-weight: bold;">&gt;</span><span style="color: #800000;">0</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">90</span><br />&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;Y&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span>&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #5a64ff; font-weight: bold;">&gt;</span><span style="color: #800000;">0</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br />&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br />&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br /><br /><span style="color: #000080;">pencolor</span>&nbsp;<span style="color: #800000;">0</span>,<span style="color: #800000;">255</span>,<span style="color: #800000;">0</span><br /><span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br />X&nbsp;<span style="color: #800000;">10</span><br /><span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">90</span><br /><span style="color: #000080;">pencolor</span>&nbsp;<span style="color: #800000;">255</span>,<span style="color: #800000;">0</span>,<span style="color: #800000;">0</span><br />Y&nbsp;<span style="color: #800000;">10</span><br /><span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br /><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">50</span>,<span style="color: #800000;">450</span>}}
{{Input|1=<span style="color: #a0a0a4;"># Heighway dragon</span><br /><br /><span style="color: #000080;">reset</span><br /><span style="color: #000080;">canvassize</span>&nbsp;<span style="color: #800000;">500</span>,&nbsp;<span style="color: #800000;">500</span><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">320</span>,&nbsp;<span style="color: #800000;">400</span><br /><span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br /><span style="color: #800080; font-weight: bold;">$size</span>&nbsp;<span style="color: #000000; font-weight: bold;">=</span>&nbsp;<span style="color: #800000;">7</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;X&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span>&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #5a64ff; font-weight: bold;">&gt;</span><span style="color: #800000;">0</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">90</span><br />&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br /><br /><span style="color: #00ff00; font-weight: bold;">learn</span>&nbsp;Y&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span>&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #5a64ff; font-weight: bold;">&gt;</span><span style="color: #800000;">0</span>&nbsp;<span style="color: #008000; font-weight: bold;">{</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br />&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">turnright</span>&nbsp;<span style="color: #800000;">90</span><br />&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;<span style="color: #800080; font-weight: bold;">$depth</span><span style="color: #808080; font-weight: bold;">-</span><span style="color: #800000;">1</span><br />&nbsp;&nbsp;<span style="color: #008000; font-weight: bold;">}</span><br /><span style="color: #008000; font-weight: bold;">}</span><br /><br /><span style="color: #000080;">pencolor</span>&nbsp;<span style="color: #800000;">0</span>,<span style="color: #800000;">255</span>,<span style="color: #800000;">0</span><br /><span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br />X&nbsp;<span style="color: #800000;">10</span><br /><span style="color: #000080;">turnleft</span>&nbsp;<span style="color: #800000;">90</span><br /><span style="color: #000080;">pencolor</span>&nbsp;<span style="color: #800000;">255</span>,<span style="color: #800000;">0</span>,<span style="color: #800000;">0</span><br />Y&nbsp;<span style="color: #800000;">10</span><br /><span style="color: #000080;">forward</span>&nbsp;<span style="color: #800080; font-weight: bold;">$size</span><br /><br /><span style="color: #000080;">go</span>&nbsp;<span style="color: #800000;">50</span>,<span style="color: #800000;">450</span>}}
<translate>
 
<!--T:15-->
<!--T:15-->
Result:
Result:

Latest revision as of 05:59, 5 September 2012

Other languages:

Home » Applications » Education » KTurtle » Examples

Tip
Script formatting results from the HTML export of KTurtle.
Note for translators
If you want to translate the scripts the best way is probably to create the script in KTurtle, export it as HTML, and insert the exported HTML in the respective Input templates. Alternatively, simply leave the scripts untranslated. A simpler solution using the syntaxhighlight tag is currently being investigated


Koch curve

This is a fractal curve. You can find more information about this at Wikipedia.

Logo script:

# Koch curve

reset
canvassize 850550
go 125350
turnright 90

learn koch $x$t {
  if $t>0  {
    $t=$t-1
    $x=$x/3
    koch $x$t
    turnleft 60
    koch $x$t
    turnright 120
    koch $x$t
    turnleft 60
    koch $x$t
  } else {
  forward 3*$x 
  }
}
koch 2006

Result:

Sierpinski Triangle

Another famous fractal is the Sierpinski triangle.

Logo script:

# Sierpinski triangle

learn sierp $l {
  if $l > 2 {
    repeat 3 {
      sierp $l/2
      forward $l
      turnleft 120
    }
  }
}

reset
canvassize 600533
go 50483
turnright 90
sierp 500

Result:

Heighway Dragon

Another famous fractal is the Heighway Dragon.

Logo script:

# Heighway dragon

reset
canvassize 500500
go 320400
turnright 90
$size = 7

learn X $depth {
  if $depth>0 {
    X $depth-1
    turnleft 90
    Y $depth-1
    forward $size
  }
}

learn Y $depth {
  if $depth>0 {
    forward $size
    X $depth-1
    turnright 90
    Y $depth-1
  }
}

pencolor 0,255,0
forward $size
10
turnleft 90
pencolor 255,0,0
10
forward $size

go 50,450

Result: