line.script
This is a simulation of a triangular robot walking a paper plane while holding a pencil.
You can control the robot's movements by writing a JavaScript program, giving it instructions to draw whatever
you like!
Use the buttons in the top right bar (or the corresponding keyboard shortcuts) to play your program at different
paces, save it and restore previous saves.
Drawing functions:
Use these functions to control the robot.
forward(steps: number )
Move forward steps number of units of movement, tracing a line on paper if the pencil is down.
back(steps: number )
Move backwards steps number of units of movement, tracing a line on paper if the pencil is down.
right(degrees: number )
Turn clockwise degrees number of degrees, leaving no trace on the paper.
left(degrees: number )
Turn counterclockwise degrees number of degrees, leaving no trace on the paper.
up()
Pick the pencil tip up from the paper, so that it will leave no trace on it.
down()
Put the pencil tip down on the paper, to resume tracing every time the robot moves.
hide()
Make the robot invisible.
show()
Make the robot visible again.
Properties:
You can set these global properties to change the behavior and appearence of the simulation.
For example:
color: color string
Set the color of the pencil.
foreground: color string
Set the color of all the strokes on paper.
background: color string
Set the color of the paper. Set to "transparent" to revert to the default background.
speed: number
Set the robot's speed. Default speed is 100.
Utility functions:
Miscellaneous utilities to interact with the user and the like.
ask(question: string ): string
Show a prompt pop-up to the user, with question . Returns the text input by the user.
print(words...: string[] )
Print words (you can pass as many as you want) separated by spaces to the built-in output panel.
println(lines...: string[] )
Print lines (you can pass as many as you want) separated and followed by newline to the built-in output panel.
wait(seconds: number )
Wait for seconds (can be a decimal number) before the next instruction.
Value functions:
Use these functions to produce some useful values to pass into other functions.
random(min?: number , max?: number ): number
Generate a pseudo-random number between min (included) and max (excluded).
If only one argument is given, it will be interpreted as max : between 0 and max .
If no arguments are given, between 0 and 1.
rgb(red: number , green: number , blue: number , alpha?: number ):
color string
Generate a color value, given its red , green , and blue components (valid values
from 0 to 255 included) and an optional alpha value (opacity, from 0 to 1, included).
hsl(hue: number , saturation: number , lightness: number , alpha?:
number ): color string
Generate a color value, given its hue (in degrees, unconstrained), and saturation and
lightness components (valid values from 0 to 1 included) and an optional alpha value
(opacity, from 0
to 1, included).