Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| howard-lee-generative [2021/06/20 20:06] – howard.lee | howard-lee-generative [2021/06/29 01:40] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | =====Rex | + | =====Rex |
| + | |||
| + | [[howard-lee|by Rex Lee]] | ||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| - | < | ||
| - | </ | ||
| + | ===== about my crazyDog.js ===== | ||
| + | What was difficult for you? I just don't know function really well. | ||
| + | What are you proud of? I guess it will be many dogs. | ||
| + | What did you learn? I learn about classes patterns. | ||
| + | How do you feel about this? I feel good after I made some progress. | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| + | < | ||
| + | |||
| + | function setup() { | ||
| + | createCanvas(2000, | ||
| + | noLoop(); | ||
| + | } | ||
| + | |||
| + | class BackgroundPattern { | ||
| + | constructor (xposition, yposition, size, pColor ) | ||
| + | { this.xposition = xposition; | ||
| + | this.yposition = yposition; | ||
| + | this.size = size; | ||
| + | this.patternColor = pColor; | ||
| + | |||
| + | } | ||
| + | draw () { | ||
| + | fill(this.patternColor); | ||
| + | rect(this.xposition, | ||
| + | fill(227, 94, 84); | ||
| + | rect(this.xposition + 10, this.yposition + 10, this.size/ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function patternRow (n, xposition, yposition) { | ||
| + | let outputArray = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray.push(new BackgroundPattern (xposition + (i*105), yposition, 100," | ||
| + | } | ||
| + | return outputArray | ||
| + | } | ||
| + | |||
| + | class Dog { | ||
| + | constructor (xposition, | ||
| + | { this.xposition = xposition; | ||
| + | this.yposition = yposition; | ||
| + | this.furColor = fColor; | ||
| + | this.eyeColor = eColor | ||
| + | } | ||
| + | draw () { | ||
| + | fill(this.furColor); | ||
| + | let leftEarPosition = [this.xposition+180, | ||
| + | this.yposition+140]; | ||
| + | let rightEarPosition = [this.xposition+300, | ||
| + | triangle(30 + leftEarPosition[0], | ||
| + | triangle(30 + rightEarPosition[0], | ||
| + | circle(this.xposition+300, | ||
| + | |||
| + | fill(this.eyeColor); | ||
| + | rect(this.xposition+250, | ||
| + | rect(this.xposition+335, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function dogArray | ||
| + | let outputArray = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray.push(new Dog ( xposition+ (i*200), yposition+(i*200)," | ||
| + | } | ||
| + | return outputArray | ||
| + | } | ||
| + | |||
| + | |||
| + | function fullPattern (startingX, startingY, numberOfRows, | ||
| + | for(let i = 0; i < numberOfRows ; i++){ | ||
| + | let mypattern = patternRow(rowLength, | ||
| + | for(let i = 0; i < mypattern.length ; i++){ | ||
| + | mypattern[i].draw() | ||
| + | }; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function fulldogs (startingX, startingY, numberOfRows, | ||
| + | for(let i = 0; i < numberOfRows ; i++){ | ||
| + | let mydogs = dogArray(rowLength, | ||
| + | for(let i = 0; i < mydogs.length ; i++){ | ||
| + | mydogs[i].draw() | ||
| + | }; | ||
| + | } | ||
| + | } | ||
| + | //let myDogs = dogArray(20); | ||
| + | |||
| + | function draw() { | ||
| + | background(229, | ||
| + | fullPattern(5, | ||
| + | fulldogs(5, | ||
| + | // | ||
| + | // | ||
| + | //let dog2 = new Dog (400,100, " | ||
| + | // | ||
| + | //} | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||