ClevelandClinicQHS / riskcalc

An R package for building risk calculators
https://clevelandclinicqhs.github.io/riskcalc/
Other
2 stars 0 forks source link

Add logo for README (retrospective) #7

Closed zajichek closed 1 year ago

zajichek commented 1 year ago

This was already done is this commit: https://github.com/ClevelandClinicQHS/riskcalc/commit/0568aead9da832ed88e35bd34f93dd6ad3ccc628

But adding an issue with notes for the sake of process documentation.

zajichek commented 1 year ago

This was the process taken to create the logo:

  1. Generate an image from the desired concept from Canva (for free): https://www.canva.com/your-apps/text-to-image (searched the concept of something like "an animated concept of a web application that uses risk factors as individual components to produce personalized risk estimates") image

  2. Upload the resulting image to http://connect.thinkr.fr/hexmake/ to make the hexagon logo, using the various imaging effect editors, etc. (however, the image zoom I wanted went out of the hexagon, so I needed to figure out how to trim it) image

  3. Use the hexSticker and magick R packages to trim the boundaries as transparent. This was an excellent resource which I basically used verbatim: https://github.com/GuangchuangYu/hexSticker/issues/39#issuecomment-889786759

I ran the following R code:

# Load the packages
library(hexSticker)
library(magick)

# Path to image downloaded from hexmake app
raw_logo <- "<path to image>/hex-riskcalc.png"

# Add whitespace to the boundaries by refitting a sticker
sticker(raw_logo, package="",
        s_x = 1, s_y = 1, s_width = .85, dpi = 600,
        h_color = "#5699AD",
        white_around_sticker = TRUE,
        filename = "temp_sticker.png")

# Import temporary logo
p <- image_read("temp_sticker.png")

# Fill in boundaries with transparency (note, use the object's width/height in the 'point' argument)
pp <- p %>%
  image_fill(color = "transparent", fuzz = 4, point = "+1+1") %>%  
image_fill(color = "transparent", refcolor = "white", fuzz = 4, point = "+1036+1") %>%  
image_fill(color = "transparent", refcolor = "white", fuzz = 4, point = "+1+1199") %>%  
image_fill(color = "transparent", refcolor = "white", fuzz = 4, point = "+1036+1199")

# Write the image to a file for use (this is the final logo)
image_write(image = pp, path = "<path to image>/hex-riskcalc-final.png")
file.show("<path to image>/hex-riskcalc-final.png")

We end up with the final logo image

  1. Add to package README
    • Used usethis::use_logo("<path to image>/hex-riskcalc-final.png") to add image to package's man/figures/ and generate code to place in README
    • Pasted the code to README containing the image reference
    • Re-built README with devtools::build_readme()
    • Committed and pushed changes to main

Note because of the Actions workflows in place, the pkgdown site automatically updated with the image.