0
當我添加功能g2d.rotate(some Number)
時,屏幕根本沒有顯示任何形狀,沒有此功能,一切正常。使用Graphics2D旋轉形狀
什麼問題?
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(color);
Polygon polygon = new Polygon(xCordinate,yCordinate,4);
// g2d.rotate(Math.toRadians(45));
g2d.draw(polygon);
g2d.fill(polygon);
}
,並在主:
public class Main extends JPanel {
Camera c=new Camera(100, 50, (Math.PI)*2, 0, 150,200,Math.PI,Color.MAGENTA);
//Camera c1=new Camera(100, 50, (Math.PI)*2, 0, 150,200,0,Color.black);
public static void main(String[] a) {
JFrame f = new JFrame();
f.setSize(400, 400);
f.add(new Main());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public void paint(Graphics g) {
//c1.paintComponent(g);
c.paintComponent(g);
}
}