====== Sophie Yen's crazyDog.js ======
by [[:sophie-yen|Sophie]]
===== about my crazyDog.js =====
This is my crazyDog.js. I've been working on it all semester. For me, the hardest thing was to make all the stars. I work on the stars for many days and It's very complicated. I'm proud of it because I think when I'm finished with the stars, the stars all look very well. The code for my artwork is below.
The animation code is released under the [[https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html|GNU Lesser General Public License v2.1]].
===== the code for my crazyDog.js =====
var stars = [];
function setup() {
createCanvas(1800, 780);
for (var i = 0; i < 1000; i++) {
stars[i] = new Star();
}
}
class Dog {
constructor (xposition, size, hColor, eColor)
{ this.xposition = xposition;
this.faceSize = size;
this.hatColor = hColor;
this.eyeColor = eColor;
}
draw () {
//ears
fill(color("beige"));
circle(this.xposition+40, 420, 25);
circle(this.xposition+80, 420, 25);
//neck
fill(color("beige"));
rect(this.xposition+60, 455, 40, 20);
//face
fill(color("beige"));
circle(this.xposition+60,450,70);
//eye
fill(color(this.eyeColor));
ellipse(this.xposition+45,440,15,15);
ellipse(this.xposition+75,440,15,15);
//hat
fill(color(this.hatColor));
rect(this.xposition+23,405, 75, 20);
rect(this.xposition+40, 367, 38, 38);
//hat decorate
fill(250, 245, 107);
rect(this.xposition+23,411, 75, 5);
//mouth
fill(color("red"));
circle(this.xposition+60, 470, 20);
//nose
fill(145, 57, 57);
ellipse(this.xposition+60, 452, 20, 10);
//blush
fill('#fae');
circle(this.xposition+38, 458, 13);
circle(this.xposition+80, 458, 13);
//legs
fill(color("beige"));
ellipse(this.xposition+110, 500, 10, 40);
ellipse(this.xposition+130, 500, 10, 40);
//tails
fill(color("beige"));
ellipse(this.xposition+140, 460, 10, 40);
//body
fill(color("beige"));
circle(this.xposition+116, 480, 60);
//stage
fill(255,255,255);
rect(30, 520, 2000, 60);
//moon
fill(250, 237, 55);
circle(80, 270, 80);
fill(0,0,0);
circle(100, 260, 80);
//star
fill(250, 237, 55);
beginShape();
//vertex(30, 40);
//vertex(50, 40);
//vertex(60, 20);
//vertex(70, 40);
//vertex(90, 40);
//vertex(70, 60);
vertex(90, 90);
vertex(60, 75);
vertex(50, 75);
vertex(60, 75);
endShape(CLOSE);
}
}
//class star//
class Star {
constructor() {
this.x = random(width);
this.y = random(height);
this.size = random(0.25, 3);
this.t = random(TAU);
}
draw() {
this.t += 0.1;
var scale = this.size + sin(this.t) * 2;
noStroke();
ellipse(this.x, this.y, scale, scale);
}
}
function DogArray (n) {
let outputArray = [];
for (let i = 0; i < n ; i++) {
outputArray.push(new Dog (20 + (i*120),100, "blue", "black"))
}
return outputArray
}
let myDog = DogArray(15);
//console.log(myFaces);
function draw() {
background(0, 0, 0);
for (var i = 0; i < stars.length; i++) {
stars[i].draw();
}
let dog2 = new Dog (200,100, "red", "blue");
//dog2.draw();
for(let i = 0; i < myDog.length ; i++){
myDog[i].draw()
}
}