Hour of Code
undefined

All the code we have been writing so far is Javascript code! Javascript is the #1 most used programming language in the world. It is the only language that works in web browsers.

While the code we are writing is Javascript a large portion of the code has been written for you. For example, all the shape functions you have been using so far were written by someone else in what is called a "library."

library A collection of code written by someone else.

The library is called p5.js which stands for Processing version 5 Javascript edition, or p5js for short. The creators of p5js have also created documentation and guides covering all the different functions you can use and how to use them!

p5js.org/reference

Here are a few of the functions taken from the documentation

Shapes

rect(x, y, w, h) draw a rectangle

ellipse(x, y, w, h) draw a circle or oval

triangle(x1, y1, x2, y2, x3, y3) draw a triangle

line(x1, y1, x2, y2) draw a line

point(x, y) draw a single dot

arc(x, y, w, h, start, stop) draw an arc shape

bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2) draw a bendy line

quad(x1, y1, x2, y2, x3, y3, x4, y4) draw a square by controlling each corner position

Colors

background(r, g, b) Set the background color

fill(r, g, b) Set the fill color for shapes

noFill() Turn off fill for shapes

stroke(r, g, b) Set the outline color for shapes

strokeWeight(thickness) Change the thickness of lines and outlines

noStroke()Turn off outlines for shapes