Michal Luria – Project 03 – Dynamic Drawing

mluria-project03

/*  Submitted by: Michal Luria
	Section A: 9:00AM - 10:20AM
	mluria@andrew.cmu.edu
	Assignment-03-A
*/

var space = 130; //space between squares 

function setup() {
    createCanvas(640, 480);
}
 
function draw() {
 
    noStroke();
    
    //pink square location determined by blue square
    var pinkSqX = width - mouseX; 
    var pinkSqY = height - mouseY;

    //map mouse movement to background range
    var bg = map(mouseY, 0, height, 150, 255);

    //map distance from center to square size
    var distCenter = dist(mouseX, mouseY, width/2, height/2);
    var sqSize = map(distCenter, 0, 300, 50, 400);
    
    background(bg);
    rectMode(CENTER);

    //top square
    fill("LightBlue");
    rect(mouseX, mouseY, sqSize, sqSize); 

    //bottom square
    fill("LightPink");
    rect(pinkSqX, pinkSqY, sqSize, sqSize);

    rectMode(CORNER);
    //top rect
    fill("DarkBlue");
    rect(0, 30, mouseX - space, 200);  

    fill("DeepPink");
    //bottom rect
    rect(pinkSqX + space, 250, mouseX - space, 200); 

}

1 thought on “Michal Luria – Project 03 – Dynamic Drawing”

  1. This time when creating the project, I enjoyed it because it was different than previous ones.
    In previous projects, I had something in mind in advance. This current project allowed me to think differently:
    Starting off with one element I wanted to control (the light blue square), I added one element at a time to the drawing,
    including new shapes, colors, sizes and angles. I liked how this work evolved one step after another, until forming a fully dynamic drawing.

Leave a Reply