import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
//import polar;

public class yildizSW 
{

public static void drawYildiz1(Graphics g2,int xi,int yi, int n,int yildizboyu,double aci )
{
   // bu yıldız cizime teta=pi/2+aci radyandan baslar

   Graphics2D g=(Graphics2D)g2;
   double teta=2.0*Math.PI/n;
   double R=yildizboyu;
   double r=yildizboyu*0.25;
   polar P1=new polar();
   polar P2=new polar();
   polar P3=new polar();
   for(int i=0;i<n;i++)
   {
     double teta1=teta*i+Math.PI/2.0+aci;
     double teta2=teta/2+teta1;
     P1.polarGir(R,teta1);
     P2.polarGir(r,teta2);
     g.drawLine((xi+(int)P1.xi()),(yi-(int)P1.xj()),
                (xi+(int)P2.xi()),(yi-(int)P2.xj()));
     double teta3=teta*(i+1)+Math.PI/2.0+aci;
     P3.polarGir(R,teta3);
     g.drawLine((xi+(int)P2.xi()),(yi-(int)P2.xj()),
                (xi+(int)P3.xi()),(yi-(int)P3.xj()));
     g.drawLine(xi,yi,
                (xi+(int)P1.xi()),(yi-(int)P1.xj()));
     g.drawLine(xi,yi,
                (xi+(int)P2.xi()),(yi-(int)P2.xj()));
   }

}  //drawYildiz1 metodu sonu

public static void drawYildiz1(Graphics g2,int xi,int yi, int n,int yildizboyu )
{
   drawYildiz1(g2,xi,yi,n,yildizboyu,0);
}  //drawYildiz1 metodu sonu

public static void drawYildiz(Graphics g2,int xi,int yi, int n,int yildizboyu,double aci )
{
   Graphics2D g=(Graphics2D)g2;
   // bu yıldız cizime teta=pi/2+aci radyandan baslar
   double teta=2.0*Math.PI/n;
   double R=yildizboyu;
   double r=yildizboyu*0.25;
   polar P1=new polar();
   polar P2=new polar();
   polar P3=new polar();
   int x[]=new int[2*n+2];
   int y[]=new int[2*n+2];
   GeneralPath polygon=new GeneralPath(GeneralPath.WIND_EVEN_ODD,
   x.length);

   for(int i=0;i<=n;i++)
   {
     double teta1=teta*i+Math.PI/2.0+aci;
     double teta2=teta/2.0+teta1;
     P1.polarGir(R,teta1);
     P2.polarGir(r,teta2);
     x[2*i]=xi+(int)P1.xi();
     y[2*i]=yi-(int)P1.xj();
     x[2*i+1]=xi+(int)P2.xi();
     y[2*i+1]=yi-(int)P2.xj();
     if(i==n)
     {
     x[2*i]=x[0];
     y[2*i]=y[0];     
     }
   }

   for(int i=0;i<=2*n;i++)
   {
          if(i==0)
          {
          polygon.moveTo(x[0],y[0]);
          }
          else
          {
           polygon.lineTo(x[i],y[i]);
          }
   }
   g.draw(polygon);
}  //drawYildiz1 metodu sonu


public static void fillYildiz(Graphics g2,int xi,int yi, int n,int yildizboyu,double aci )
{
   Graphics2D g=(Graphics2D)g2;
   // bu yıldız cizime teta=pi/2+aci radyandan baslar
   double teta=2.0*Math.PI/n;
   double R=yildizboyu;
   double r=yildizboyu*0.25;
   polar P1=new polar();
   polar P2=new polar();
   polar P3=new polar();
   int x[]=new int[2*n+2];
   int y[]=new int[2*n+2];
   GeneralPath polygon=new GeneralPath(GeneralPath.WIND_EVEN_ODD,
   x.length);

   for(int i=0;i<=n;i++)
   {
     double teta1=teta*i+Math.PI/2.0+aci;
     double teta2=teta/2.0+teta1;
     P1.polarGir(R,teta1);
     P2.polarGir(r,teta2);
     x[2*i]=xi+(int)P1.xi();
     y[2*i]=yi-(int)P1.xj();
     x[2*i+1]=xi+(int)P2.xi();
     y[2*i+1]=yi-(int)P2.xj();
     if(i==n)
     {
     x[2*i]=x[0];
     y[2*i]=y[0];     
     }
   }

   for(int i=0;i<=2*n;i++)
   {
          if(i==0)
          {
          polygon.moveTo(x[0],y[0]);
          }
          else
          {
           polygon.lineTo(x[i],y[i]);
          }
   }
   g.fill(polygon);
   
}  //fillYildiz metodu sonu

public static void fillAkrep(Graphics g2,int xi,int yi, int n,int yildizboyu,double aci,int i )
{
   // bu yıldız cizime teta=pi/2+aci radyandan baslar
   // yildızın içini boyar
   Graphics2D g=(Graphics2D)g2;
   double teta=2.0*Math.PI/n;
   double R=yildizboyu;
   double r=yildizboyu*0.25;
   polar P1=new polar();
   polar P2=new polar();
   polar P3=new polar();
   int x[]=new int[5];
   int y[]=new int[5];
   GeneralPath polygon=new GeneralPath(GeneralPath.WIND_EVEN_ODD,
   x.length);
   x[0]=xi;
   y[0]=yi;
   x[4]=xi;
   y[4]=yi;
     double teta1=teta*i+Math.PI/2.0+aci;
     double teta2=teta1+teta/2.0;
     double teta3=teta1-teta/2+Math.PI*2;
     P1.polarGir(R,teta1);
     P2.polarGir(r,teta2);
     P3.polarGir(r,teta3);
     x[1]=xi+(int)P3.xi();
     y[1]=yi-(int)P3.xj();
     x[2]=xi+(int)P1.xi();
     y[2]=yi-(int)P1.xj();
     x[3]=xi+(int)P2.xi();
     y[3]=yi-(int)P2.xj();
   for(i=0;i<5;i++)
   {
          if(i==0)
          {
          polygon.moveTo(x[0],y[0]);
          }
          else
          {
           polygon.lineTo(x[i],y[i]);
          }
   }
   g.fill(polygon);
}  //fillAkrep metodu sonu

public static void drawAkrep(Graphics g2,int xi,int yi, int n,int yildizboyu,double aci,int i )
{
   Graphics2D g=(Graphics2D)g2;
   double teta=2.0*Math.PI/n;
   double R=yildizboyu;
   double r=yildizboyu*0.25;
   polar P1=new polar();
   polar P2=new polar();
   polar P3=new polar();
   int x[]=new int[5];
   int y[]=new int[5];
   GeneralPath polygon=new GeneralPath(GeneralPath.WIND_EVEN_ODD,
   x.length);
   x[0]=xi;
   y[0]=yi;
   x[4]=xi;
   y[4]=yi;
     double teta1=teta*i+Math.PI/2.0+aci;
     double teta2=teta1+teta/2.0;
     double teta3=teta1-teta/2+Math.PI*2;
     P1.polarGir(R,teta1);
     P2.polarGir(r,teta2);
     P3.polarGir(r,teta3);
     x[1]=xi+(int)P3.xi();
     y[1]=yi-(int)P3.xj();
     x[2]=xi+(int)P1.xi();
     y[2]=yi-(int)P1.xj();
     x[3]=xi+(int)P2.xi();
     y[3]=yi-(int)P2.xj();
   for(i=0;i<5;i++)
   {
          if(i==0)
          {
          polygon.moveTo(x[0],y[0]);
          }
          else
          {
           polygon.lineTo(x[i],y[i]);
          }
   }
   g.draw(polygon);

} //drawAkrep metodu sonu 

public static void drawDaire(Graphics g2, int xi,int yi, int R)
{
   Graphics2D g=(Graphics2D)g2;
   g.draw(new Ellipse2D.Double((int)(xi-R),(int)(yi-R),2*R,2*R));
}

public static void fillDaire(Graphics g2, int xi,int yi, int R)
{
   Graphics2D g=(Graphics2D)g2;
   g.fill(new Ellipse2D.Double((int)(xi-R),(int)(yi-R),2*R,2*R));
}
}
