Presentation is loading. Please wait.

Presentation is loading. Please wait.

20 minutes maximum exhibits

Similar presentations


Presentation on theme: "20 minutes maximum exhibits"— Presentation transcript:

1 20 minutes maximum exhibits

2 Variable Scope Variables can be declared anywhere in the sketch. The concept is called scope Global variables are accessible anywhere in the sketch. Local variables are limited to the code block in which they reside. Example: if() or for() function where a variable is declared for that block. Try example 6-7 and note that “x” is not accessible outside of draw() block. Advice on handling scope: Try to place variables where they are used because it is more efficient and less confusing. Some programmers, however, do like to see most of their variables at top. So it depends.

3 Then to keep from flashing is to use noLoop().
Open exercise 6_2circle. Then fill colors to dark random colors rather than w. Then to keep from flashing is to use noLoop(). void setup() { size(200,200); background(255); } void draw() { float w = 200; while (w > 0) { stroke(0); fill(w); //fill(random(0,255), random(0,255), random(0,255)); ellipse(width/2, height/2, w, w); w = w - 20;

4 Open A, I had made a typo, which led me to an even more crazy remix.
Exercise 6-3 Open B because it is visually interesting. Note how you can simply try different associations and formulas to see what happens. Open A, I had made a typo, which led me to an even more crazy remix. size(300,300); background(255); stroke(#0033ff); noFill(); int h = height/2; int i = 0; while(i <10) { ellipse(width/2, h, i*20, i+20); i++; h += 10 ; }

5 Nested Loops To make a nested loop, simply place a for statement inside another. size(480,120); background(0); noStroke(); for(int y = 0; y<=height; y += 40) { for(int x = 0; x<=width; x +=40) { fill(250, 100, 100 ); ellipse(x, y, 40,40); } //need better color scheme //I founding something interesting: inverted round corner size(480,120); background(0); noStroke(); for(int y = 0; y<=height; y += 40) { for(int x = 0; x<=width; x +=40) { fill(250, 100, 100 ); ellipse(x, y, 40,40); fill(6, 200, 100 ); ellipse(x+40, y, 40,40); fill(#ff9933); rectMode(CENTER); rect(x+40, y , 20, 20,-20);//inverted round corner line(x,y-5, x, y+5); strokeWeight(.5); stroke(#cc6600); line(x, 0, x, height); line(0, y, width, y); x += 40; strokeWeight(1); }

6 We probably won’t get to this, but take a look and see how it works
Fuzzy line size(300,200); background(0); int totalPts = 200; float steps = totalPts + 1; stroke(#ffffff); strokeWeight(2); for(int i = 1; i<steps; i++) { point((width/steps)* i , (height/2) + random(-5, 5)); } Funnel size(300,300); background(0); int totalPts = 300; float steps = totalPts + 1; stroke(255); float rand = 0; for(int i = 1; i<steps; i++) { point((width/steps)*i, (height/2) + random(-rand, rand)); rand += .1; } Wavy dots //RUN THIS ABOUT 10 TIMES. size(300,300); background(0); int totalPts = 300; float steps = totalPts + 1; stroke(255); strokeWeight(3); float rand = 0; for(int i = 1; i<steps; i++) { point((width/steps)*i, (height/2) + random(-rand, rand)); rand += random(-5, 5); }

7

8 Life is like a box of chocolates. You never know what you’re gonna get.
/*originally started out with creating a spiral, which would mainly happen by translating, then incrementing the x axis and rotate(.1) However i did a remix into this abstraction */ void setup(){ size(500,500); background(0); //frameRate(5 ); } void draw(){ noLoop(); translate(width/2, height/2); for (float i = 0; i <200; i++) { //strokeWeight(.25); fill(255,random(200), random(1,100), 15);//barely visible big circles rotate(180); ellipse(i, 0,100, 100); //unplanned triangle noStroke(); fill(255,random(200), random(1,100) ); triangle(i-5, 5, 10, 15, i+5, 8); }}

9

10 /* this came from funprogramming. Also see link below
size(500, 200); noStroke();stroke(0); background(23, 100, 240); // in rare cases, paint using yellow color for (int x=20; x<width-30; x=x+25) { for (int y = 20; y<height-30; y = y+25) { //if the random generated # is >90, fill yellow if (random(100) > 90) { fill(255, 255, 0); } //if the random is between , fill black else if(random(100) > 50) { fill(0); }else { noFill(); ellipse(x , y , 20, 20); /* this came from funprogramming. Also see link below */ /*This program is simply a grid, but it allows 3 different fill colors based on whether random # is between , then 50-89, or 0-49 The if() is like that grade program that we did in chap 5 */


Download ppt "20 minutes maximum exhibits"

Similar presentations


Ads by Google