2012-05-29 75 views
0

問題是,在繪製矩形後,我在由18個矩形的外側創建的大圓的中心有圓形。在這個問題中,這18個矩形的左下角必須是常見的,中間的矩形之間沒有空間。我怎樣才能刪除這個空間。它必須由drawPolygon函數繪製。感謝幫助和抱歉我的英語!drawPolygone()繪圖18 20deg差異的矩形

import java.awt.*; 
import javax.swing.*; 

public class Rect20degreeRotate extends JApplet{ 
public void init() { 
resize(500,500); 

    Container DrawArea = getContentPane(); 
    DrawArea.add(

      new JPanel(){ 
      public void paintComponent(Graphics g) { 
       Graphics2D g2 = (Graphics2D)g; 
         int x[]={10,40,40,10}; 
         int y[]={10,10,20,20}; 
         g2.translate(100, 100); 
         for (int i=0;i<18;i++){ 
         g2.rotate(20.0 * Math.PI/180.0); 
         g2.drawPolygon(x,y,4); 
         }       
        } 
      } 
       ); 
} 

}

+0

我已經解決了感謝:問題已在INT X [] = {10,40,40,10}; int y [] = {10,10,20,20}; – user1418998

+0

您應該輸入該答案(沒有SHOUTING或** bold **)並接受它。 –

回答

0
import java.awt.*; 
import javax.swing.*; 

public class Rect20degreeRotate extends JApplet{ 
public void init() { 
resize(500,500); 

    Container DrawArea = getContentPane(); 
    DrawArea.add(

       new JPanel(){ 
      public void paintComponent(Graphics g) { 
       Graphics2D g2 = (Graphics2D)g; 
         int x[]={0,80,80,0}; 
         int y[]={0,0,50,50}; 
        g2.translate(100, 100); 
         for (int i=0;i<18;i++){ 
        g2.rotate(20.0 * Math.PI/180.0); 
        g2.drawPolygon(x,y,4); 
         }       
        } 
      } 
       ); 
} 

}