Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private final Color TREE = Color.decode("#92d050"); // Color for the leaves
- private final Color TRUNK = Color.decode("#948a54"); // Color for the trunk
- // Draws trees on a graphic
- private void PlotTree(Graphics graphics, int X, int Y, int Width, int Height) {
- int trunk = (Width / 5) - 1, Y36 = Y - 36, W2 = Width / 2;
- if (trunk % 2 == 0 || trunk < 1) trunk += 1;
- graphics.setColor(TRUNK);
- graphics.fillRect(X - (trunk / 2), Y36, trunk, 36);
- graphics.setColor(TREE);
- graphics.fillPolygon(new int[]{X - (W2), X + (W2), X}, new int[]{Y36, Y36, Y - Height}, 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement