Project-03-Dynamic-Drawing

sketch

var r = 255;
var g = 255;
var b = 255;

function setup() {
    createCanvas(600, 450, WEBGL);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
  background (220);
  fill(r,g,b);
  
  //to create that spin that is constant
  rotateX(frameCount*0.01);
  rotateY(frameCount*0.01);
  rotateZ(frameCount*0.01);
  
  //the cones that are in different positions and sizes change with the mouse
  cone(mouseX,mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  
  rotate(radians(90));
   cone(mouseX,mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  
   rotate(radians(90));
   cone(mouseX,mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  
  rotate(radians(90));
  cone(mouseX,mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (100,100);
  cone(mouseX, mouseY);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  translate (-100,-100);
  cone(mouseY, mouseX);
  
}

// colors change when mouse is pressed 

function mousePressed () {
  
  r -= 20;
  g -= 20;
  b -= 20;
  
}

This was alot of fun! Especially working with 3D objects!

Leave a Reply