xxxxxxxxxx
54
let egg;
function setup() {
createCanvas(320, 360);
noLoop();
// frameRate(4);
}
function draw() {
egg = new PerlinEgg();
translate(14, 22);
background("#f1e1a5");
background("#f9a622");
background("#2c817a");
fill(0);
fill("#00b2af");
noStroke();
let factor = 1;
let posJit = {
x: width/30,
y: height/30
}
egg.draw({x: width/2, y: height/2});
save("petlja.jpg");
}
class PerlinEgg {
constructor() {
this.zoff = 0;
this.noiseMax = random(0.5, 0.8);
this.size = {w: 2, h: 254};
}
draw(pos) {
beginShape();
for(let a = 0; a < TWO_PI; a += 0.05) {
let xoff = map(cos(a), -1, 1, 0, this.noiseMax);
let yoff = map(sin(a), -1, 1, 0, this.noiseMax);
let r = map(noise(xoff, yoff, this.zoff),
0, 1, this.size.w, this.size.h);
let x = pos.x + 0.8 * r * cos(a);
let y = pos.y + r * sin(a);
vertex(x, y);
}
endShape(CLOSE);
this.zoff += 0.5;
}
}