Table of Contents

Ron Liu's crazyDog.js

by Ron

about my crazyDog.js

My dog is not so good. I think I can do a better job, but there are some small rectangles that I think make my dog look special. Maybe my dog looks like a robot dog.

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);
   background(245, 203, 66);
}

function drawDog(){
for (let i = 0; i < n ; i++){
}
}

class BackgroundPattern {
  constructor (size, gColor, x,y)
  { this.backgroundSize = size;
    this.backgroundColor = gColor;
   this.x = x;
   this.y = y;
  }
  draw () {
    fill(color(this.backgroundColor))
    rect(this.x,this.y,20,20)
  }
}

class dog{
  constructor (dsize,dcolor,x,y)
  {this.dogsize=dsize;
   this.dogcolor=dcolor;
   this.x= x;
   this.y= y;
  }
  draw(){
fill(color("beige"));
fill(20,50,40);
rect(90,160,180,70);
rect(90,230,20,100);
  rect(250,230,20,100)
    fill(255,255,255)
    rect(200,230,20,100)
    rect(140,230,20,100)
    rect(140,160,130,70)
    fill(0,0,0)
    rect(150,240,10,5)
    rect(200,200,30,20)
    rect(250,170,20,20)
  rect(200,230,20,20)
    fill(255,255,255)
    square(115,200,22,6)
    rect(90,250,20,30)
    fill(81, 127, 153)
    square(70,80,80,8)
    fill(255,255,255)
    square(110,80,40,7)
    fill(0,0,0)
    circle(130,120,20)
    circle(90,120,20)
    fill(255,255,255)
    circle(130,120,10)
    circle(90,120,10)
    fill(151, 210, 247)
    rect(145,82,20,60)
    rect(55,82,20,60)
    fill(209, 245, 188)
    rect(140,190,20,8)
    rect(255,300,17,15)
    fill(0,0,0)
    rect(55,90,20,5)
     rect(120,120,20,2)
    fill(250, 147, 236)
    square(270,150,20,15)

  }
}

function backgroundPatternArray (number,x,y) {
    let outputArray = [];
    for (let i = 0; i < number ; i++) {
        outputArray.push(new BackgroundPattern (10,"blue",x + (i * 35),y))
    }
    return outputArray
}

 function Background2 (startingX, startingY, numberOfArrays, arrayLength) {
  for(let i = 0; i < numberOfArrays ; i++){
    let myBackground = backgroundPatternArray (arrayLength, startingX, startingY+(i*35));
    for(let i = 0; i < myBackground.length ; i++){
      myBackground[i].draw()
    }
  }
}

function draw() {
  Background2 (20,20,20,20);
  let dog2 = new dog (100, "black", 40, 156);
  dog2.draw();
}