Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| brendan-hsu-generative [2021/06/20 18:12] – brendan.hsu | brendan-hsu-generative [2021/06/29 01:29] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======Brendan' | + | ======Brendan |
| + | |||
| + | [[brendan-hsu|by Brendan]] | ||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| + | |||
| + | |||
| + | ===== about my crazyDog.js ===== | ||
| + | |||
| + | 我覺得我的狗狗做得很好因為這個是我第一次做 | ||
| + | |||
| + | I think my dog is doing very well because this is my first time doing programming. | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| < | < | ||
| function setup() { | function setup() { | ||
| Line 22: | Line 37: | ||
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| for(let i = 0; i<1; i++){ | for(let i = 0; i<1; i++){ | ||
| - | | + | |
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| - | | + | |
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| - | rect(this.xposition+100, | + | rect(this.xposition+100, |
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| - | rect(this.xposition+160, | + | rect(this.xposition+160, |
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| - | ellipse(this.xposition+190, | + | ellipse(this.xposition+190, |
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| - | circle(this.xposition+83, | + | circle(this.xposition+83, |
| fill(Math.random()*255, | fill(Math.random()*255, | ||
| - | circle(this.xposition+99, | + | circle(this.xposition+99, |
| } | } | ||
| } | } | ||
| class Background { | class Background { | ||
| - | constructor (xposition, size, bColor, bposition) | + | constructor (xposition, size, bColor, bposition,yposition) |
| { this.xposition = xposition; | { this.xposition = xposition; | ||
| this.backgroundSize = size; | this.backgroundSize = size; | ||
| this.backgroundColor = bColor; | this.backgroundColor = bColor; | ||
| this.backgroundposition = bposition; | this.backgroundposition = bposition; | ||
| + | | ||
| } | } | ||
| draw () { | draw () { | ||
| | | ||
| | | ||
| - | rect(this.xposition+30, | + | rect(this.xposition+30, |
| fill(Math.random()*355, | fill(Math.random()*355, | ||
| - | rect(this.xposition+40, | + | rect(this.xposition+40, |
| } | } | ||
| } | } | ||
| Line 56: | Line 72: | ||
| function dogArray (n) { | function dogArray (n) { | ||
| let outputArray = []; | let outputArray = []; | ||
| + | |||
| for (let i = 0; i < n ; i++) { | for (let i = 0; i < n ; i++) { | ||
| - | outputArray.push(new Dog (20 + (i*300), | + | outputArray.push(new Dog (25 + (i*300), |
| } | } | ||
| + | |||
| + | |||
| return outputArray | return outputArray | ||
| } | } | ||
| + | function dogArrays (n) { | ||
| + | let outputArray2 = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray2.push(new Dog (25 + (i*300), 300 ,200, 1000, 1000)) | ||
| + | } | ||
| + | return outputArray2 | ||
| + | } | ||
| + | |||
| function backgroundArray (n) { | function backgroundArray (n) { | ||
| let outputArray = []; | let outputArray = []; | ||
| for (let i = 0; i < n ; i++) { | for (let i = 0; i < n ; i++) { | ||
| - | outputArray.push(new Background (20 + (i*300), | + | outputArray.push(new Background (20 + (i*300), |
| } | } | ||
| return outputArray | return outputArray | ||
| } | } | ||
| + | |||
| + | function backgroundArrays (n) { | ||
| + | let outputArrays = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArrays.push(new Background (20 + (i*300), | ||
| + | } | ||
| + | return outputArrays | ||
| + | } | ||
| + | |||
| + | |||
| function draw() { | function draw() { | ||
| background(220); | background(220); | ||
| for(let i = 0; i < 10 ; i++){ | for(let i = 0; i < 10 ; i++){ | ||
| let myDogs = dogArray(10); | let myDogs = dogArray(10); | ||
| + | let mydogss= dogArrays(10); | ||
| let myBackgrounds = backgroundArray(10); | let myBackgrounds = backgroundArray(10); | ||
| + | let myBackgroundss = backgroundArrays(10); | ||
| | | ||
| myBackgrounds[i].draw() | myBackgrounds[i].draw() | ||
| + | } | ||
| + | | ||
| + | myBackgroundss[i].draw() | ||
| } | } | ||
| | | ||
| myDogs[i].draw(); | myDogs[i].draw(); | ||
| + | } | ||
| + | for(let i = 0; i < mydogss.length ; i++){ | ||
| + | mydogss[i].draw(); | ||
| } | } | ||
| } | } | ||
| } | } | ||
| </ | </ | ||