Guest User

Untitled

a guest
Jan 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. private void drawObstacleCircle(Obstacle o, Graphics2D g)
  2. {
  3. final double OBSTACLE_CENTER_RADIUS = 2.0;
  4. final double OBSTACLE_RADIUS = o.getRadius(true);
  5.  
  6. float scaleToUse = Math.max(0.8f, scale);
  7.  
  8. Vector pos = o.getPosition();
  9.  
  10. int xPos = (int) (pos.getX() * getBufferedHeightMap().getWidth());
  11. int yPos = (int) (pos.getY() * getBufferedHeightMap().getHeight());
  12.  
  13. Point positionPoint = convertToPanelPoint(new Point(xPos, yPos));
  14.  
  15. // Draw the circle where the Obstacle's center is
  16. Graphics2D g1 = (Graphics2D) g.create();
  17.  
  18. g1.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  19. g1.setColor(Color.RED);
  20. g1.fillOval(positionPoint.x - (int) (OBSTACLE_CENTER_RADIUS * scaleToUse), positionPoint.y - (int) (OBSTACLE_CENTER_RADIUS * scaleToUse), (int) (OBSTACLE_CENTER_RADIUS * 2 * scaleToUse), (int) (OBSTACLE_CENTER_RADIUS * 2 * scaleToUse));
  21.  
  22. Color c = Color.RED;
  23. g1.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 100));
  24. g1.fillOval(positionPoint.x - (int) (OBSTACLE_RADIUS * scaleToUse), positionPoint.y - (int) (OBSTACLE_RADIUS * scaleToUse), (int) (OBSTACLE_RADIUS * 2 * scaleToUse), (int) (OBSTACLE_RADIUS * 2 * scaleToUse));
  25.  
  26. g1.dispose();
  27. g2.dispose();
  28. }
Add Comment
Please, Sign In to add comment