Pentagram: Difference between revisions
Content added Content deleted
(→{{header|Java}}: no need actually for recursion) |
|||
Line 43: | Line 43: | ||
} |
} |
||
private void |
private void drawPentagram(Graphics2D g, int len, int x1, int y1) { |
||
double angle = 0; |
|||
for (int i = 0; i < 5; i++) { |
|||
int x2 = x1 + (int) (Math.cos(angle) * len); |
|||
int y2 = y1 + (int) (Math.sin(-angle) * len); |
|||
g.drawLine(x1, y1, x2, y2); |
|||
x1 = x2; |
|||
y1 = y2; |
|||
angle -= degrees144; |
|||
} |
|||
drawPentagramR(g, len, x2, y2, angle - degrees144, depth - 1); |
|||
} |
} |
||
Line 90: | Line 89: | ||
g.setColor(Color.darkGray); |
g.setColor(Color.darkGray); |
||
drawPentagram(g, 500, 70, 250); |
|||
} |
} |
||
}</lang> |
}</lang> |