画乌龟

import java.awt.Color;
import java.awt.Graphics;
import java.awt.*;

import javax.swing.JFrame;

public class turtle1 {

	public static void main(String[] args) {
		
			JFrame w=new JFrame();
			w.setSize(3000,4000);
			MyPanel mp=new MyPanel();
			w.add(mp);		
			Thread t=new Thread(mp);
			t.start();
			w.setVisible(true);
	}

}
class MyPanel extends Panel implements Runnable{
	
	
	 int x11=20;
	 int y11=50;
	 
	 int x22=130;
	 int y22=50;
	 
	 
	 int x[]={20,37};
	 int y[]={50,37};
	
     public void paint(Graphics g){
    	 
    
    	
    	
    	 g.setColor(new Color(128,128,128));
    	 g.fillOval(75, 10, 35, 40);//头
    	// g.fillOval(x1,y2,30, 40); 
    
    	 g.fillOval(20, 50, 30, 40); //第一条腿
    	 
    	 g.fillOval(20, 113, 30, 40); //第二条腿
    	 
    	 g.fillOval(130, 113, 30, 40); 	 //第三条腿
    	
          g.fillOval(130, 50, 30, 40); //第四条腿
    	 
    	 g.fillOval(37, 37, 105, 125);  //身体外围圆环
    	 
    	 
    	
    	 g.fillArc(83, 150, 35, 46, 120, 190);// x坐标 y坐标 长 宽 开始弧度 结束弧度
    	 //g.setColor(Color.green);
    	g.setColor(new Color(0,205,102));
    
    	 //g.setColor(new Color(128,128,128));
    	 g.fillOval(43, 43, 90, 110); //假想有个矩形刚好把圆包住,那么矩形的左上角就是(x,y),右下角坐标(x+width,y+height)
       //圆心坐标(x+width/2,y+height/2),半径(width/2)

    	    //绘制眼白
    	     g.setColor(Color.white);
    	     g.fillOval(82, 13, 11, 11);  	       
    	     g.fillOval(95, 13, 11, 11);  
    	       
   	 int [] a={70,60,70,105,115,105};
  	 int [] b={80,100,120,120,100,80};
	 g.setColor(Color.BLACK);
	 //绘制眼睛
	  g.fillOval(80, 13, 10, 10); 
	  g.fillOval(94, 13, 10, 10); 
	  
	g.setColor(Color.GRAY);
	
		 
  	 g.drawLine(52,66,70,80);
  	 g.drawLine(60,100,43,113);
  	 g.drawLine(70, 120, 53, 136); 
  	 g.drawLine(105, 120, 124, 133); 
  	 g.drawLine(115, 100, 134, 108); 
    g.drawLine(105, 80, 124, 66); 
      g.drawPolygon(a, b, 6);
     

  
     }
     
     public void run(){
    	
    		 
    		 
    		 
    		 try{
        		 Thread.sleep(10);
        	 }catch(Exception e){};
        	 repaint();
    		 
    		 
    	
    	 
    	
    }
}

猜你喜欢

转载自blog.csdn.net/u011159607/article/details/85228062