import java.awt.Graphics;
import java.applet.Applet;
import java.awt.Color;
public class oslm extends java.applet.Applet{
  Color col1,col2;
  int N,taka,haba,ni,nj;
  int k,i,j,l,co,minj,minj2,minj3;
  int xz,xz2,yz,yz2,label;
  String NS,habaS,takaS;
  double Nd,takad,habad,th;
  Color cl[]=new Color[13];


  public double dou(String dous){
    double dou1;
    dou1 = (Double.valueOf(dous)).doubleValue();
    return dou1;
  }
  public double rand(){
    double rand1;
    rand1=Math.random();
    return rand1;
  }
  public void init(){
    col1=Color.black;
    col2=Color.yellow;
    cl[0]=Color.white;
    cl[1]=Color.cyan;
    cl[2]=Color.green;
    takaS=getParameter("takap");
    habaS=getParameter("habap");
    NS=getParameter("Np");
    habad=dou(habaS);
    takad=dou(takaS);
    Nd=4-50*Math.log(rand());
    haba=(int)habad;
    taka=(int)takad;
    N=(int)Nd;
  }
  double x1;
  double y1;
  int x;
  int y;
  double s;
  String sss;
  public double jou(double a,double b){
    double jou1;
    jou1=Math.pow(a,b);
    return jou1;
  }
  public double arcsinaw(double atasw){
    double artn1saw;
    artn1saw=Math.asin(atasw);
    return artn1saw;
  }
  public double d(double d1,double d2,double d3,double d4){
    double dw;
    dw=jou(jou(d3-d1,2.0)+jou(d4-d2,2.0),0.5);
    return dw;
  }

  public void paint(java.awt.Graphics g){
    double dbr;
    double x0;
    double y0;
    int NN;
    double xs;
    double ys;
    double xe;
    double ye;
    g.setColor(col1);

    g.fillRect(1,1,haba,taka);
    dbr=rand();

    NN=(int)(2+50*rand());
    for(j=0;j<NN;j++){
    N=(int)(4-5*Math.log(rand()));
    x1=rand()*(haba-30)+15;
    y1=rand()*(taka-30)+15;
    x=(int)(x1+0.5);
    y=(int)(y1+0.5);
    g.setColor(Color.orange);
    g.drawString(""+N,x,y);
    if(dbr<0.5){
      g.setColor(Color.cyan);
      g.fillOval(x-2,y-2,4,4);
    }
    x0=x1;
    y0=y1;
    xs=x0;
    ys=y0;

    for(k=0;k<N;k++){
      x1=rand()*(haba-30)+15;
      y1=rand()*(taka-30)+15;
      x=(int)(x1+0.5);
      y=(int)(y1+0.5);
      if(dbr<0.5){
        g.setColor(Color.cyan);
        g.fillOval(x-2,y-2,4,4);
      }
      xe=x1;
      ye=y1;
      if(j%10==0){
          g.setColor(Color.white);
      }
      if(j%10==1){
          g.setColor(Color.yellow);
      }
      if(j%10==2){
          g.setColor(Color.green);
      }
      if(j%10==3){
          g.setColor(Color.pink);
      }
      if(j%10==4){
          g.setColor(Color.cyan);
      }
      if(j%10==5){
          g.setColor(Color.orange);
      }
      if(j%10==6){
          g.setColor(Color.red);
      }
      if(j%10==7){
          g.setColor(Color.blue);
      }
      if(j%10==8){
          g.setColor(Color.magenta);
      }
      if(j%10==9){
          g.setColor(Color.gray);
      }
      g.drawLine((int)xs,(int)ys,(int)xe,(int)ye);
      xs=xe;
      ys=ye;
    }
    g.drawLine((int)xs,(int)ys,(int)x0,(int)y0);
    }//j
    g.setColor(Color.green);
    g.drawString("N="+(NN),15,15);
    if(dbr<0.5){
      g.drawString("With circle",75,15);
    }else{
      g.drawString("With no circle",75,15);
    }
  }
}
