Sunteți pe pagina 1din 30

Vlad

Laborator 1

Laborator 3
Lena
Laborator 1

Listingul functiei paint():


public void paint(Graphics g) {
starColor = skyColor;

//sky
g2.setColor(skyColor);
g2.fillRect(0,0, 1500, 900);

g2.setColor(starColor);

g2.setColor(myColor21);

g2.fillOval(rectx,recty, h, 70);
//first star

g2.setColor(myColor5);
starX = 50;
starY = 50;
//updatePoints(starX, starY);

g2.fillPolygon(xPoints, yPoints, 5);


g2.fillOval(starX + 5, starY - 1, 6, 7);
//movin baloons

g2.setColor(myColor18);
g2.fillOval(x, y, 100, 100);
g2.setColor(myColor19);
g2.fillOval(x + 25, y, 75, 80);
g2.setColor(myColor20);
g2.fillOval(x + 45, y + 5, 55, 65);
g2.setColor(myColor8);
g2.drawOval(x, y, 100, 100);

g2.setColor(myColor15); //835+185
g2.fillOval(x1, y1, 100, 100);
g2.setColor(myColor13);
g2.fillOval(x1 + 25, y1, 75, 80);
g2.setColor(myColor16);
g2.fillOval(x1 + 45, y1 + 5, 55, 65);
g2.setColor(myColor8);
g2.drawOval(x1, y1, 100, 100);

g2.setColor(myColor21);
g2.fillOval(x2-25, y2, 100, 120);
int[] arrayX2 = {x2+20, x2+30, x2+15, x2+35, x2+20};
int[] arrayY2 = {y2+120, y2+120, y2+130, y2+130, y2+120};
g2.fillPolygon(arrayX2,arrayY2,5);
g2.setColor(myColor6);
g2.fillOval(x2,y2,75,90);
g2.setColor(myColor7);
g2.fillOval(x2+20,y2+5,55,75);
g2.setColor(myColor8);
g2.drawOval(x2-25,y2,100,120);
g2.drawPolygon(arrayX2,arrayY2,5);
int[] arrayX2z = {x2+25,x2-25};
int[] arrayY2z = {y2+135,y2+415};
g2.drawPolygon(arrayX2z,arrayY2z,2);

//second star

g2.setColor(myColor5);
starX = 100;
starY = 180;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//third star

g2.setColor(myColor5);
starX = 175;
starY = 70;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//fourth star

g2.setColor(myColor5);
starX = 280;
starY = 120;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//fifth star

g2.setColor(myColor5);
starX = 330;
starY = 25;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//sixth star

g2.setColor(myColor5);
starX = 450;
starY = 160;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//seventh star

g2.setColor(myColor5);
starX = 500;
starY = 50;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//eighth star

g2.setColor(myColor5); starX = 560;


starY = 110;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//ninth star

g2.setColor(myColor5);
starX = 650;
starY = 30;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);

//tenth star

g2.setColor(myColor5);
starX = 725;
starY = 200;
g2.fillPolygon(xPoints, yPoints, 5);
g2.fillOval(starX + 5, starY - 1, 6, 7);
//baloon static
g2.setColor(myColor2);
g2.fillOval(555,70,100,120);
int[] arrayX = {600,610,595,615,600};
int[] arrayY = {190,190,200,200,190};
g2.fillPolygon(arrayX,arrayY,5);
g2.setColor(myColor3);
g2.fillOval(580,70,75,90);
g2.setColor(myColor4);
g2.fillOval(600,75,55,75);
g2.setColor(myColor8);
g2.drawOval(555,70,100,120);
g2.drawPolygon(arrayX,arrayY,5);
int[] arrayX1z = {605,635};
int[] arrayY1z = {200,500};
g2.drawPolygon(arrayX1z,arrayY1z,2);
g2.setColor(myColor2);
g2.fillOval(640,345,100,120);
int[] arrayX1 = {685,695,680,700,685};
int[] arrayY1 = {465,465,475,475,460};
g2.fillPolygon(arrayX1,arrayY1,5);
g2.setColor(myColor3);
g2.fillOval(665,345,75,90);
g2.setColor(myColor4);
g2.fillOval(685,350,55,75);
g2.setColor(myColor8);
g2.drawOval(640,345,100,120);
g2.drawPolygon(arrayX1,arrayY1,5);
int[] arrayX11z = {690,720};
int[] arrayY11z = {475,600};
g2.drawPolygon(arrayX11z,arrayY11z,2);

g2.setColor(myColor21);
int[] arrayX3 = {575,585,570,590,575};
int[] arrayY3 = {430,430,440,440,430};
g2.fillPolygon(arrayX3,arrayY3,5);
g2.fillOval(530,310,100,120);
g2.setColor(myColor6);
g2.fillOval(555,310,75,90);
g2.setColor(myColor7);
g2.fillOval(575,315,55,75);
g2.setColor(myColor8);
g2.drawOval(530,310,100,120);
g2.drawPolygon(arrayX3,arrayY3,5);
int[] arrayX7z = {580,580};
int[] arrayY7z = {440,700};
g2.drawPolygon(arrayX7z,arrayY7z,2);

g2.setColor(myColor9);
int[] arrayX4 = {x3+45,x3+55,x3+45,x3+65,x3+45};
int[] arrayY4 = {y3+120,y3+120,y3+130,y3+130,y3+120};
g2.fillPolygon(arrayX4,arrayY4,5);

g2.fillOval(x3, y3, 100, 120);//670+165


g2.setColor(myColor10);
g2.fillOval(x3+25, y3, 75, 90);
g2.setColor(myColor11);
g2.fillOval(x3+45, y3+15, 55, 75);
g2.setColor(myColor8);
g2.drawOval(x3, y3, 100, 100);
g2.drawPolygon(arrayX4,arrayY4,5);
int[] arrayX6z = {x3+55,x3+75};
int[] arrayY6z = {y3+130,y3+285};
g2.drawPolygon(arrayX6z,arrayY6z,2);

g2.setColor(myColor9);
int[] arrayX5 = {x4,x4+10,x4-5,x4+15,x4};//670+620
int[] arrayY5 = {y4,y4,y4+10,y4+10,y4};
g2.fillPolygon(arrayX5,arrayY5,5);
g2.fillOval(x4-45,y4-120,100,120);
g2.setColor(myColor10);
g2.fillOval(x4-20,y4-120,75,90);
g2.setColor(myColor11);
g2.fillOval(x4,y4-105,55,75);
g2.setColor(myColor8);
g2.drawOval(x4-45,y4-120,100,120);
g2.drawPolygon(arrayX5,arrayY5,5);
int[] arrayX4z = {x4+5,x4+15};
int[] arrayY4z = {y4+10,y4+130};
g2.drawPolygon(arrayX4z,arrayY4z,2);

g2.setColor(myColor12);
int[] arrayX6 = {425,435,420,440,425};
int[] arrayY6 = {375,375,385,385,375};
g2.fillPolygon(arrayX6,arrayY6,5);
g2.fillOval(380,275,100,100);
g2.setColor(myColor13);
g2.fillOval(405,275,75,80);
g2.setColor(myColor14);
g2.fillOval(420,280,55,65);
g2.setColor(myColor8);
g2.drawOval(380,275,100,100);
g2.drawPolygon(arrayX6,arrayY6,5);
int[] arrayX5z = {430,430};
int[] arrayY5z = {385,550};
g2.drawPolygon(arrayX5z,arrayY5z,2);

g2.setColor(myColor18);
g2.fillOval(750,315,100,100);
g2.setColor(myColor19);
g2.fillOval(775,315,75,80);
g2.setColor(myColor20);
g2.fillOval(795,320,55,65);
g2.setColor(myColor8);
g2.drawOval(750,315,100,100);

//cloud moving, white


g2.setColor(Color.white);
g2.fillOval(cloudX, cloudY, 50, 60);
g2.fillOval(cloudX+15, cloudY-25, 70, 80);
g2.fillOval(cloudX+30, cloudY+30, 70, 50);
g2.fillOval(cloudX+60, cloudY, 80, 60);
g2.fillOval(cloudX+50, cloudY-30, 60, 40);
g2.fillOval(cloudX+80, cloudY-20, 70, 60);
g2.fillOval(cloudX+80, cloudY+20, 70, 60);
g2.fillOval(cloudX+100, cloudY, 70, 60);

g2.setColor(Color.white);
g2.fillOval(cloudX1, cloudY1, 50, 60);
g2.fillOval(cloudX1+15, cloudY1-25, 70, 80);
g2.fillOval(cloudX1+30, cloudY1+30, 70, 50);
g2.fillOval(cloudX1+60, cloudY1, 80, 60);
g2.fillOval(cloudX1+50, cloudY1-30, 60, 40);
g2.fillOval(cloudX1+80, cloudY1-20, 70, 60);
g2.fillOval(cloudX1+80, cloudY1+20, 70, 60);
g2.fillOval(cloudX1+100, cloudY1, 70, 60);

g2.setColor(Color.white);
g2.fillOval(cloudX2, cloudY2, 50, 60);
g2.fillOval(cloudX2+15, cloudY2-25, 70, 80);
g2.fillOval(cloudX2+30, cloudY2+30, 70, 50);
g2.fillOval(cloudX2+60, cloudY2, 80, 60);
g2.fillOval(cloudX2+50, cloudY2-30, 60, 40);
g2.fillOval(cloudX2+80, cloudY2-20, 70, 60);
g2.fillOval(cloudX2+80, cloudY2+20, 70, 60);
g2.fillOval(cloudX2+100, cloudY2, 70, 60);

//gase baloon
int[] a1 = {1193,1207,1223,1289,1273,1228,1160,1120,1120,1193};
int[] a2 = {144,137,147,231,357,422,420,420,350,225,144};
int[]
a3={1193,1079,1064,1114,1161,1228,1303,1335,1347,1331,1291,1217,1193};
int[] a4={144,199,321,393,418,425,379,333,271,212,168,146,144};
int[] a5={1081,1116,1290,1330};
int[] a6={201,224,228,207};
int[] a7={1068,1116,1269,1331};
int[] a8={318,345,356,333};
int[] a9={1116,1150,1161,1132,1116};
int[] a10={394,476,478,407,394};
int[] a11={1158,1166,1180,1165,1158};
int[] a12={421,477,479,420,421};
int[] a13={1230,1240,1216,1206,1230};
int[] a14={419,421,481,478,419};
int[] a15={1260,1271,1238,1228,1260};
int[] a16={408,403,477,478,408};
int[] a17={1140,1141,1242,1245,1140};
int[] a18={475,491,495,478,475};
int[] a19={1146,1234,1225,1148,1146};
int[] a20={499,499,544,540,499};

g2.setColor(myColor6);
g2.fillPolygon(a3,a4,13);
g2.setColor(myColor9);
g2.fillPolygon(a9,a10,5);
g2.setColor(myColor12);
g2.fillPolygon(a11,a12,5);
g2.setColor(myColor18);
g2.fillPolygon(a13,a14,5);
g2.setColor(myColor19);
g2.fillPolygon(a15,a16,5);
g2.setColor(myColor5);
g2.fillPolygon(a17,a18,5);
g2.setColor(myColor15);
g2.setColor(myColor4);
g2.fillPolygon(a1,a2,5);
g2.setColor(myColor2);
g2.fillPolygon(a18,a19,5);

g2.setColor(myColor8);
g2.drawPolygon(a1,a2,9);
g2.drawPolygon(a3,a4,13);
g2.drawPolygon(a5,a6,4);
g2.drawPolygon(a7,a8,4);
g2.drawPolygon(a9,a10,5);
g2.drawPolygon(a11,a12,5);
g2.drawPolygon(a13,a14,5);
g2.drawPolygon(a15,a16,5);
g2.drawPolygon(a17,a18,5);
g2.drawPolygon(a19,a20,5);
g2.drawOval(1188,515,20,20);
g2.drawOval(1142,513,20,10);

//racheta
g2.drawOval(120, 406, 100 - z, 70 - z);
g2.setColor(myColor21);
g2.fillRoundRect(105-z/2,346,130-z/2,250-z,20,20);
g2.setColor(myColor2);
g2.drawRoundRect(105-z/2,346,130-z/2,250-z,20,20);
g2.fillRect(120,596,100-z,20-z);

if(z<=50) {
int[] b1 = {170, 110, 170, 230, 170};
int[] b2 = {346, 346, 206, 346, 346};
int[] b3 = {235, 280, 235};
int[] b4 = {406, 456, 456};
int[] b5 = {105, 55, 105};
int[] b6 = {406, 456, 456};
g2.setColor(myColor18);
g2.fillPolygon(b1, b2, 3);
g2.setColor(myColor19);
g2.fillPolygon(b3, b4, 3);
g2.setColor(myColor12);
g2.fillPolygon(b5, b6, 3);

g2.drawPolygon(b1, b2, 5);


g2.drawPolygon(b3, b4, 3);
g2.drawPolygon(b5, b6, 3);

g.setColor(myColor21);
int[] b7 = {120, 90, 130, 130, 140, 150, 160, 170, 180, 190, 200,
230, 220, 120};
int[] b8 = {616, 700, 640, 730, 660, 780, 650, 700, 630, 750, 640,
700, 616, 616};
g.drawPolygon(b7, b8, 14);
}
g.drawImage(img, 0, 0, this);
}
Laborator 2

Listingul programului:
package graphics;

import java.awt.*;

import java.awt.image.BufferedImage;

import javax.swing.*;

import java.util.Random;

class JavaGraphics extends JApplet implements Runnable {

Thread animator;

//variables for animating the sun

int xSunPosition,x,x1,x2,x3,x4,z,z1,z2,z3,z4,z5,rectx=1000,recty=600,h=30;

int ySunPosition,y,y1,y2,y3,y4;
//variables for the sky changing color

int skyR, skyG, skyB;

Color skyColor = new Color(skyR, skyG, skyB);

//variables for animating the cloud

int cloudX = 850;

int cloudY = 100;

int cloudX1 = 1000;

int cloudY1 = 150;

int cloudX2 = 1350;

int cloudY2 = 75;

//variables for keeping the stars hidden until they should come out

Color starColor = skyColor;

//variables for the points of the stars

int starX;

int starY;

int xPoints[] = {starX, starX+11, starX+7, starX+3, starX};

int yPoints[] = {starY, starY+8, starY-5, starY+8, starY};

//for the double buffer to prevent flickeriness

BufferedImage img;

Graphics g2;
@Override

public void init() {

JRootPane root = this.getRootPane();

root.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

@Override

public void start()

img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);

g2 = img.createGraphics();

xSunPosition = 300;

ySunPosition = 400;

x=470;x1=550;x2=835;x3=670;x4=670;z=0;

y=400;y1=210;y2=185;y3=165;y4=620;

animator = new Thread(this);

animator.start();

skyR = 0;

skyG = 0;

skyB = 0;

skyColor = myColor19;

starColor = skyColor;

Color myColor1 = new Color(135, 206, 235);

Color myColor2 = new Color(255, 0, 255);


Color myColor3 = new Color(238, 130, 238);

Color myColor4 = new Color(255, 192, 203);

Color myColor6 = new Color(255, 99, 71);

Color myColor7 = new Color(240, 128, 128);

Color myColor8 = new Color(128, 0, 0);

Color myColor9 = new Color(255,215,0 );

Color myColor10 = new Color(255,165,0);

Color myColor11 = new Color(240,230,140 );

Color myColor12 = new Color(0,100,0 );

Color myColor13 = new Color(107,142,35);

Color myColor14 = new Color(102,205,170 );

Color myColor15 = new Color(0,255,0 );

Color myColor16 = new Color(144,238,144 );

Color myColor17 = new Color(189,183,107 );

Color myColor18 = new Color(0,0,205 );

Color myColor19 = new Color(65,105,225);

Color myColor20 = new Color(135,206,250 );

Color myColor21 = new Color(255, 0, 0);

Color myColor5 = new Color(200, 230, 250);

@Override

public void paint(Graphics g) {

starColor = skyColor;

//sky

g2.setColor(skyColor);

g2.fillRect(0,0, 1500, 900);


g2.setColor(starColor);

g2.setColor(myColor21);

g2.fillOval(rectx,recty, h, 70);

//first star

g2.setColor(myColor5);

starX = 50;

starY = 50;

//updatePoints(starX, starY);

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//movin baloons

g2.setColor(myColor18);

g2.fillOval(x, y, 100, 100);

g2.setColor(myColor19);

g2.fillOval(x + 25, y, 75, 80);

g2.setColor(myColor20);

g2.fillOval(x + 45, y + 5, 55, 65);

g2.setColor(myColor8);

g2.drawOval(x, y, 100, 100);

g2.setColor(myColor15); //835+185

g2.fillOval(x1, y1, 100, 100);

g2.setColor(myColor13);

g2.fillOval(x1 + 25, y1, 75, 80);

g2.setColor(myColor16);
g2.fillOval(x1 + 45, y1 + 5, 55, 65);

g2.setColor(myColor8);

g2.drawOval(x1, y1, 100, 100);

g2.setColor(myColor21);

g2.fillOval(x2-25, y2, 100, 120);

int[] arrayX2 = {x2+20, x2+30, x2+15, x2+35, x2+20};

int[] arrayY2 = {y2+120, y2+120, y2+130, y2+130, y2+120};

g2.fillPolygon(arrayX2,arrayY2,5);

g2.setColor(myColor6);

g2.fillOval(x2,y2,75,90);

g2.setColor(myColor7);

g2.fillOval(x2+20,y2+5,55,75);

g2.setColor(myColor8);

g2.drawOval(x2-25,y2,100,120);

g2.drawPolygon(arrayX2,arrayY2,5);

int[] arrayX2z = {x2+25,x2-25};

int[] arrayY2z = {y2+135,y2+415};

g2.drawPolygon(arrayX2z,arrayY2z,2);

//second star

g2.setColor(myColor5);

starX = 100;

starY = 180;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//third star
g2.setColor(myColor5);

starX = 175;

starY = 70;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//fourth star

g2.setColor(myColor5);

starX = 280;

starY = 120;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//fifth star

g2.setColor(myColor5);

starX = 330;

starY = 25;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//sixth star

g2.setColor(myColor5);

starX = 450;

starY = 160;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);


//seventh star

g2.setColor(myColor5);

starX = 500;

starY = 50;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//eighth star

g2.setColor(myColor5); starX = 560;

starY = 110;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//ninth star

g2.setColor(myColor5);

starX = 650;

starY = 30;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);

//tenth star

g2.setColor(myColor5);

starX = 725;

starY = 200;

g2.fillPolygon(xPoints, yPoints, 5);

g2.fillOval(starX + 5, starY - 1, 6, 7);


//baloon static

g2.setColor(myColor2);

g2.fillOval(555,70,100,120);

int[] arrayX = {600,610,595,615,600};

int[] arrayY = {190,190,200,200,190};

g2.fillPolygon(arrayX,arrayY,5);

g2.setColor(myColor3);

g2.fillOval(580,70,75,90);

g2.setColor(myColor4);

g2.fillOval(600,75,55,75);

g2.setColor(myColor8);

g2.drawOval(555,70,100,120);

g2.drawPolygon(arrayX,arrayY,5);

int[] arrayX1z = {605,635};

int[] arrayY1z = {200,500};

g2.drawPolygon(arrayX1z,arrayY1z,2);

g2.setColor(myColor2);

g2.fillOval(640,345,100,120);

int[] arrayX1 = {685,695,680,700,685};

int[] arrayY1 = {465,465,475,475,460};

g2.fillPolygon(arrayX1,arrayY1,5);

g2.setColor(myColor3);

g2.fillOval(665,345,75,90);

g2.setColor(myColor4);

g2.fillOval(685,350,55,75);

g2.setColor(myColor8);

g2.drawOval(640,345,100,120);

g2.drawPolygon(arrayX1,arrayY1,5);

int[] arrayX11z = {690,720};


int[] arrayY11z = {475,600};

g2.drawPolygon(arrayX11z,arrayY11z,2);

g2.setColor(myColor21);

int[] arrayX3 = {575,585,570,590,575};

int[] arrayY3 = {430,430,440,440,430};

g2.fillPolygon(arrayX3,arrayY3,5);

g2.fillOval(530,310,100,120);

g2.setColor(myColor6);

g2.fillOval(555,310,75,90);

g2.setColor(myColor7);

g2.fillOval(575,315,55,75);

g2.setColor(myColor8);

g2.drawOval(530,310,100,120);

g2.drawPolygon(arrayX3,arrayY3,5);

int[] arrayX7z = {580,580};

int[] arrayY7z = {440,700};

g2.drawPolygon(arrayX7z,arrayY7z,2);

g2.setColor(myColor9);

int[] arrayX4 = {x3+45,x3+55,x3+45,x3+65,x3+45};

int[] arrayY4 = {y3+120,y3+120,y3+130,y3+130,y3+120};

g2.fillPolygon(arrayX4,arrayY4,5);

g2.fillOval(x3, y3, 100, 120);//670+165

g2.setColor(myColor10);

g2.fillOval(x3+25, y3, 75, 90);

g2.setColor(myColor11);

g2.fillOval(x3+45, y3+15, 55, 75);


g2.setColor(myColor8);

g2.drawOval(x3, y3, 100, 100);

g2.drawPolygon(arrayX4,arrayY4,5);

int[] arrayX6z = {x3+55,x3+75};

int[] arrayY6z = {y3+130,y3+285};

g2.drawPolygon(arrayX6z,arrayY6z,2);

g2.setColor(myColor9);

int[] arrayX5 = {x4,x4+10,x4-5,x4+15,x4};//670+620

int[] arrayY5 = {y4,y4,y4+10,y4+10,y4};

g2.fillPolygon(arrayX5,arrayY5,5);

g2.fillOval(x4-45,y4-120,100,120);

g2.setColor(myColor10);

g2.fillOval(x4-20,y4-120,75,90);

g2.setColor(myColor11);

g2.fillOval(x4,y4-105,55,75);

g2.setColor(myColor8);

g2.drawOval(x4-45,y4-120,100,120);

g2.drawPolygon(arrayX5,arrayY5,5);

int[] arrayX4z = {x4+5,x4+15};

int[] arrayY4z = {y4+10,y4+130};

g2.drawPolygon(arrayX4z,arrayY4z,2);

g2.setColor(myColor12);

int[] arrayX6 = {425,435,420,440,425};

int[] arrayY6 = {375,375,385,385,375};

g2.fillPolygon(arrayX6,arrayY6,5);

g2.fillOval(380,275,100,100);
g2.setColor(myColor13);

g2.fillOval(405,275,75,80);

g2.setColor(myColor14);

g2.fillOval(420,280,55,65);

g2.setColor(myColor8);

g2.drawOval(380,275,100,100);

g2.drawPolygon(arrayX6,arrayY6,5);

int[] arrayX5z = {430,430};

int[] arrayY5z = {385,550};

g2.drawPolygon(arrayX5z,arrayY5z,2);

g2.setColor(myColor18);

g2.fillOval(750,315,100,100);

g2.setColor(myColor19);

g2.fillOval(775,315,75,80);

g2.setColor(myColor20);

g2.fillOval(795,320,55,65);

g2.setColor(myColor8);

g2.drawOval(750,315,100,100);

//cloud moving, white

g2.setColor(Color.white);

g2.fillOval(cloudX, cloudY, 50, 60);

g2.fillOval(cloudX+15, cloudY-25, 70, 80);

g2.fillOval(cloudX+30, cloudY+30, 70, 50);

g2.fillOval(cloudX+60, cloudY, 80, 60);

g2.fillOval(cloudX+50, cloudY-30, 60, 40);


g2.fillOval(cloudX+80, cloudY-20, 70, 60);

g2.fillOval(cloudX+80, cloudY+20, 70, 60);

g2.fillOval(cloudX+100, cloudY, 70, 60);

g2.setColor(Color.white);

g2.fillOval(cloudX1, cloudY1, 50, 60);

g2.fillOval(cloudX1+15, cloudY1-25, 70, 80);

g2.fillOval(cloudX1+30, cloudY1+30, 70, 50);

g2.fillOval(cloudX1+60, cloudY1, 80, 60);

g2.fillOval(cloudX1+50, cloudY1-30, 60, 40);

g2.fillOval(cloudX1+80, cloudY1-20, 70, 60);

g2.fillOval(cloudX1+80, cloudY1+20, 70, 60);

g2.fillOval(cloudX1+100, cloudY1, 70, 60);

g2.setColor(Color.white);

g2.fillOval(cloudX2, cloudY2, 50, 60);

g2.fillOval(cloudX2+15, cloudY2-25, 70, 80);

g2.fillOval(cloudX2+30, cloudY2+30, 70, 50);

g2.fillOval(cloudX2+60, cloudY2, 80, 60);

g2.fillOval(cloudX2+50, cloudY2-30, 60, 40);

g2.fillOval(cloudX2+80, cloudY2-20, 70, 60);

g2.fillOval(cloudX2+80, cloudY2+20, 70, 60);

g2.fillOval(cloudX2+100, cloudY2, 70, 60);

//gase baloon

int[] a1 = {1193,1207,1223,1289,1273,1228,1160,1120,1120,1193};

int[] a2 = {144,137,147,231,357,422,420,420,350,225,144};

int[] a3={1193,1079,1064,1114,1161,1228,1303,1335,1347,1331,1291,1217,1193};

int[] a4={144,199,321,393,418,425,379,333,271,212,168,146,144};

int[] a5={1081,1116,1290,1330};
int[] a6={201,224,228,207};

int[] a7={1068,1116,1269,1331};

int[] a8={318,345,356,333};

int[] a9={1116,1150,1161,1132,1116};

int[] a10={394,476,478,407,394};

int[] a11={1158,1166,1180,1165,1158};

int[] a12={421,477,479,420,421};

int[] a13={1230,1240,1216,1206,1230};

int[] a14={419,421,481,478,419};

int[] a15={1260,1271,1238,1228,1260};

int[] a16={408,403,477,478,408};

int[] a17={1140,1141,1242,1245,1140};

int[] a18={475,491,495,478,475};

int[] a19={1146,1234,1225,1148,1146};

int[] a20={499,499,544,540,499};

g2.setColor(myColor6);

g2.fillPolygon(a3,a4,13);

g2.setColor(myColor9);

g2.fillPolygon(a9,a10,5);

g2.setColor(myColor12);

g2.fillPolygon(a11,a12,5);

g2.setColor(myColor18);

g2.fillPolygon(a13,a14,5);

g2.setColor(myColor19);

g2.fillPolygon(a15,a16,5);

g2.setColor(myColor5);

g2.fillPolygon(a17,a18,5);

g2.setColor(myColor15);
g2.setColor(myColor4);

g2.fillPolygon(a1,a2,5);

g2.setColor(myColor2);

g2.fillPolygon(a18,a19,5);

g2.setColor(myColor8);

g2.drawPolygon(a1,a2,9);

g2.drawPolygon(a3,a4,13);

g2.drawPolygon(a5,a6,4);

g2.drawPolygon(a7,a8,4);

g2.drawPolygon(a9,a10,5);

g2.drawPolygon(a11,a12,5);

g2.drawPolygon(a13,a14,5);

g2.drawPolygon(a15,a16,5);

g2.drawPolygon(a17,a18,5);

g2.drawPolygon(a19,a20,5);

g2.drawOval(1188,515,20,20);

g2.drawOval(1142,513,20,10);

//racheta

g2.drawOval(120, 406, 100 - z, 70 - z);

g2.setColor(myColor21);

g2.fillRoundRect(105-z/2,346,130-z/2,250-z,20,20);

g2.setColor(myColor2);

g2.drawRoundRect(105-z/2,346,130-z/2,250-z,20,20);

g2.fillRect(120,596,100-z,20-z);

if(z<=50) {

int[] b1 = {170, 110, 170, 230, 170};

int[] b2 = {346, 346, 206, 346, 346};


int[] b3 = {235, 280, 235};

int[] b4 = {406, 456, 456};

int[] b5 = {105, 55, 105};

int[] b6 = {406, 456, 456};

g2.setColor(myColor18);

g2.fillPolygon(b1, b2, 3);

g2.setColor(myColor19);

g2.fillPolygon(b3, b4, 3);

g2.setColor(myColor12);

g2.fillPolygon(b5, b6, 3);

g2.drawPolygon(b1, b2, 5);

g2.drawPolygon(b3, b4, 3);

g2.drawPolygon(b5, b6, 3);

g.setColor(myColor21);

int[] b7 = {120, 90, 130, 130, 140, 150, 160, 170, 180, 190, 200, 230, 220, 120};

int[] b8 = {616, 700, 640, 730, 660, 780, 650, 700, 630, 750, 640, 700, 616, 616};

g.drawPolygon(b7, b8, 14);

g.drawImage(img, 0, 0, this);

public static void main(String s[]) {

JFrame f = new JFrame("Java Graphics");

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JApplet applet = new JavaGraphics();

f.getContentPane().add(applet);

applet.init();
f.pack();

f.setSize(new Dimension(1500, 1000));

f.setVisible(true);

applet.start();

float centerx,centery,unghi,r;

float angle,dx,dy,X1,Y1;

float c = 0.84f,s=0.54f;

public void run() {

while (Thread.currentThread() == animator) {

//rotation

if (unghi==360) {unghi=0;}

unghi = unghi + 45;

//angle = Math.toRadians(unghi);

centerx = 900;

centery = 500;

dx = rectx - centerx;

dy = recty - centery;

X1 = (rectx - centerx) * c + (recty - centery) * s + centerx;

Y1 = (recty - centery) * c - (rectx - centerx) * s + centery;

h = 30;

rectx = (int) X1;

recty = (int) Y1;

if(z!=250) z++;

else z=249;

if (skyR < 200) {

skyR++;
}

if (skyG < 230) {

skyG++;

if (skyB < 250) {

skyB++;}

skyColor = new Color(skyR, skyG, skyB);

starColor = skyColor;

if (y < 1000)

y -= 5;

if (y1 < 1000)

y1 -= 3;

if (y2 < 1000)

y2 -= 3;

if (y3 < 1000)

y3 -= 5;

if (y4 < 1000)

y4 -= 3;

//cloud animation

if(cloudX>0)cloudX=cloudX-10; else cloudX=1400;

if(cloudX1>0)cloudX1=cloudX1-5; else cloudX1=1400;

if(cloudX2>0)cloudX2=cloudX2-3; else cloudX2=1400;


repaint();

try {

Thread.sleep(40); //time in milliseconds

} catch (Exception e) {

break;

}
Laborator 3