Table of Contents

Ingram Chung's crazyDog.js

by Ingram

about my crazyDog.js

JUST CRAZY

The animation code is released under the GNU Lesser General Public License v2.1.

the code for my crazyDog.js

function setup() {
  createCanvas(1800, 780);
}
 
class BackgroundPattern {
 constructor (xpostion, ypostion)
  { this.x = xpostion;
    this.y = ypostion;
  }
  draw () { 
    fill(color(random(0,255),random(0,255),random(0,255)));
    rect(this.x, this.y, 10, 10);
    fill(color(random(0,255),random(0,255),random(0,255)));
    rect(this.x + 10, this.y, 10, 10)
  }
}
 
class Dog {
 constructor (xpostion, ypostion)
  { this.x = xpostion;
    this.y = ypostion;
  }
  draw () { 
    fill(color(random(0,255),random(0,255),random(0,255)));
  circle(this.x+60, this.y+150, 80);
  circle(this.x+340, this.y+150, 80);
  circle(this.x+60, this.y+150, 30);  
  circle(this.x+340, this.y+150, 30);
  circle(this.x+200, this.y+200, 250);
  circle(this.x+170, this.y+150, 40);
  circle(this.x+230, this.y+150, 40);
  circle(this.x+200, this.y+200, 30);
  circle(this.x+170, this.y+150, 15);
  circle(this.x+230, this.y+150, 15);
  line(this.x+200, this.y+215, this.x+200, this.y+240);
  line(this.x+230, this.y+270, this.x+200, this.y+240);
  line(this.x+170, this.y+270, this.x+200, this.y+240);
  fill(255,255,255)
    circle(this.positionx+50,200,60)
    circle(this.positionx+80,190,60)
    circle(this.positionx+100,180,60)
    circle(this.positionx+110,220,60)
    circle(this.positionx+120,220,60)
    circle(this.positionx+110,230,60)
    circle(this.positionx+100,200,60)
    circle(this.positionx+80,240,60)
    stroke(0,0,0)
  }
}
 
function backgroundPatternArray (n, y){
  let outputArray = [];
    for (let i = 0; i < n ; i++) {
        outputArray.push(new BackgroundPattern (10 + (i * 30),10 + y))
    }
    return outputArray
}
 
function dogArray (n){
  let outputArray = [];
    for (let i = 0; i < n ; i++) {
        outputArray.push(new Dog (Math.random()*800,Math.random()*800))
    }
    return outputArray
}
 
let myDogArray = dogArray(100);
console.log(myDogArray);
 
function draw() {
  //background(random(0,255),random(0,255),random(0,255)); 
    for(let i = 0; i < 100 ; i++){
      let myBackgroundPatternArray = backgroundPatternArray(300, 10 + (i* 20));
      for(let i = 0; i < myDogArray.length ; i++){ 
      myBackgroundPatternArray[i].draw()
    }
  }
  //let dog2 = new Dog (100, 100);
  //dog2.draw();
  for(let i = 0; i < myDogArray.length ; i++){
    myDogArray[i].draw()
  }
}