| Title: | Create a Tile of Logos for Loaded Packages |
| Version: | 0.1.0 |
| Description: | Creates a responsive HTML file with tiled hexagonal logos for packages in an R session. Tiles can be also be generated for a custom set of packages specified with a character vector. Output can be saved as a static screenshot in PNG format using a headless browser. |
| License: | MIT + file LICENSE |
| Suggests: | knitr, rmarkdown, rsvg, testthat (≥ 3.0.0), withr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| URL: | https://github.com/luisDVA/hexsession, https://hexsession.liomys.mx/ |
| BugReports: | https://github.com/luisDVA/hexsession/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | base64enc, chromote, jsonlite, magick, purrr, htmltools, |
| NeedsCompilation: | no |
| Packaged: | 2026-03-26 02:50:27 UTC; luisd |
| Author: | Luis D. Verde Arregoitia
|
| Maintainer: | Luis D. Verde Arregoitia <luis@liomys.mx> |
| Repository: | CRAN |
| Date/Publication: | 2026-03-30 18:10:07 UTC |
Arrange Images by Color
Description
Takes a vector of image paths, extracts the main color from each image using k-means clustering, converts the colors to the LAB color space, and sorts the images based on the lightness (L) component of their dominant color.
Usage
col_arrange(image_paths)
Arguments
image_paths |
Character vector. A vector of file paths to the images. |
Value
A character vector of image paths, sorted by the lightness of their main color.
Examples
img1 <- system.file("extdata/rectLight.png", package = "hexsession")
img2 <- system.file("extdata/rectMed.png", package = "hexsession")
img3 <- system.file("extdata/rectDark.png", package = "hexsession")
sorted_paths <- col_arrange(c(img1,img3,img2))
Encode image to Base64
Description
Encode image to Base64
Usage
encode_image(file_path)
Arguments
file_path |
Path to an image file |
Value
A character string containing a base64-encoded data URI
(e.g., "data:image/png;base64,..."), or NULL with a warning if
encoding fails.
Examples
img <- system.file("extdata/rectLight.png", package = "hexsession")
encode_image(img)
Find image paths
Description
Find image paths
Usage
find_imgpaths(pkgnames)
Arguments
pkgnames |
Character vector of package names |
Details
Images in svg format will be converted to png. When no image matches 'logo' in the file name the used is will be prompted to select likely logos.
Value
A list of image file paths for each package
Find logo paths
Description
Find logo paths
Usage
find_logopaths(imagepaths, pkgnames)
Arguments
imagepaths |
List of image paths |
pkgnames |
Character vector of package names |
Value
A vector of logo paths
Generate JavaScript file for hexsession
Description
Generate JavaScript file for hexsession
Usage
generate_hexsession_js(
logopaths,
urls,
dark_mode,
output_js,
highlight_mode = FALSE,
pkg_names = NULL,
focus = NULL
)
Arguments
logopaths |
Vector of image paths |
urls |
Vector of URLs |
dark_mode |
Use dark mode, inherited from make_tile |
output_js |
Path to save the JavaScript file |
highlight_mode |
Use highlight mode, inherited from make_tile |
pkg_names |
Vector of package names (optional) |
focus |
Vector of package names to focus on (optional) |
Value
Called for its side effect; invisibly returns NULL. Writes a
JavaScript file to output_js containing base64-encoded image data and
dark/light mode CSS variable assignments.
Examples
img <- system.file("extdata/rectLight.png", package = "hexsession")
out <- tempfile(fileext = ".js")
generate_hexsession_js(
logopaths = img,
urls = "https://example.com",
dark_mode = FALSE,
output_js = out
)
Get loaded packages
Description
Get loaded packages
Usage
getLoaded()
Value
A character vector of the attached packages (excludes base packages)
Get package data
Description
Get package data
Usage
get_pkg_data(packages = NULL)
Arguments
packages |
Character vector of package names (default is NULL, uses loaded packages) |
Value
A list containing logopaths, urls, and package names
Extract the Most Frequent Color from an Image
Description
Internal helper. For a given image path, this functions uses k-means clustering to identify the most dominant color in the image.
Usage
maincolorRGB(imgpath)
Arguments
imgpath |
Character string. File path to the image. |
Value
A data frame with one row containing the RGB values of the dominant color. The column name is set to the input image path.
Create missing logos
Description
Create missing logos
Usage
make_missingLogos(attached_pkgs, logopaths)
Arguments
attached_pkgs |
Character vector of attached package names |
logopaths |
Vector of existing logo paths |
Value
Vector of paths to new logos
Generate tile of package logos
Description
Creates and returns an interactive html tile of the packages either listed in the packages argument, or all the packages attached to the search path. When rendered interactively, the result is output in the viewer. When rendered in Quarto or RMarkdown, the tile becomes part of the rendered html. revealjs presentations are now supported. If local images are provided, only these images will be used, excluding loaded packages.
Usage
make_tile(
packages = NULL,
local_images = NULL,
local_urls = NULL,
dark_mode = FALSE,
color_arrange = FALSE,
highlight_mode = FALSE,
focus = NULL,
output_dir = tempdir()
)
Arguments
packages |
A character vector of package names to include (defaults to NULL, which uses loaded packages) |
local_images |
Optional character vector of local image paths to add to the tile |
local_urls |
Optional character vector of URLs for each of the local images passed |
dark_mode |
Draw the tile on a dark background? |
color_arrange |
Logical, whether to arrange the images by color along the 'Lab' color space (defaults to FALSE) |
highlight_mode |
Logical, dim all images except on hover (defaults to FALSE) |
focus |
A character vector of package names to highlight, dimming all others (defaults to NULL) |
output_dir |
Directory where the intermediate js, rds, and HTML outputs are written. Defaults to |
Details
If an installed package does not have a bundled logo, or if the logo has been added to .Rbuildignore, a generic logo with the name of the package will be created instead. When the function cannot locate a package logo unambiguously, users will be prompted to select one from a list of potential options.
Set the execution options to output: asis in Quarto revealjs presentations to enable raw markdown output and adequate rendering of the tiles.
Value
The path to the output HTML file (invisibly) when called
interactively. A message() also prints the location. Returns an
htmltools HTML object when rendered inside Quarto or R Markdown.
Examples
img1 <- system.file("extdata/rectLight.png", package = "hexsession")
img2 <- system.file("extdata/rectMed.png", package = "hexsession")
img3 <- system.file("extdata/rectDark.png", package = "hexsession")
path <- make_tile(local_images = c(img1, img2, img3))
Get package URLs
Description
Get package URLs
Usage
pkgurls(pkgnames)
Arguments
pkgnames |
Character vector of package names |
Value
A vector of package URLs
Take screenshot of html image tile
Description
Take screenshot of html image tile
Usage
snap_tile(
output_path,
screen_width = 800,
screen_height = 700,
dark_mode = FALSE,
output_dir = getwd()
)
Arguments
output_path |
Path to image file |
screen_width |
Width of the browser window |
screen_height |
Height of the browser window |
dark_mode |
Is the tile being saved dark or light mode? |
output_dir |
Directory where |
Value
Path to the saved PNG image (the value of output_path).
Examples
snap_tile(tempfile(fileext = ".png"))