1 / 9

s etup() and draw() functions

s etup() and draw() functions. Week 3. A block of code. A block of code is any code enclosed with curly brackets { } A block of code can be nested { { } }. Setup(). It can be used to define the base sketch setup, like its size, its mode For example void setup() {

danyl
Download Presentation

s etup() and draw() functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. setup() and draw()functions Week 3

  2. A block of code • A block of code is any code enclosed with curly brackets { } • A block of code can be nested { { } }

  3. Setup() • It can be used to define the base sketch setup, like its size, its mode • For example void setup() { step 1a step 1b } Do once

  4. draw() • It can be used to define the base sketch setup, like its size, its mode • For example void draw() { step 2a step 2b } Loop over and over

  5. example1Background in setup() void setup(){ size(200,200); background(255); } void draw(){ stroke(256,0,128); fill(255,126,0); rectMode(CENTER); rect(mouseX, mouseY, 100,100); } Size and background are set once Loops continualy until you close the sketch window

  6. Example2background in draw() void setup(){ size(200,200); } void draw(){ background(255); //background is reset before each rect drawing stroke(256,0,128); fill(255,126,0); rectMode(CENTER); rect(mouseX, mouseY, 100,100); }

  7. Example 3noLoop() void setup(){ size(200,200); background(255); noLoop(); // this meeans that the draw function gets called once only. } void draw(){ stroke(256,0,128); fill(255,126,0); rectMode(CENTER); rect(mouseX, mouseY, 100,100); }

  8. Example 4loop() void setup(){ size(200,200); background(255); loop(); } void draw(){ stroke(256,0,128); fill(255,126,0); rectMode(CENTER); rect(mouseX, mouseY, 100,100); }

More Related