Coding Art by Mathias Funk & Yu Zhang

Coding Art by Mathias Funk & Yu Zhang

Author:Mathias Funk & Yu Zhang
Language: eng
Format: epub
ISBN: 9781484297803
Publisher: Apress


In this example (Figure 5-1), we use the keyboard to switch between shapes and colors. This is only a simple example. You can use the keyboard to switch between different functions controlling many things or create a switchable demo of all examples in this book. As a final example for “backstaging,” let’s make a sketch that uses the keyboard to reset.

Figure 5-1 Example of how we can reset the canvas after drawing frame over frame

USE THE KEYBOARD TO RESET THE VISUAL OUTPUT

void setup() {

size(400, 400);

background(0); noStroke(); rectMode(CENTER);

}

void draw() {

fill(40 + 20 * noise(0.8 - frameCount/2000.), 155, noise(frameCount/100.) * 255, random(10, 200));

rect(width * noise(0.2 + frameCount/100.), height * noise(0.3 + frameCount/200.), 100, 100);

}

void keyPressed(){

background(0);

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.