You are on page 1of 3

Code

from Week 2 Think. Create. Code.




Week 2 Subsection 1:

Example 1:
line(10,10,120,10);
strokeWeight(1);
line(10, 30, 120, 30);
strokeWeight(5);
line(10, 60, 120, 60);
strokeWeight(10);
line(10, 90, 120, 90);
strokeWeight(4);
line(10, 150, 120, 150);

Example 2:
strokeWeight(10);
line(40, 40, 140, 40);
strokeCap(SQUARE);
line(40, 90, 140, 90);
strokeCap(PROJECT);
line(40, 140, 140, 140);

Example 3:
strokeWeight(1);
ellipse(100,100,90,90);
strokeWeight(5);
ellipse(100,100,70,70);
strokeWeight(7);
ellipse(100,100,50,50);
strokeWeight(10);
ellipse(100,100,30,30);
strokeWeight(1);
ellipse(100,100,10,10);

Week 2 Subsection 2:

Example 1:
size(120,300);
int y = 20;
int distance = 10;
int h = 10;
rect(10,y,100,h);
y = y + distance + h;
h = h * 2;
rect(10,y,100,h);
y = y + distance + h;
h = h * 2;
rect(10,y,100,h);
y = y + distance + h;
h = h * 2;
rect(10,y,100,h);


Week 2 Subsection 3:
These programs are used throughout the videos and are often re-used with
minor changes to things like the size of the canvas. Ive split the second program
into two separate examples to show you what I mean by this.

Example 1:
size(200,200);
background(120,40,40);
rect(90,80,20,40);

Example 2a:
size(200,200);
background(120,40,40);
rect(width/2-20,height/2-20,20,40);

Example 2b:
size(300,300);
background(120,40,40);
rect(width/2-20,height/2-20,20,40);

Example 3:
size(200,200);
background(120,40,40);
rect(width/2-20,height/2-20,width/10,height/5);

Example 4:
size(200,200);
background(120,40,40);
int hwid=width/2;
int hhei=height/2;
int woffset=width/10;
int hoffset=height/5;
rect(hwid-(woffset/2),hhei-(hoffset/2),woffset,hoffset);

You might also like