Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. user_area_centre = { longitude: centre_x, latitude: centre_y }
  2. tile_bounds = { south: latitude_min, west: longitude_min, north: latitude_max, east: longitude_max }
  3.  
  4. image = static_satellite_img
  5. draw_circle(image, tile_bounds, user_area_centre)
  6.  
  7. def draw_circle(image, bounds, user_area_centre, circle_line_width = 3, circle_colour = 'red', circle_size = 0.1)
  8. # Approximate where the centre point is in the image.
  9. width = (bounds[:east] - bounds[:west]).abs
  10. x_scale = image.columns / width
  11.  
  12. height = (bounds[:south] - bounds[:north]).abs
  13. y_scale = image.rows / height
  14.  
  15. x = (centre[:longitude] - bounds[:west]) * x_scale
  16. y = (centre[:latitude] - bounds[:south]) * y_scale
  17.  
  18. circle = Magick::Draw.new
  19. circle.stroke(circle_colour)
  20. circle.fill('transparent')
  21. circle.stroke_width(circle_line_width)
  22. circle.ellipse(x, image.rows - y, image.columns * circle_size, image.columns * circle_size, 0, 360)
  23. circle.draw(image)
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement