Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| yuna-wu-generative [2021/06/20 18:08] – yuna.wu | yuna-wu-generative [2021/06/29 01:47] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Yuna's crazyDog.js ====== | + | ====== Yuna Wu's crazyDog.js ====== |
| + | By: | ||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| + | |||
| + | ===== about my crazyDog.js ===== | ||
| + | |||
| + | This is my code. I have been working on it a long time. I think programing is very hard to me, but in this code the hardest one is the animation. I'm proud of my code, because I have been working on my code the whole semester and I have try so hard to do it. I hope everyone will like my code!!! | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| < | < | ||
| - | </let x, y; | + | let x, y; |
| function setup() { | function setup() { | ||
| Line 11: | Line 22: | ||
| x = width / 2; | x = width / 2; | ||
| y = height / 2; | y = height / 2; | ||
| - | | + | //noLoop(); |
| | | ||
| } | } | ||
| Line 67: | Line 78: | ||
| this.positionY = startingY; | this.positionY = startingY; | ||
| } | } | ||
| - | draw () { | + | draw (bodyColor, |
| //dog | //dog | ||
| for (let i = 0; i < 1; i++){ | for (let i = 0; i < 1; i++){ | ||
| Line 74: | Line 85: | ||
| strokeWeight(2); | strokeWeight(2); | ||
| stroke(0); | stroke(0); | ||
| - | let myRandoms = [Math.random()*r, | + | //let myRandoms = [Math.random()*r, |
| - | fill(myRandoms[0], | + | |
| + | fill(bodyColor); | ||
| //front left side feet | //front left side feet | ||
| rect(this.positionX + 60, this.positionY+298, | rect(this.positionX + 60, this.positionY+298, | ||
| Line 95: | Line 107: | ||
| circle(this.positionX + 50, this.positionY+253, | circle(this.positionX + 50, this.positionY+253, | ||
| //Left side ear | //Left side ear | ||
| + | fill(earColor); | ||
| circle(this.positionX + 25, this.positionY+236, | circle(this.positionX + 25, this.positionY+236, | ||
| - | fill(Math.random()*r, Math.random()*r, Math.random()*r) | + | fill(earColor.map(x => x*3)); |
| + | |||
| + | // | ||
| circle(this.positionX + 25, this.positionY + 236, 10); | circle(this.positionX + 25, this.positionY + 236, 10); | ||
| //Right side ear | //Right side ear | ||
| - | fill(myRandoms[0], | + | |
| + | //fill(myRandoms[0], | ||
| circle(this.positionX + 65, | circle(this.positionX + 65, | ||
| - | | + | |
| + | |||
| + | // | ||
| circle(this.positionX + 65, this.positionY+229, | circle(this.positionX + 65, this.positionY+229, | ||
| } | } | ||
| Line 109: | Line 127: | ||
| fill(0) | fill(0) | ||
| //Left eyes(black) | //Left eyes(black) | ||
| - | circle(this.positionX + 40, this.positionY+253, | + | circle(this.positionX + 40, this.positionY+253, |
| //Right eyes(black) | //Right eyes(black) | ||
| - | circle(this.positionX + 60, this.positionY+253, | + | circle(this.positionX + 60, this.positionY+253, |
| fill(255) | fill(255) | ||
| //Left eyes(white) | //Left eyes(white) | ||
| - | circle(this.positionX + 40, this.positionY+253, | + | circle(this.positionX + 40, this.positionY+253, |
| //Right eyes(white) | //Right eyes(white) | ||
| - | circle(this.positionX + 60, this.positionY+253, | + | circle(this.positionX + 60, this.positionY+253, |
| } | } | ||
| } | } | ||
| Line 181: | Line 199: | ||
| let myClouds = cloudArray(114); | let myClouds = cloudArray(114); | ||
| + | function randomColorArray(n) { | ||
| + | let output = []; | ||
| + | for (let i = 0; i < n; i++){ | ||
| + | output.push([Math.floor(255* Math.random()), | ||
| + | } | ||
| + | return output | ||
| + | } | ||
| + | |||
| + | function randomNumberArray(n, | ||
| + | let output = []; | ||
| + | for (let i = 0; i < n; i++){ | ||
| + | output.push(max * Math.random()) | ||
| + | } | ||
| + | return output | ||
| + | } | ||
| + | |||
| + | let dogColors = randomColorArray(12); | ||
| + | |||
| + | let dogEyeSizes1 = randomNumberArray(12, | ||
| + | let dogEyeSizes2 = randomNumberArray(12, | ||
| function draw() { | function draw() { | ||
| Line 197: | Line 235: | ||
| y = -240 + (height * (1/2)) + (Math.sin(frameCount/ | y = -240 + (height * (1/2)) + (Math.sin(frameCount/ | ||
| let myDogs = dogArray(12, | let myDogs = dogArray(12, | ||
| + | |||
| for(let i = 0; i < myDogs.length ; i++){ | for(let i = 0; i < myDogs.length ; i++){ | ||
| - | myDogs[i].draw() | + | myDogs[i].draw((dogColors[i]), |
| } | } | ||
| | | ||
| Line 206: | Line 245: | ||
| } | } | ||
| - | > | + | |
| + | </Code> | ||