benyamindsmith / mapBliss

Create Beautiful Maps Of Your Adventures With Leaflet In R.
https://benyamindsmith.github.io/mapBliss/
GNU General Public License v3.0
27 stars 4 forks source link

Frame Idea #2 #6

Open benyamindsmith opened 1 year ago

benyamindsmith commented 1 year ago

Need to figure out the Shiny Code/CSS to do this:

image

GTBoon72 commented 1 year ago

Maybe magick comes in handy here, the R wrapper for ImageMagick.

benyamindsmith commented 1 year ago

@GTBoon72 interesting. It may be possible to create these frames by making transparent places where the maps are supposed to be and overlaying it on the leaflet maps.

GTBoon72 commented 1 year ago

Played a bit around with magick, and this looks promising. It's not so using partly transparent frames, but a black-and-white mask.

Start script

library(magick) map <- image_read('https://user-images.githubusercontent.com/46410142/199815517-4da0d3f8-84a6-482c-83e7-c4e33d0dce7b.png')

get height, width and crop longer side to match shorter side

ii <- magick::image_info(map) ii_min <- min(ii$width, ii$height)

create a new image with white background and black circle

mask <- magick::image_draw(image_blank(ii_min, ii_min)) symbols(ii_min/2, ii_min/2, circles=(ii_min/2)-3, bg='black', inches=FALSE, add=TRUE) dev.off()

create an image composite using both images

combo <- magick::image_composite(map, mask, gravity='center', operator='copyopacity')

set background as white

magick::image_background(combo, 'white')

End script

Result: combo

benyamindsmith commented 1 year ago

Wow this looks beautiful! I wonder how I can fit it in the present way mapBliss works.

If you look at frames.R you'll see that the one frame mask I worked on so far is based on CSS.

I will try to work on this when I get the time.