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 17:58] – 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() { | ||
| + | createCanvas(2800, | ||
| + | } | ||
| + | |||
| + | class Dog { | ||
| + | constructor (xposition, yposition, size, | ||
| + | { | ||
| + | this.xposition = xposition; | ||
| + | this.yposition = yposition; | ||
| + | this.dogSize = size; | ||
| + | this .dogColor = dColor; | ||
| + | this.dogPosition = dPosition; | ||
| + | } | ||
| + | draw () { | ||
| + | translate(this.positionX+50, | ||
| + | stroke(255, 0, 0); | ||
| + | fill(Math.random()*255, | ||
| + | for(let i = 0; i<1; i++){ | ||
| + | | ||
| + | fill(Math.random()*255, | ||
| + | | ||
| + | fill(Math.random()*255, | ||
| + | rect(this.xposition+100, | ||
| + | fill(Math.random()*255, | ||
| + | rect(this.xposition+160, | ||
| + | fill(Math.random()*255, | ||
| + | ellipse(this.xposition+190, | ||
| + | fill(Math.random()*255, | ||
| + | circle(this.xposition+83, | ||
| + | fill(Math.random()*255, | ||
| + | circle(this.xposition+99, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | class Background { | ||
| + | constructor (xposition, size, bColor, bposition, | ||
| + | { this.xposition = xposition; | ||
| + | this.backgroundSize = size; | ||
| + | this.backgroundColor = bColor; | ||
| + | this.backgroundposition = bposition; | ||
| + | | ||
| + | } | ||
| + | draw () { | ||
| + | | ||
| + | | ||
| + | rect(this.xposition+30, | ||
| + | fill(Math.random()*355, | ||
| + | rect(this.xposition+40, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function dogArray (n) { | ||
| + | let outputArray = []; | ||
| + | |||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray.push(new Dog (25 + (i*300), 20 ,200, 1000, 1000)) | ||
| + | } | ||
| + | |||
| + | |||
| + | 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) { | ||
| + | let outputArray = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray.push(new Background (20 + (i*300), | ||
| + | } | ||
| + | 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() { | ||
| + | background(220); | ||
| + | for(let i = 0; i < 10 ; i++){ | ||
| + | let myDogs = dogArray(10); | ||
| + | let mydogss= dogArrays(10); | ||
| + | let myBackgrounds = backgroundArray(10); | ||
| + | let myBackgroundss = backgroundArrays(10); | ||
| + | | ||
| + | myBackgrounds[i].draw() | ||
| + | } | ||
| + | | ||
| + | myBackgroundss[i].draw() | ||
| + | } | ||
| + | | ||
| + | myDogs[i].draw(); | ||
| + | } | ||
| + | for(let i = 0; i < mydogss.length ; i++){ | ||
| + | mydogss[i].draw(); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||