project 07

sketch,js

/* Arden Wolf
Section B
ardenw@andrew.cmu.edu
Project 07
*/


var nPoints = 20;
var radius = 50;
var separation = 125;

function setup() {
    createCanvas(480, 480);
    frameRate(10);
}

function draw() {
    background(0);
    noStroke();
    //magenta
    fill (50);
    ellipse(125,120,100,100);
    fill (80);
    ellipse(125,120,80,80);
    fill (100);
    ellipse(125,120,50,50);
    fill (120);
    ellipse(125,120,30,30);


    //yellow
    fill (50);
    ellipse(377,240,100,100);
    fill (80);
    ellipse(377,240,80,80);
    fill (100);
    ellipse(377,240,50,50);
    fill (120);
    ellipse(377,240,30,30);


    //calls light beam
    LightBeam(); 
    //calls wiggle
     wiggle();
    //call square
     square();



}

function LightBeam() {
  for(var h = 0; h < 100; h++) //allows for thicker lines
    {
        //yellow
         push();
        translate(3 * separation, height / 2);
        for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta);
        var py = radius * sin(theta);
        stroke (255,255,0);
        line(-375, 238, px, py);
        }
        pop();

         push();
        translate(3 * separation, height / 2);
        for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta);
        var py = radius * sin(theta);
        stroke (255,255,0);
        line(0, 238, px, py);
        }
        pop();



        //magenta
         push();
        translate( separation, height / 4);
        for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta);
        var py = radius * sin(theta);
        stroke (255,0,255);
        line(360, 365, px, py);
        }
        pop();

         push();
        translate( separation, height / 4);
        for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta);
        var py = radius * sin(theta);
        stroke (255,0,255);
        line(360, 0, px, py);
        }
        pop();
    }

}
function wiggle(){
    stroke(4);

    //first
    fill(255,165,0);
    push();

    translate(separation, height/1.7);
    beginShape();
    for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta);
        var py = radius * sin(theta);
        vertex(px + random(-5, 5), py + random(-5, 5));
    }
    endShape(CLOSE);
    pop();

    //second
    fill(255,100,10);
    push();
    translate(separation, height/1.7);
    beginShape();
    for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta)/2;
        var py = radius * sin(theta)/2;
        vertex(px + random(-5, 5), py + random(-5, 5));
    }
    endShape(CLOSE);
    pop();

}

function square(){
//first
    fill(255,100,10);
    push();
    translate(2*separation+40, height/1.18);
    beginShape();
    for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta);
        var py = radius * sin(theta);
        vertex(px + random(-5, 5), py + random(-5, 5));
    }
    endShape(CLOSE);
    pop();

//second
    fill(255,165,0);
      push();
    translate(2*separation+40, height/1.18);
   beginShape();
    for (var i = 0; i < nPoints; i++) {
        var theta = map(i, mouseX, nPoints, mouseY, TWO_PI);
        var px = radius * cos(theta)/2;
        var py = radius * sin(theta)/2;
        vertex(px + random(-5, 5), py + random(-5, 5));
    }
    endShape(CLOSE);
    pop();
}

I was inspired by commits and stars in space and used the equations, mouseX and mouseY to make it interactive.

Leave a Reply