Jdbrown – Project 10 – Magic

I took a rather simple approach to this project – none of the ideas I came up with was more interesting than this experiment that I made:

sketch

// Joshua Brown
// Jdbrown@andrew.cmu.edu
// Section C
// Project 10 - Landscape

// Joshua Brown
// Jdbrown@andrew.cmu.edu
// Section C
// Project 10 - Landscape

// Simple demonstration of the noise() function. 
// Change these for different effects:

var terrainSpeed = 0.0005;
var terrainDetail = 0.005;
var i;

function setup() {
    createCanvas(480, 480);
    frameRate(30);
}
 
function draw() {
    
    background(255);
    beginShape(); 
    fill(0, 100);

    for (var i = 0; i < width; i++) {
        var t = (i * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0, 1, 0, height);
        vertex(i, y + 200); 
    }

    for (var i = 0; i < width; i++) {
        fill (0);
        var t = (i * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0, -1, 0, height);
        vertex(i, y + 400); 
        fill(0, 10)
        noStroke();
        rect (i, y + 800, i, y + 100);
    }

    endShape();
    drawSun();
}

function drawSun() {
    // making the sun and its lines

    var S = second();
    var H = hour();
    var M = minute();

    //drawLines();

    push ();
    stroke (255);
    strokeWeight (2.5);
    translate (width, 0);
    rotate (radians (S * 6));
    fill (0, 0);
    arc (0, 0, 320, 320, radians (0), radians (45));
    arc (0, 0, 320, 320, radians (55), radians (100));
    arc (0, 0, 320, 320, radians (110), radians (155));
    arc (0, 0, 320, 320, radians (165), radians (210));
    arc (0, 0, 320, 320, radians (220), radians (265));
    arc (0, 0, 320, 320, radians (275), radians (310));
    arc (0, 0, 320, 320, radians (320), radians (350));

    fill (255, 100, 120);
    ellipse (0, 0, 200 + (H * 3), 200 + (H * 3));   // draws the sun
    fill (255);
    ellipse (0, 0, S + 75, S + 75);     // draws the white ball in the sun, growing every second
    pop ();

    push ();
    stroke (255);
    strokeWeight (1.5);
    translate (width, 0);
    rotate (radians (S * -6));
    fill (0, 0);
    arc (0, 0, 300, 300, radians (0), radians (45));
    arc (0, 0, 300, 300, radians (55), radians (100));
    arc (0, 0, 300, 300, radians (110), radians (155));
    arc (0, 0, 300, 300, radians (165), radians (210));
    arc (0, 0, 300, 300, radians (220), radians (265));
    arc (0, 0, 300, 300, radians (275), radians (310));
    arc (0, 0, 300, 300, radians (320), radians (350));
    fill (200, 180, 70);
    pop ();

    push ();
    stroke (255);
    strokeWeight (1);
    translate (width, 0);
    rotate (radians (S * 6));
    fill (0, 0);
    arc (0, 0, 280, 280, radians (0), radians (45));
    arc (0, 0, 280, 280, radians (55), radians (100));
    arc (0, 0, 280, 280, radians (110), radians (155));
    arc (0, 0, 280, 280, radians (165), radians (210));
    arc (0, 0, 280, 280, radians (220), radians (265));
    arc (0, 0, 280, 280, radians (275), radians (310));
    arc (0, 0, 280, 280, radians (320), radians (350));
    fill (200, 180, 70);
    pop ();
    
}

Leave a Reply