Advertisement
TizzyT

PlotTree - TizzyT

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