Unit 3 – LA 2.2

Exersice 1:

var colors = ['#4F000B', '#720026', '#CE4257', '#FF7F51', '#FF9B54']
var color1, color2;
function setup() {
  createCanvas(400, 200);
  color1 = colors[floor(random(0, colors.length))];
  color2 = colors[floor(random(0, colors.length))];
  color3 = colors[floor(random(0, colors.length))];
  color4 = colors[floor(random(0, colors.length))];
}

function draw() {
  background(0);
  
  stroke('#ffffff');
  
  fill(color1);
  rect(80, 55, 90, 90);
  
  fill(color2);
  ellipse(275, 100, 90, 90);
  
  fill(color3);
  ellipse(40, 40, 20, 20);
  ellipse(360, 40, 20, 20);
  ellipse(40, 160, 20, 20);
  ellipse(360, 160, 20, 20);
  
  fill(color4);
  rect(30, 60, 20, 80);
  rect(350, 60, 20, 80);
  rect(60, 30, 280, 20);
  rect(60, 150, 280, 20)
  
}

https://editor.p5js.org/BrainyZebra5/full/xXBOXlief

Exercise 2:

var sentence;
var phrase = ['An alien of some sort will be appearing to you shortly', 'Fortune not found? Abort, Retry, Ignore.', 'You love Chinese food.', 'If a turtle doesn’t have a shell, is it naked or homeless?', 'Ask your mom instead of a cookie', 'Hard work pays off in the future. Laziness pays off now.', 'Some men dream of fortunes, others dream of cookies.', 'A fanatic is one who can not change his mind, and will not change the subject.', 'A cynic is only a frustrated optimist.', 'A foolish man listens to his heart. A wise man listens to cookies.'];
function setup() {
  sentence = phrase[floor(random(0, phrase.length))];
  noLoop();
}

function draw() {
  background(220);
  console.log(sentence);
}

https://editor.p5js.org/BrainyZebra5/full/0_0b950wM