daniel-ho-generative

This is an old revision of the document!


Daniel Ho's crazyDog.js

This is my crazyDog.js. I've been working on it all semester. The hardest thing was making the animation look good. I'm proud of it because I've never said that I am proud of it. The code for my artwork is below.


**function setup() {
  createCanvas(1800,780);
  background(0)
}
 
 
 
function backgroundpatterns(x,y,bgColor){
  for(let i = 0; i<174;i++){
    fill(bgColor)
ellipse(x,y,10)
rect(x-3,y-3,5)
    x = x + 10
  }
}
 
function backgroundpatterns2(x,y,bgColor){
  for(let i = 0;i<60;i++){
    fill(bgColor)
    backgroundpatterns(x,y,bgColor)
    y = y+10
  }
}
 
class dog {
  constructor(x1,y1,num){
    this.positionx = x1
    this.fat1 = num
    this.positiony = y1
  }
draw(){
  fill(color(random(0,255),random(0,255),random(0,255)))
  ellipse(65+this.positionx,90+this.positiony,50+this.fat1,50+this.fat1);
  square(75+this.positionx,34+this.positiony,10+this.fat1);
  square(35+this.positionx,34+this.positiony,10+this.fat1);
  square(40+this.positionx,40+this.positiony,40+this.fat1);
  ellipse(75+this.positionx,50+this.positiony,5+this.fat1);
  ellipse(45+this.positionx,50+this.positiony,5+this.fat1);
line(45+this.positionx,60+this.positiony,50+this.positionx,65+this.positiony);
line(50+this.positionx,65+this.positiony,70+this.positionx,65+this.positiony);
line(70+this.positionx,65+this.positiony,75+this.positionx,60+this.positiony);
  ellipse(56+this.positionx,115+this.positiony,10+this.fat1,10+this.fat1);
  ellipse(80+this.positionx,110+this.positiony,10+this.fat1,10+this.fat1);
  triangle(50+this.positionx, 40+this.positiony, 60+this.positionx, 10+this.positiony, 70+this.positionx, 40+this.positiony);}
}
 
function loopdog(x) {
   let outputarray = [];
  for(let i = 0;i<x;i++){
 outputarray.push(new dog(random(0,1700),275,0 + (random(0,30) *i)))
  }
  //console.log(outputarray)
return outputarray
}
 
//function loopbackground(y){
  //let outputarray2 = [];
  //for(let)
//}
 
let redraw = 0;
 
function drawBackground (){
  if (redraw == 0) {
  backgroundpatterns2(20, 100, ([255*Math.random(),255*Math.random(),255*Math.random()]));
    redraw = 1
}
}
 
function draw() {
  drawBackground();
  //let background3 = new background(10,10)
  //background3.draw()
  let mydog = loopdog(10);
for(let i = 0; i < mydog.length ; i++){
   mydog[i].draw()
  }
 
}** 


By: Daniel

  • daniel-ho-generative.1624802955.txt.gz
  • Last modified: 2021/06/27 07:09
  • by sharon.chou