0% found this document useful (0 votes)
478 views

Snowman Java Processing Code

The document defines code for drawing a winter scene with snowmen and birds flying across the screen when the mouse is pressed. It sets the canvas size, defines variables to track the bird animation and drawing coordinates, and contains functions for setup, draw, and mouse interactions. The draw function contains code to render the background, snowmen, trees, and other winter elements, and uses conditionals to animate flying birds on mouse press by incrementing bezier curve coordinates.

Uploaded by

KingBen1223
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
478 views

Snowman Java Processing Code

The document defines code for drawing a winter scene with snowmen and birds flying across the screen when the mouse is pressed. It sets the canvas size, defines variables to track the bird animation and drawing coordinates, and contains functions for setup, draw, and mouse interactions. The draw function contains code to render the background, snowmen, trees, and other winter elements, and uses conditionals to animate flying birds on mouse press by incrementing bezier curve coordinates.

Uploaded by

KingBen1223
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

void setup () {

size (1500, 1000);


}
//variables
float x1=50, y=75, x2=25, b=25, x3=125, x4=100, a1=100, a2=75, a3=175, a4=150;
float steps = 5;
float bird = 0;

//snowmen
void draw() {
background (2,186,210);
noStroke ();
fill(255);
fill (255);
ellipse (1150, 680, 275, 275) ;
ellipse (1150, 530, 220, 220);
ellipse (1150, 390, 175, 175);
rect (0, 760 , 1500, 500);

//buttons and mouth


fill (0);
ellipse (1115, 360, 20, 20);
ellipse (1185, 360, 20, 20);
ellipse (1100, 410, 15, 15);
ellipse (1125, 420, 15, 15);
ellipse (1150, 425, 15, 15);
ellipse (1175, 420, 15, 15);
ellipse (1200, 410, 15, 15);

fill(#EE0C0C);
ellipse (1150, 530, 20, 20);
ellipse (1150, 490, 20, 20);
ellipse (1150, 570, 20, 20);

fill(0);
rect (1050, 295, 200, 50);
rect (1075, 170, 150, 150);

fill(#FF7315);
triangle(1100, 400, 1150, 400, 1150, 370);

fill (#6E2C00 );
rect (1035, 500, 15, 175);

fill (#F4D03F);
ellipse (400, 150, 200, 200);

fill(#196F3D);
triangle(250, 250, 100, 520, 405, 520);

fill (#6E2C00 );
rect (235,520, 40, 250);

if(mousePressed){
pushMatrix();
translate(1250,500);
rotate(radians(-120));
rect(0,0,15,175);
popMatrix();
} else {
rect (1250, 500, 15, 175);
}

{
noFill();
stroke(0);

if(mousePressed){
bird=1;
}

if(bird>0.9){
x1=x1+steps;
x2=x2+steps;
x3=x3+steps;
x4=x4+steps;
a1=a1+steps;
a2=a2+steps;
a3=a3+steps;
a4=a4+steps;
bezier(x1, y, x2, b, x3, b, x4, y);
bezier(a1, y, a2, b, a3, b, a4, y);
x1=x1+steps-1;
x2=x2+steps-1;
x3=x3+steps-1;
x4=x4+steps-1;
a1=a1+steps-1;
a2=a2+steps-1;
a3=a3+steps-1;
a4=a4+steps-1;
bezier(x1, y, x2, b, x3, b, x4, y);
bezier(a1, y, a2, b, a3, b, a4, y);

if(x1>1500){
x1=50;
y=75;
x2=25;
b=25;
x3=125;
x4=100;
a1=100;
a2=75;
a3=175;
a4=150;
}
}
}

void setup() {
size(1000, 600);

float x1=50, y=75, x2=25, b=25, x3=125, x4=100, a1=100, a2=75, a3=175, a4=150;
float steps = 5;

void draw() {
background(112, 222, 255);
if (mousePressed) {
fill(0);
noStroke();
rect(650, 275, 10, 77);
} else {
background(112, 222, 255);
noStroke();
fill(0);
rect(580, 350, 77, 10);
}
if (mousePressed) {
fill(112, 222, 255);
noStroke();
rect(580, 350, 77, 11);
}
noStroke();

fill(255, 255, 255);


ellipse(800, 500, 200, 200);
ellipse(800, 375, 150, 150);
ellipse(800, 270, 120, 120);
rect(0, 555, 10000, 45);

fill(0, 0, 0);
ellipse(780, 255, 25, 25);
ellipse(820, 255, 25, 25);
rect(759, 100, 85, 100);
rect(740, 200, 120, 25);
ellipse(800, 375, 15, 15);
ellipse(800, 350, 15, 15);
ellipse(800, 400, 15, 15);
arc(800, 280, 50, 50, 0, 3.14);
rect(873, 350, 75, 10);
rect(938, 275, 10, 75);
rect(650, 350, 77, 10);

fill(255, 255, 0);


ellipse(500, 100, 200, 200);

fill(156, 93, 82);


rect(150, 505, 100, 50);
triangle(200, 250, 25, 505, 375, 505);

fill(92, 153, 45);


triangle(200, 250, 25, 505, 375, 505);
triangle(200, 200, 50, 400, 350, 400);
triangle(200, 150, 75, 295, 325, 295);

fill(255, 0, 0);
ellipse(100, 475, 45, 45);
ellipse(300, 475, 45, 45);
ellipse(100, 375, 35, 35);
ellipse(300, 375, 35, 35);
ellipse(125, 275, 25, 25);
ellipse(275, 275, 25, 25);
{
noFill();
stroke(0);

if(mousePressed){
x1=x1+steps;
x2=x2+steps;
x3=x3+steps;
x4=x4+steps;
a1=a1+steps;
a2=a2+steps;
a3=a3+steps;
a4=a4+steps;
bezier(x1, y, x2, b, x3, b, x4, y);
bezier(a1, y, a2, b, a3, b, a4, y);

x1=x1+steps-1;
x2=x2+steps-1;
x3=x3+steps-1;
x4=x4+steps-1;
a1=a1+steps-1;
a2=a2+steps-1;
a3=a3+steps-1;
a4=a4+steps-1;
bezier(x1, y, x2, b, x3, b, x4, y);
bezier(a1, y, a2, b, a3, b, a4, y);

if(x1>875){
x1=50;
y=75;
x2=25;
b=25;
x3=125;
x4=100;
a1=100;
a2=75;
a3=175;
a4=150;
}
}
}

You might also like