/* HEART.java - Produces turtle with square shell.
      Created by Randel McGirr
       Searles Valley, CA
       2011 
*/
                                  
import java.awt.*;
import java.applet.*;
import java.util.*;

public class ICON_SQ extends Applet{

  Dimension d;
  Image offI;
  Color dark = new Color(30,120,30);
  Color light = new Color(255,160,40);
  Color colors[] = { Color.red, Color.yellow, Color.green, Color.cyan,
    new Color(125,125,125), Color.magenta, new Color(99,50,255), Color.orange, Color.pink };
  Random r;
  int body, fleg, bleg;

  public void init(){
    d = getSize();
    r = new Random();
    fleg=50;
    bleg=50;
    body=50;
    offI = createImage(d.width, d.height);
  }

  public void paint(Graphics g){
    g.setColor(Color.black);
    g.fillRect(0,0,d.width,d.height);
    int endPT=6;
    int start=body+40;
    for(int yy=0; yy<4; yy++){
      for(int xx=0; xx<endPT; xx++){
        int pick = Math.abs(r.nextInt()%colors.length);
        g.setColor(colors[pick]);
        g.fillRect(start+xx*20,120-yy*20,18,18);
      }
      start+=10;
      endPT--;
    }
     //tail
    int c[] = {body+42,body+55,body+40,body+22,body+32,body+42 };
    int d[] = {141,141,146,150,146,141 };
    Polygon tail = new Polygon(c,d,c.length);
    g.fillPolygon(tail);
    //back leg
    int bx[]={bleg+68,bleg+78,bleg+88,bleg+58,bleg+68};
    int by[]={141,141,160,160,141};
    Polygon backleg=new Polygon(bx,by,bx.length);
    g.fillPolygon(backleg);    
    //front leg
    int fx[]={fleg+118,fleg+128,fleg+138,fleg+108,fleg+118};
    int fy[]={141,141,160,160,141};
    Polygon frontleg=new Polygon(fx,fy,fx.length);
    g.fillPolygon(frontleg);    
    //head
    int hx[]={body+140,body+165,body+175,body+190,body+200,body+190,body+175,body+165,body+150,body+140};
    int hy[]={141,141,120,120,141,155,155,150,150,141};
    Polygon head=new Polygon(hx,hy,hx.length);
    g.fillPolygon(head);    
    g.setColor(Color.black);
    g.fillOval(body+186,130,5,5);
    g.drawLine(body+195,150,body+185,145);
  }
}

//<applet code=ICON_SQ.class height=200 width=380></applet>
