import java.applet.Applet; import java.awt.*; public class OhakagaKinnas extends Applet{ int algusx=145; int algusy=250; int loppx=145; int loppy=160; void joonistaJoon(Graphics g, int algusx, int algusy, int loppx, int loppy){ int sinine=0; int punane=0; int roheline=0; int s=(int)(Math.random()*255); int p=(int)(Math.random()*255); int r=(int)(Math.random()*255); g.setColor(new Color(sinine+s,punane+p,roheline+r));//värvi segamine// int xd[]=new int[3]; //komnurga joonistamine xd[0]=150; xd[1]=250; xd[2]=50; int yd[]=new int[3]; yd[0]=0; yd[1]=75; yd[2]=75; g.fillPolygon(xd,yd,3); int xd1[]=new int[3]; //komnurga joonistamine xd1[0]=300; xd1[1]=260; xd1[2]=290; int yd1[]=new int[3]; yd1[0]=240; yd1[1]=254; yd1[2]=285; g.fillPolygon(xd1,yd1,3); g.drawLine(260,254,250,264); g.drawLine(290,284,251,321); g.drawRect(50,75,200,340); g.drawRect(50,415,200,50); int soonik=0; int soonik1=55; while(soonik<20){ g.drawLine(soonik1,415,soonik1,465); soonik1=soonik1+10; soonik=soonik+1; } int ringx=56, ringy=75, ringlaius=20, ringkorgus=20; int s1=(int)(Math.random()*255); int p1=(int)(Math.random()*255); int r1=(int)(Math.random()*255); int reas=0; g.setColor(new Color(sinine+s1,punane+p1,roheline+r1)); while(reas<9){ while(ringlaius>3){ g.drawOval(ringx, ringy, ringlaius, ringkorgus); ringlaius=ringlaius/2; ringkorgus=ringkorgus/2; ringx=ringx+ringlaius/2; ringy=ringy+ringlaius/2; } ringx=ringx+13; ringlaius=20; ringkorgus=20; ringy=75; reas=reas+1; } int kastx=56, kasty=300, kastlaius=20, kastkorgus=20, kastreas=0; while(kastreas<9){ while(kastlaius>3){ g.drawRect(kastx, kasty, kastlaius, kastkorgus); kastlaius=kastlaius/2; kastkorgus=kastkorgus/2; kastx=kastx+kastlaius/2; kasty=kasty+kastlaius/2; } kastx=kastx+13; kastlaius=20; kastkorgus=20; kasty=300; kastreas=kastreas+1; } g.drawLine(algusx,algusy,loppx,loppy); int v1=(loppx-algusx)*(loppx-algusx); int v2=(loppy-algusy)*(loppy-algusy); int pikkus=((int)Math.sqrt(v1+v2)); if(pikkus>pikkus/2){ int uusx=loppx-(pikkus/2); int paremx=loppx+(pikkus/2); int ylesy=loppy-(pikkus/2); g.drawLine(loppx,loppy,paremx,loppy); g.drawLine(algusx,algusy,algusx,ylesy); g.drawLine(loppx,loppy,uusx,loppy); g.setColor(Color.red); g.fillOval(paremx-4,loppy-4,10,10); g.fillOval(algusx-4,ylesy,10,10); g.fillOval(uusx-4,loppy-4,10,10); } else{ g.drawLine(algusx, algusy, loppx, loppy); } } public void paint(Graphics g){ joonistaJoon(g, algusx,algusy,loppx,loppy); } public static void main (String argumendid[]){ Frame f=new Frame("KARUOHAKAS"); f.add(new OhakagaKinnas()); f.setSize(400, 500); f.setVisible(true); } }