Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user_area_centre = { longitude: centre_x, latitude: centre_y }
- tile_bounds = { south: latitude_min, west: longitude_min, north: latitude_max, east: longitude_max }
- image = static_satellite_img
- draw_circle(image, tile_bounds, user_area_centre)
- def draw_circle(image, bounds, user_area_centre, circle_line_width = 3, circle_colour = 'red', circle_size = 0.1)
- # Approximate where the centre point is in the image.
- width = (bounds[:east] - bounds[:west]).abs
- x_scale = image.columns / width
- height = (bounds[:south] - bounds[:north]).abs
- y_scale = image.rows / height
- x = (centre[:longitude] - bounds[:west]) * x_scale
- y = (centre[:latitude] - bounds[:south]) * y_scale
- circle = Magick::Draw.new
- circle.stroke(circle_colour)
- circle.fill('transparent')
- circle.stroke_width(circle_line_width)
- circle.ellipse(x, image.rows - y, image.columns * circle_size, image.columns * circle_size, 0, 360)
- circle.draw(image)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement