View on GitHub

idmd

Bush School Interactive Digital Media Design Course

Bush School IDMD Spring Semester 2021

Re-Introduction

Homework Expectations

Learning Objectives

Lessons

Exercises

1 Dot Drawing


function setup() {
  createCanvas(500, 500);
  background(255, 0, 0);
}

function draw() {
  ellipse(mouseX, mouseY, 25, 25);
}

2 Line Drawing

function setup() {
  createCanvas(500, 500);
  background(0, 0, 255);
}

function draw() {
  if(mouseIsPressed) {
    stroke(255, 255, 255);
    line(150, 150, mouseX, mouseY);
  }
}

3 Growing Ellipse

var x = 250;
var y = 250;
var w = 50;

function setup() {
  createCanvas(500, 500);
  background(255);
  noStroke();
}

function draw() {
  background(255);
  fill(120);
  ellipse(x, y, w, w);
  distance = dist(x, y, mouseX, mouseY);
  if (distance < w / 2) {
    w += 1; 
  } else {
    w = 50;  
  }
}

4 React to Sound Volume

var mic;
var vol = 0;
var xMax = 0;

function setup() {
  createCanvas(600, 600);

  // create and start audio input
  mic = new p5.AudioIn();
  mic.start();
}

function draw() {
  background(200);

  // get the overall volume (between 0 and 1.0)
  var vol = mic.getLevel();

  // add a call to the ease function here to smooth the volume variable
  // it should be of the form vol = vol + ease(......)

  // map vol from range 0 to 1 to range 0, 600
  var xVol = map(vol, 0, 1, 0, 600);

  // let x either be the value of xVol or stay as x, whichever is currently greater
  xMax = max(xMax, xVol); 

  // map volume to x coordinate
  var xVol = map(vol, 0, 1, 0, 600);
  // let xMax either be the value of xVol or stay as x, whichever is currently greater
  xMax = max(xMax, xVol); 

  // Draw ellipses for both instantaneous volume and Max volume
  fill(0, 0, 255);
  ellipse(xVol, 200, 50, 50);
  fill(255, 0, 0);
  ellipse(xMax, 400, 50, 50);
}

function ease(target, current, ease) {
  return (target-current)/ease;
}


5 REQUIRED: Interactive Monster Project - Follow Specifications as noted

6 OPTIONAL: Add a Reset Button

Resources

Debrief

Homework