pen gold, 50 fd 150 rt 180, 75 lt 90, 100 rt 90, 50 rt 180, 150
You can draw a wide or narrow track with turns or wiggles
by using pen
, rt
, lt
,
and fd
:
pen gold, 50
uses a gold-colored pen that
draws a line 50 pixels wide.
fd 150
moves the turtle (drawing a line with
a pen) forward by 150 pixels.
rt 90
pivots the turtle, without moving,
right by 90 degrees.
rt 180, 75
turns the turtle 180 degrees
to the right, while tracing out a circle of radius 75.
lt 90, 100
turns the turtle 90 degrees
to the left, while tracing out a circle of radius 100.
The diagrams below can be used to help plan curves.
await loadscript '/lib/angles.cs', defer() jumpto 0, -25 label 'lt 90,50', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto -48, 25 plan -> css { turtleRotation: '-90deg' } label '50 pixels', fontSize: '80%' home() jumpto 25, 0 pen gold, 10 lt 90, 50
r = 100 pen silver, 2 for turn in [rt, lt] for d in [30..360] by 30 turn 30, r turn 90; fd 5 jump 0, 20 remember = direction() turnto 0 label d turnto remember jump 0, -20 bk 5; turn 270 jumpto r, 0 label 'rt', fontSize: '200%' fontFamily: 'Source Code Pro' jumpto -r, 0 label 'lt', fontSize: '200%' fontFamily: 'Source Code Pro' home() pen gray, 3 rt 48, r pen path fd 2; rt 150 for [1..3] fd 10; rt 120 fill gray home() pen gray, 3 lt 48, r pen path fd 2; rt 150 for [1..3] fd 10; rt 120 fill gray home()
await loadscript '/lib/angles.cs', defer() jumpto 0, -25 label 'rt 90,50', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto 48, 25 plan -> css { turtleRotation: 90 } label '50 pixels', fontSize: '80%' home() jumpto -25, 0 pen gold, 10 rt 90, 50
jumpto 0, -25 label 'lt 60,100', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto 30, 0 pen gold, 10 lt 60, 100
jumpto 0, -25 label 'lt 180,30', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto 30, 0 pen gold, 10 lt 180, 30
label 'rt 360,70', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto -70, 0 pen gold, 10 rt 360,70
jumpto 0, -25 label 'rt 180,30', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto -30, 0 pen gold, 10 rt 180, 30
jumpto 0, -25 label 'rt 60,100', fontSize: '120%' fontFamily: 'Source Code Pro' jumpto -30, 0 pen gold, 10 rt 60, 100