0% found this document useful (0 votes)
482 views1 page

Pencil Code Reference Sheet

The document provides code examples for the pencilcode programming environment. It includes commands for drawing, movement, appearance, properties and output. It also lists various functions like tick, random, play and table. Finally, it provides a color chart listing HTML color names.

Uploaded by

Siji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
482 views1 page

Pencil Code Reference Sheet

The document provides code examples for the pencilcode programming environment. It includes commands for drawing, movement, appearance, properties and output. It also lists various functions like tick, random, play and table. Finally, it provides a color chart listing HTML color names.

Uploaded by

Siji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Reference — pencilcode.

net
Movement Drawing
fd 50 forward 50 pixels pen blue draw in blue
bk 10 backward 10 pixels pen red, 9 9 pixel wide red pen
rt 90 turn right 90 degrees pen null use no color
lt 120 turn left 120 degrees pen off pause use of the pen
rt 90, 50 do a 90° arc of radius 50 pen on use the pen again
home() go to the page center label 'X' draw the letter X
slide x, y slide right x and forward y dot green draw a green dot
moveto x, y go to x, y relative to home dot gold, 30 30 pixel gold circle
turnto 45 set direction to 45 (NE) pen path trace an invisible path
turnto obj point toward obj fill cyan fill traced path in cyan
speed 30 do 30 moves per second cg() clear graphics
Appearance Properties
ht() hide the turtle turtle name of the main turtle
st() show the turtle getxy() [x, y] position relative to home
scale 8 do everything 8x bigger direction() direction of turtle
wear yellow wear a yellow shell hidden() if the turtle is hidden
fadeOut() fade and hide the turtle touches(obj) if the turtle touches obj
remove() totally remove the turtle inside(window) if enclosed in the window
Output Objects
see obj debug the value of obj t = new Turtle make a new turtle
write 'hello' writes a line of HTML p = new Piano 88 make a new 88-key piano
p = write 'hm' saves an HTML element g = $('img') select all <img> as a set
p.html 'done' changes old text
append 'ok' text without a new line Other Functions
button 'go', adds a button with tick 5, -> fd 10 go 5 times per second
-> fd 10 an action click -> fd 10 go when clicked
read (n) -> adds a text input with random [3,5,7] return 3, 5, or 7
write n*n an action random 100 random [0..99]
t = table 3,5 adds a 3x5 <table> play 'ceg' play musical notes
t.cell(0, 0). selects the first cell of the $(window) the visible window
text 'aloha' table and sets its text $('p').eq(0) the first <p> element
ct() clear text $('#zed') the element with id="zed"

Colors
white gainsboro silver darkgray gray dimgray black

whitesmoke lightgray lightcoral rosybrown indianred red maroon

snow mistyrose salmon orangered chocolate brown darkred

seashell peachpuff tomato darkorange peru firebrick olive

linen bisque darksalmon orange goldenrod sienna darkolivegreen

oldlace antiquewhite coral gold limegreen saddlebrown darkgreen

floralwhite navajowhite lightsalmon darkkhaki lime darkgoldenrod green

cornsilk blanchedalmond sandybrown yellow mediumseagreen olivedrab forestgreen

ivory papayawhip burlywood yellowgreen springgreen seagreen darkslategray

beige moccasin tan chartreuse mediumspringgreen lightseagreen teal

lightyellow wheat khaki lawngreen aqua darkturquoise darkcyan

lightgoldenrodyellow lemonchiffon greenyellow darkseagreen cyan deepskyblue midnightblue

honeydew palegoldenrod lightgreen mediumaquamarine cadetblue steelblue navy

mintcream palegreen skyblue turquoise dodgerblue blue darkblue

azure aquamarine lightskyblue mediumturquoise lightslategray blueviolet mediumblue

lightcyan paleturquoise lightsteelblue cornflowerblue slategray darkorchid darkslateblue

aliceblue powderblue thistle mediumslateblue royalblue fuchsia indigo

ghostwhite lightblue plum mediumpurple slateblue magenta darkviolet

lavender pink violet orchid mediumorchid mediumvioletred purple

lavenderblush lightpink hotpink palevioletred deeppink crimson darkmagenta

You might also like