Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| larissa-kuo-generative [2021/06/20 18:05] – created larissa.kuo | larissa-kuo-generative [2021/06/29 01:35] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | =====My CrazyDog.js===== | + | =====Larissa Kuo's crazyDog.js===== |
| - | <iframe src=" | + | by [[Larissa-kuo|Larissa]] |
| + | |||
| + | |||
| + | < | ||
| + | <iframe src=" | ||
| + | </ | ||
| + | |||
| + | ===== about my CrazyDog.js ===== | ||
| + | |||
| + | My dog is supposed to look like a teddy bear, but instead, it looks like a real bear instead of a cute teddy bear. But my dog does shine in different colors, and it does let your eyes catch it. I had some difficulty during the process of my dog, but at last, I got to finish my dog at the right time. My dog moves up and pretty smoothly, I hope my dog lets you have a bright and warm time after you see it. | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| + | < | ||
| + | function setup() { | ||
| + | createCanvas(1800, | ||
| + | |||
| + | } | ||
| + | class BackgroundPattern { | ||
| + | constructor (xposition, yposition, cSize, sSize, cColor, sColor) | ||
| + | { this.xposition = xposition; | ||
| + | this.yposition = yposition; | ||
| + | this.circleSize = cSize; | ||
| + | this.squareSize = sSize; | ||
| + | this.circleColor = cColor; | ||
| + | this.squareColor = sColor | ||
| + | } | ||
| + | draw () { | ||
| + | fill(this.circleColor); | ||
| + | circle(this.xposition+100, | ||
| + | fill(this.squareColor); | ||
| + | square(this.xposition+80, | ||
| + | square(this.xposition+120, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | class Dog { | ||
| + | constructor (xposition, | ||
| + | this.xposition = xposition; | ||
| + | this.yposition = yposition; | ||
| + | } | ||
| + | draw (){ | ||
| + | //ears1 | ||
| + | | ||
| + | circle(this.xposition+130, | ||
| + | |||
| + | // | ||
| + | fill (Math.random() * 255, | ||
| + | circle(this.xposition+255, | ||
| + | |||
| + | // | ||
| + | fill( 255,255, 225) | ||
| + | circle(this.xposition+140, | ||
| + | |||
| + | //earing2 | ||
| + | fill(Math.random() ) | ||
| + | circle(this.xposition+250, | ||
| + | |||
| + | // | ||
| + | fill(Math.random() * 255, | ||
| + | ellipse(this.xposition+205, | ||
| + | |||
| + | //hands | ||
| + | ellipse(this.xposition+205, | ||
| + | |||
| + | // | ||
| + | fill (255, 255, 255 ) | ||
| + | circle(this.xposition+200, | ||
| + | |||
| + | // | ||
| + | | ||
| + | circle(this.xposition+170, | ||
| + | |||
| + | // | ||
| + | | ||
| + | circle(this.xposition+230, | ||
| + | |||
| + | // | ||
| + | fill (Math.random() ) | ||
| + | circle(this.xposition+170, | ||
| + | |||
| + | //mouth2 | ||
| + | fill(Math.random() ) | ||
| + | circle(this.xposition+230, | ||
| + | |||
| + | //mouth3 | ||
| + | fill(Math.random() ) | ||
| + | circle(this.xpositio+200, | ||
| + | |||
| + | //hand1 | ||
| + | fill(255, | ||
| + | circle(this.xposition+140, | ||
| + | |||
| + | //hand2 | ||
| + | fill(255, | ||
| + | circle(this.xposition+270, | ||
| + | |||
| + | //leg1 | ||
| + | fill(255, | ||
| + | circle(this.xposition+230, | ||
| + | |||
| + | //leg2 | ||
| + | fill(255, | ||
| + | circle(this.xposition+140, | ||
| + | |||
| + | //leg3 | ||
| + | fill(Math.random() * 255, | ||
| + | circle(this.xposition+260, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function backgroundPatternArray (n, y) { | ||
| + | let outputArray = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray.push(new BackgroundPattern (20 + (i*120),0 + y,50, 10," | ||
| + | } | ||
| + | return outputArray | ||
| + | } | ||
| + | |||
| + | function dogArray (n, y) { | ||
| + | let outputArray = []; | ||
| + | for (let i = 0; i < n ; i++) { | ||
| + | outputArray.push(new Dog (20 + (i*120), | ||
| + | } | ||
| + | return outputArray | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | function draw() { | ||
| + | background(217, | ||
| + | //let square2 = new BackgroundPattern (200,0,100, 30," | ||
| + | // | ||
| + | for(let i = 0; i < 10 ; i++){ | ||
| + | let myBackgroundPattern = backgroundPatternArray(25, | ||
| + | for(let i = 0; i < myBackgroundPattern.length ; i++){ | ||
| + | myBackgroundPattern[i].draw() | ||
| + | } | ||
| + | } | ||
| + | y = | ||
| + | let myDogs = dogArray(25, | ||
| + | for(let i = 0; i < myDogs.length ; i++){ | ||
| + | myDogs[i].draw() | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | Click here to adopt! [[: | ||