Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| shannia-lin-generative [2021/06/20 17:56] – created renick | shannia-lin-generative [2021/06/29 01:43] (current) – renick | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Shannia' | + | ====== Shannia |
| + | Made by: [[shannia-lin|Shannia Lin]] | ||
| < | < | ||
| - | <iframe src=" | + | <iframe src=" |
| </ | </ | ||
| + | |||
| + | ===== about my crazyDog.js ===== | ||
| + | |||
| + | This is my crazydog.js. I've been working on this the whole semester learning javascript and p5.js. I think the hardest part of this was to make it work how I wanted to. Some parts would just go everywhere or it will just not show up. I'm proud that I now have something that works how I want it to. This the code for my art below. | ||
| + | |||
| + | The animation code is released under the [[https:// | ||
| + | |||
| + | ===== the code for my crazyDog.js ===== | ||
| + | |||
| + | < | ||
| + | let x = 10; | ||
| + | let speed = 0.1; | ||
| + | function setup() { | ||
| + | createCanvas(1800, | ||
| + | rectMode(CENTER) | ||
| + | frameRate(10) | ||
| + | |||
| + | } | ||
| + | function cartPolarX (kall){ | ||
| + | xcp=kall*10*cos(kall*PI/ | ||
| + | } | ||
| + | function cartPolarY (kall){ | ||
| + | ycp=kall*10*sin(kall*PI/ | ||
| + | } | ||
| + | |||
| + | class Dog { | ||
| + | constructor (x, y, earxl, earyl, earxr, earyr, color, tounge, numberarray, | ||
| + | { | ||
| + | this.x = x | ||
| + | this.y = y | ||
| + | this.earxl = earxl | ||
| + | | ||
| + | this.earxr = earxr | ||
| + | | ||
| + | this.color = color | ||
| + | this.tocol = tounge | ||
| + | this.numberarr = numberarray | ||
| + | this.collar = collar | ||
| + | } | ||
| + | draw () { | ||
| + | | ||
| + | | ||
| + | |||
| + | |||
| + | rotate(frameCount * 0.25) | ||
| + | fill(this.collar) | ||
| + | ellipse (100 + this.x,140 + this.y ,70,50); | ||
| + | fill(this.color); | ||
| + | let r = random(0, | ||
| + | ellipse(100+ this.x, 100+ this.y, 100+r); | ||
| + | noFill(); | ||
| + | |||
| + | | ||
| + | |||
| + | let r = random(this.numberarr) | ||
| + | fill(50); | ||
| + | ellipse(75+ this.x, 90+ this.y, 10+r, 10+r); | ||
| + | | ||
| + | } | ||
| + | |||
| + | fill(50); | ||
| + | triangle(110+this.x, | ||
| + | noFill(); | ||
| + | line(100+this.x, | ||
| + | line(100+this.x, | ||
| + | line(100+this.x, | ||
| + | for(let i = 0; i<1; i++) { | ||
| + | fill(this.tocol); | ||
| + | let r = random(this.numberarr) | ||
| + | arc(100 + this.x, 125+this.y, 10+r, 30, 75, 60, OPEN); | ||
| + | noFill(); | ||
| + | |||
| + | translate(xcp, | ||
| + | push() | ||
| + | //ear | ||
| + | fill(this.color); | ||
| + | rotate(-1*PI/ | ||
| + | ellipse(25+ this.earxl, 80+ this.earyl, 55, 40); | ||
| + | noFill(); | ||
| + | //ear | ||
| + | fill(this.color); | ||
| + | rotate(PI/ | ||
| + | ellipse(160+ this.earxr, 25+ this.earyr, 55, 40); | ||
| + | noFill(); | ||
| + | rotate(-1 *PI/ 10); | ||
| + | pop() | ||
| + | |||
| + | } | ||
| + | pop() | ||
| + | } | ||
| + | } | ||
| + | |||
| + | class Diamond { | ||
| + | | ||
| + | { | ||
| + | this.x = x | ||
| + | this.y = y | ||
| + | this.size = size | ||
| + | } | ||
| + | draw(){ | ||
| + | |||
| + | for(let i = 0; i < 10;i++){ | ||
| + | fill(255, | ||
| + | rotate(2.7/ | ||
| + | rect(this.x, | ||
| + | rotate(-1*2.7/ | ||
| + | noFill() | ||
| + | var k= i | ||
| + | } | ||
| + | fill(255) | ||
| + | rotate(2.7/ | ||
| + | rect(this.x, | ||
| + | rotate(-1*2.7/ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function backgroundPattern (xy,yx) { | ||
| + | push() | ||
| + | noFill() | ||
| + | |||
| + | for(let i = 0; i < 100; i++){ | ||
| + | fill (36, 41, 138, 25) | ||
| + | beginShape(TRIANGLE_FAN); | ||
| + | vertex((57.5*i)-100, | ||
| + | vertex((57.5*i)-100, | ||
| + | vertex((92*i)-100, | ||
| + | vertex((57.5*i)-100, | ||
| + | vertex((22*i)-100, | ||
| + | vertex((57.5*i)-100, | ||
| + | endShape() | ||
| + | noFill() | ||
| + | fill(1000/ | ||
| + | circle((x*i)-100, | ||
| + | circle((x*i)-100, | ||
| + | circle((x*i)-100, | ||
| + | noFill() | ||
| + | x = x + speed; | ||
| + | |||
| + | if(x > 100 - 10 || x < 10){ | ||
| + | speed = -speed; | ||
| + | } | ||
| + | |||
| + | |||
| + | } | ||
| + | pop() | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | function draw() { | ||
| + | background(220); | ||
| + | |||
| + | backgroundPattern() | ||
| + | noStroke() | ||
| + | |||
| + | for(let i=0; i <25; i++){ | ||
| + | r = random(-2500, | ||
| + | b= random(-2500, | ||
| + | | ||
| + | diamond.draw() | ||
| + | } | ||
| + | |||
| + | stroke(1) | ||
| + | for(let i=0; i <100; i++){ | ||
| + | cartPolarX(i) | ||
| + | cartPolarY(i) | ||
| + | |||
| + | dog1 = new Dog (xcp, ycp, 0, 0, 0, 0,'# | ||
| + | |||
| + | dog2 = new Dog (xcp+100, ycp+100, 70, 130, 130, 70,'# | ||
| + | dog3 = new Dog (xcp+200, ycp+200, 130, 250, 250, 130,'# | ||
| + | | ||
| + | dog1, | ||
| + | dog2, | ||
| + | dog3, | ||
| + | ] | ||
| + | |||
| + | |||
| + | |||
| + | dogarr.forEach(x => x.draw()) | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||