Вы находитесь на странице: 1из 3

var clouds = [];

var MIN_DISTANCE = 190;


var angle = 0;

function setup() {
createCanvas(700, 380);

for (var i = 0; i < 1000; i++) {


var newCloud = new Cloud();
var overlap = false;
for (var j = 0; j < clouds.length; j++) {
var distance = dist(newCloud.x, newCloud.y, clouds[j].x, clouds[j].y);
if (distance < MIN_DISTANCE) {
overlap = true;
break;
}
}
if (!overlap) {
clouds.push(newCloud);
}
}
}

function draw() {
fill('#012A59');
rect(0,0,700,50)
fill('#04438D');
rect(0,50,700,50)
fill('#95BFF3');
rect(0,100,700,50)
fill('#F47ADF');
rect(0,150,700,50)
fill('#EA4C86');
rect(0,200,700,50)
fill('#CA2978');
rect(0,250,700,50)
//пингвин
fill('#161415');
ellipse(200,260,80,80)
rect(160,255,80,80)

fill('#FCF9FA');
arc(200 , 270 ,30, 20, 0 * Math.PI, 2 * Math.PI);
rect(185,270,30,50)
ellipse(180,245,15,15)
ellipse(217,245,15,15)
fill('#141313');
ellipse(180,245,7,7)
ellipse(217,245,7,7)
fill('#FF5722');
triangle(190,247,205,242,205,255);
fill('#0D0C0C');
triangle(165,250,135,255,160,270);
triangle(225,250,270,255,240,270);

push();
translate(width-350 , height-60 );
if (height-20 > 300) {
var framerate = 700;
var angle = map(frameCount, 0, framerate, 0, TWO_PI);
applyMatrix(cos(angle), sin(angle), -sin(angle), cos(angle), 0, 0);
}
fill('#FFEB3B');
arc(250 , 70 ,90, 90, 0 * Math.PI, 2 * Math.PI);
pop();
fill('#795548');
rect(0,300,700,100)
fill('#8BC34A');
rect(0,300,700,20)
fill('#FF5722');
triangle(160,300,180,300,150,315);
triangle(160,300,180,300,160,315);
triangle(220,300,240,300,210,315);
triangle(220,300,240,300,220,315);

// рисование дерева
fill('#795548');
rect(550, 200, 15, 100);
fill('#4CAF50');
ellipse(555, 180, 100, 100);
ellipse(600, 185, 40, 40);
ellipse(590, 155, 40, 40);
ellipse(570, 140, 40, 40);
ellipse(550, 140, 40, 40);
ellipse(530, 145, 40, 40);
ellipse(515, 160, 40, 40);
ellipse(513, 180, 40, 40);
ellipse(525, 205, 40, 40);
ellipse(588, 205, 40, 40);

fill('#F0F5FA');
for (var i = 0; i < clouds.length; i++) {
clouds[i].move();
clouds[i].display();
if (clouds[i].x > width) {
clouds[i].x = 10;
}

function Cloud() {
this.x = random(0, width);
this.y = random(0, height / 3-15);

this.display = function() {
fill('#F0F5FA');
noStroke();
ellipse(this.x, this.y, 150, 80);
ellipse(this.x - 60, this.y + 10, 60, 50);
ellipse(this.x - 50, this.y - 10, 60, 50);
ellipse(this.x - 20, this.y - 30, 80, 50);
ellipse(this.x + 30, this.y - 30, 80, 50);
ellipse(this.x + 60, this.y - 10, 50, 50);
ellipse(this.x + 70, this.y, 60, 38);
ellipse(this.x + 65, this.y + 20, 60, 40);
ellipse(this.x + 20, this.y + 30, 60, 40);
ellipse(this.x - 30, this.y + 30, 60, 40);

this.move = function() {
var masx=0.6;
applyMatrix(masx, 0, 0,masx, this.x, this.y);
masx+=2.005;
this.x+=1;
}
}

Вам также может понравиться