Week1: Take Home Quiz

1. Where do you define the size of your canvas?
 
function setup() { 
createCanvas(400,400); 
} 
2. What numbers do you need to plug into fill() to get a bright turquoise? This Online Color Picker might help.

function setup() { 
createCanvas(100, 100); 
fill(51, 204, 204); 
ellipse(50, 50, 50, 50); 
} 
3. Re-create the following image with code:

https://alpha.editor.p5js.org/ellacyt/sketches/SyaMyAV9Z

 
function setup() { 
createCanvas(200, 200); 
} 
function draw(){ 
background(0,0,0); 

//red 
fill(217,35,20); 
rect(50,0,150,145); 

//blue 
fill(0,91,158); 
rect(0,151,42,49); 

//yellow fill(237,220,104); 
rect(185,181,16,20); 

//white 1 
fill(255,255,255); 
rect(0,0,42,61); 

//white 2 
fill(255,255,255); 
rect(0,73,42,72); 

//white 3 
fill(255,255,255); 
rect(49,151,129,49); 

//white 4 
fill(255,255,255); 
rect(184,151,17,20); 
} 

4. Re-create the following sketch:

Result:

http://alpha.editor.p5js.org/ellacyt/sketches/SJrTQR4cW

function setup() {
  createCanvas(200, 150);
  ellipseMode(CENTER);
}
function draw(){
  background(0,255,255);
  
  //line
  fill(255,0,0);
  stroke(255,0,0);
  strokeWeight(20);
  line(0,0,200,150);
  
  //ellipse
  noStroke();
  fill(0,255,0);
  ellipse(100,75,100,70);
  
  //square
  fill(0,0,255);
  rect(130,60,20,20);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top