| Title: | A Dependency-Light Hex-Logo Builder |
|---|---|
| Description: | A simple interface to create hexagon-shaped logos that help promote your R package or other projects. Uses the 'grid' system. |
| Authors: | Matt Dray [aut, cre] |
| Maintainer: | Matt Dray <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.2 |
| Built: | 2026-05-09 07:24:17 UTC |
| Source: | https://github.com/matt-dray/gex |
Add a border of given thickness and colour to the inner edges of hexagon.
add_border(width = 0.05, col = "black")add_border(width = 0.05, col = "black")
width |
Numeric. Thickness of the border, expressed as the
inverse ratio of the interior of the hex to the full extent of the hex
(must be between |
col |
Character. Named R colour or hexadecimal code for the border around the hex. |
When building a hex, this function should be called after open_device, add_hex and any calls to add_text and add_image (in that order), and before close_device.
Named colour values must be listed in grDevices::colours(). Hexadecimal
colour values must be provided with length 6 or 8 and must begin with an
octothorpe (#).
NULL. Adds to an existing graphics device.
Other hex elements:
add_hex()
temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()
Add a hexagon 'canvas' to which elements can be added.
add_hex(col = "grey")add_hex(col = "grey")
col |
Character. Named R colour or hexadecimal code for the interior background. |
When building a hex, this function should be called after open_device. You can then use add_text, add_image and add_border (if desired) and finally close_device.
Named colour values must be listed in grDevices::colours(). Hexadecimal
colour values must be provided with length 6 or 8 and must begin with an
octothorpe (#).
NULL. Adds to an existing graphics device.
Other hex elements:
add_border()
temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()
Overlay an image on the hexagon. Call this function separately for each image you want to add.
add_image(img, x = 0.5, y = 0.7, angle = 0, width = 0.4)add_image(img, x = 0.5, y = 0.7, angle = 0, width = 0.4)
img |
Array. A PNG or JPEG file read in by the user, most likely using packages 'png' or 'jpeg'. |
x |
Numeric. Image location on the hexagon's x-axis. |
y |
Numeric. Image location on the hexagon's y-axis. |
angle |
Numeric. Text rotation in degrees. |
width |
Numeric. Image width. |
When building a hex, this function should be called after open_device and add_hex. You can then use further calls to add_image, add_text and add_border (if desired) and finally close_device.
Coordinates should be provided within the x- and y-axis ranges, which are both from 0 to 1, giving the centre as x = 0.5 and y = 0.5.
NULL. Adds to an existing graphics device.
Other hex content adders:
add_text()
temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()
Overlay text on the hexagon. Call this function separately for each string you want to add.
add_text( string = "example", x = 0.5, y = 0.4, angle = 0, size = 20, col = "black", family = "sans", face = c("plain", "bold", "italic", "bold.italic") )add_text( string = "example", x = 0.5, y = 0.4, angle = 0, size = 20, col = "black", family = "sans", face = c("plain", "bold", "italic", "bold.italic") )
string |
Character. Text to display. |
x |
Numeric. Text location on the hexagon's x-axis. |
y |
Numeric. Text location on the hexagon's y-axis. |
angle |
Numeric. Rotation of text string in degrees. Positive values will rotate anticlockwise by the given angle. |
size |
Numeric. Text point-size. |
col |
Character. Text colour. A named R colour or hexadecimal code. |
family |
Character. Name of a font family available on your system. |
face |
Character. Font face for the text. |
When building a hex, this function should be called after open_device and add_hex. You can then use further calls to add_text, add_image and add_border (if desired) and finally close_device.
Coordinates should be provided within the x- and y-axis ranges, which are both from 0 to 1, giving the centre as x = 0.5 and y = 0.5.
Named colour values must be listed in grDevices::colours(). Hexadecimal
colour values must be provided with length 6 or 8 and must begin with an
octothorpe (#).
NULL. Adds to an existing graphics device.
Other hex content adders:
add_image()
temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()
Clip to the area of the outer hexagon and shut down the PNG plot device,
which writes to the file_path specified in open_device.
close_device()close_device()
When building a hex, this function should be called at the end, after open_device, add_hex and any calls to add_text, add_image and add_border.
Named numeric. The device name and number where the hex has been written.
Other hex device handlers:
open_device()
temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()
Begin a PNG plot device with dimensions matching the Stickers Standard: 4.39 cm wide by 5.08 cm high (2 by 1.73 inches).
open_device(file_path, resolution = 300)open_device(file_path, resolution = 300)
file_path |
Character. File path to a .png where the output file will be saved. The containing directory must already exist. |
resolution |
Numeric. Resolution of the graphics device in pixels per inch (ppi). Higher values have better resolution but create larger file sizes. |
When building a hex, this function should be called first, followed by add_hex. You can then use add_text, add_image and add_border (if desired) and finally close_device.
Nothing. A graphics device is opened.
Other hex device handlers:
close_device()
temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()temp_path <- tempfile(fileext = ".png") open_device(temp_path) add_hex() img_path <- system.file("img", "Rlogo.png", package = "png") img_png <- png::readPNG(img_path) add_image(img_png) add_text() add_border() close_device()