Drag the background!

Step 7. Program structure

P5 programs use the following structure to define what code runs once at startup, and what code runs every time step:

// Can define global variables and constants up here, outside both functions  

function setup() 		 
{
	// Instructions to be executed once, at start of run 
} 

function draw()
{
	// Instructions to be executed every time step 
}  

This is a P5 thing, not a JavaScript thing in general.

Note the chain brackets. These define the start and end of blocks of code.

We will now add some new code at certain locations within the structure.

The background is a program, showing the JavaScript graphics used on this site.
The globes light up when you log in.
 
Font:

Users retain ownership of user content.

Platforms      Stats      The name

Contact      Terms and conditions      Partners