Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Daniel Ho's crazyDog.js ====== [[daniel-ho|by Daniel]] <HTML> <iframe src="https://editor.p5js.org/renick/present/CFQiYy25R" width=99% height=799px></iframe> </HTML> ===== about my crazyDog.js ===== This is my crazyDog.js. I've been working on it all semester. I think the hardest thing was that I need to make the loop function slower. For example, if I draw a dog, and loop it 10 times, it only need 5 second, but now i want it to draw ten dogs but use 10 second. The thing that im proud of is that I found out that if I let the website lag enough, I cant let the loop get slower(dont try it, it might let your computer crash....). 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 ===== <Code:js> 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() } } </Code> By: [[:daniel-ho|Daniel]] daniel-ho-generative.txt Last modified: 2021/06/29 01:30by renick Log In