Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| marcus-hsieh-generative [2021/06/20 19:58] – marcus.hsieh | marcus-hsieh-generative [2021/06/29 01:38] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | =====Marcus' | + | =====Marcus |
| + | by [[: | ||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| - | < | ||
| - | // Where is the circle | ||
| - | let x, y; | ||
| + | ===== about my crazyDog.js ===== | ||
| + | |||
| + | I know more about coding and useing p5.js | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| + | < | ||
| function setup() { | function setup() { | ||
| - | createCanvas(600, 470); | + | createCanvas(1800, 780); |
| - | // Starts in the middle | + | |
| - | x = width / 2; | + | |
| - | y = height; | + | |
| } | } | ||
| - | + | ||
| - | function | + | class Face { |
| - | | + | constructor (positionX, |
| - | + | { this.positionX= positionX | |
| - | | + | |
| - | stroke(50); | + | } |
| + | | ||
| + | | ||
| + | ellipse(this.positionX+98, | ||
| + | ellipse(this.positionX+55, | ||
| + | ellipse(this.positionX+135, | ||
| + | fill(0, | ||
| + | ellipse(this.positionX+135, | ||
| + | fill(0, | ||
| + | ellipse(this.positionX+100, | ||
| + | fill(0, 189, 35) | ||
| + | ellipse(this.positionX+120, | ||
| + | |||
| + | |||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| + | function faceArray | ||
| + | let outputArray = []; | ||
| + | for (let x = 0; x < n ; x++) { | ||
| + | for (let y = 0; y < n ; y++) { | ||
| + | outputArray.push(new Face ( (x*150), | ||
| + | } | ||
| + | } | ||
| + | return outputArray | ||
| + | } | ||
| + | |||
| + | let myFaces = faceArray(10); | ||
| + | |||
| + | class Face2 { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | draw (animateX, | ||
| + | | ||
| | | ||
| - | | + | |
| - | ellipse(x+55,y+60,45) | + | ellipse(animateX+this.positionX+55,animateY+this.positionY+60,45) |
| - | ellipse(x+135,y+60,45) | + | ellipse(animateX+this.positionX+135,animateY+this.positionY+60,45) |
| fill(0, | fill(0, | ||
| - | ellipse(x+135,y+100, | + | ellipse(animateX+this.positionX+135,animateY+this.positionY+100, |
| fill(0, | fill(0, | ||
| - | ellipse(x+100,y+100,35) | + | ellipse(animateX+this.positionX+100,animateY+this.positionY+100,35) |
| fill(0, 189, 35) | fill(0, 189, 35) | ||
| - | ellipse(x+120,y+125, | + | ellipse(animateX+this.positionX+120,animateY+this.positionY+125, |
| - | + | ||
| - | + | ||
| - | // Jiggling randomly on the horizontal axis | + | |
| - | x = x + random(-1, 1); | + | |
| - | // Moving up at a constant speed | + | |
| - | y = y - 1; | + | |
| - | + | ||
| - | // Reset to the bottom | + | |
| - | if (y < 0) { | + | |
| - | y = height; | + | |
| } | } | ||
| } | } | ||
| + | |||
| + | function faceArray2 (n) { | ||
| + | let outputArray = []; | ||
| + | for (let x = 0; x < n ; x++) { | ||
| + | for (let y = 0; y < n ; y++) { | ||
| + | outputArray.push(new Face2 ( (x*180), | ||
| + | } | ||
| + | } | ||
| + | return outputArray | ||
| + | } | ||
| + | |||
| + | let myFaces2 = faceArray2(10); | ||
| + | |||
| + | function draw() { | ||
| + | background(220); | ||
| + | for (let x = 0; x < 12; x += 1) { | ||
| + | for (let y = 0; y < 12; y += 1) { | ||
| + | DrawCloud(x * 150, y * 120); | ||
| + | |||
| + | } | ||
| + | } | ||
| + | //for(let i = 0; i < myFaces.length ; i++){ | ||
| + | // myFaces[i].draw() | ||
| + | //} | ||
| + | for(let i = 0; i < myFaces.length ; i++){ | ||
| + | myFaces2[i].draw(Math.random() * 2,(-1) * frameCount % height) | ||
| + | } | ||
| + | |||
| + | |||
| + | } | ||
| + | function DrawCloud(xPosition, | ||
| + | noStroke(); | ||
| + | fill(252, 252, 252); | ||
| + | ellipse(50 + xPosition, 50 + yPosition, 60, 50); | ||
| + | ellipse(80 + xPosition, 40 + yPosition, 60, 50); | ||
| + | ellipse(130 + xPosition, 50 + yPosition, 60, 50); | ||
| + | ellipse(70 + xPosition, 70 + yPosition, 60, 50); | ||
| + | ellipse(110 + xPosition, 65 + yPosition, 60, 50); | ||
| + | } | ||
| </ | </ | ||
| + | |||