setup()

Initializes the canvas

Example

def setup():
 background("grey")

def draw():
  fill(255,79,132)
  circle(mouseX,mouseY,100)

Syntax

setup()

Description

The setup() function is called only once at the beginning of the program. Its purpose is to set up the initial environment of the program, such as canvas size, background color, to load media such as images and fonts as the program starts and any other initial values that the program needs.

The setup() function takes no arguments, and must be defined in the program before the draw() function.

Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!

We'd love to hear your Feedback/Comments here.

Last updated