yinjiet-project-06

sketch

//Yinjie Tian
//Section B
//yinjiet@andrew.cmu.edu
//Assignment 06

var x = []; 
var y = [];
var dx = []; 
var dy = []; 
var col = []; 

function setup() { 
    createCanvas(480, 480);
    angleMode(DEGREES);
    for (i = 0; i < 100; i++) { 
        x[i] = random(width);
        y[i] = random(height);
        dx[i] = random(-5, 5);
        dy[i] = random(-5, 5);
        col[i] = color(random(255), random(255), random(255));
    }
    frameRate(5);
}


function draw() {
 
    background(80, 200, 100);
 
 //bubbles at the background   
    noStroke();
    for (i = 0; i < 100; i++) {  // for each rectangle ...
        fill(col[i]);
        ellipse(x[i], y[i], 10, 10);
        x[i] += dx[i];
        y[i] += dy[i];
        
        if (x[i] > width) x[i] = 0;        //horizontally
        else if (x[i] < 0) x[i] = width;
        if (y[i] > height) y[i] = 0;       //vertically
        else if (y[i] < 0) y[i] = height;
    }

        var h = hour();
        var m = minute();
        var s = second(); 

//clock bubbles
    push();
    noStroke();
    fill(200, 200, s * 5);
    translate(width/2,height/2);
    rotate(s * (360/60));
    
    ellipse(200, 0, 60, 60);
    line()

    pop();
    
    push();
    noStroke();
    fill(200, m * 5, 200);
    translate(width/2,height/2);
    rotate(m*(360/60));
    
    ellipse(60, 0, 40, 40);
    pop();
    
    push();
    noStroke();
    fill(h * 25, 200, 200);
    translate(width/2,height/2);
    rotate(h*(360/12));
    
    ellipse(100, 0, 20, 20);
    pop();

//center point
    strokeWeight(4);
    stroke(0)
    line(width / 2 - 25, height / 2, width / 2 + 25, height / 2);
    line(width / 2, height / 2 - 25, width / 2, height / 2 + 25);
    fill(255, 0, 0);
    ellipse(width/2, height/2, 10, 10); 

}

The background is a bunch of randomly moving rectangle with random colors. A cross with a red dot representing the center for the clock. Three bubbles with constantly changing colors based on time orbiting around the cross indicates the time. Second is the largest and furthers bubble and hour is the smallest and closest bubble.

 

Leave a Reply