0

问题是,在绘制矩形后,我在由 18 个矩形的外侧创建的更大圆圈的中心有一个圆圈。在这个问题中,这 18 个矩形的左下角必须是共同的,并且中心矩形之间没有空间。我怎样才能删除这个空间。它必须由 drawPolygon 函数绘制。感谢您的帮助,对不起我的英语!

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);
                      }                         
                    }
            }
                );
}

}

4

1 回答 1

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);
                      }                         
                    }
            }
                );
}

}

于 2012-05-30T15:33:52.553 回答