Anonymous user
Pentagram: Difference between revisions
→{{header|Java}}: more compact
(no longer draft) |
(→{{header|Java}}: more compact) |
||
Line 57:
final double degrees144 = Math.toRadians(144);
public static void main(String[] args) {▼
JFrame f = new JFrame();▼
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);▼
f.setTitle("Pentagram");▼
f.setResizable(false);▼
f.add(new Pentagram(), BorderLayout.CENTER);▼
f.pack();▼
f.setLocationRelativeTo(null);▼
f.setVisible(true);▼
});▼
}▼
public Pentagram() {
Line 76 ⟶ 63:
}
private void drawPentagram(Graphics2D g, int len, int
Color fill, Color stroke) {
double angle = 0;
Path2D p = new Path2D.Float();
for (int i = 0; i < 5; i++) {
int x2 =
int y2 =
angle -= degrees144;
}
p.closePath();▼
▲ p.lineTo(x, y);
▲ p.closePath();
}
Line 118 ⟶ 97:
g.setStroke(new BasicStroke(5, BasicStroke.CAP_ROUND, 0));
▲ }
▲ public static void main(String[] args) {
▲ g.setColor(Color.darkGray);
▲ JFrame f = new JFrame();
▲ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
▲ f.setTitle("Pentagram");
▲ f.setResizable(false);
▲ f.add(new Pentagram(), BorderLayout.CENTER);
▲ f.pack();
▲ f.setLocationRelativeTo(null);
▲ f.setVisible(true);
▲ });
}
}</lang>
|