---
resource_files:
- figures/logo-dark.svg
- figures/logo.svg
title: "Getting Started with hexmakR"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Getting Started with hexmakR}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
[](https://github.com/CTTIR/hexmakR/actions/workflows/R-CMD-check.yaml)
[](https://cttir.github.io/hexmakR/)
[](https://app.codecov.io/gh/CTTIR/hexmakR?branch=main)
[](https://opensource.org/licenses/MIT)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.width = 3,
fig.height = 3.46 # 3 / (sqrt(3)/2) for correct hex ratio
)
# Files written by the examples go to a temporary folder.
knitr::opts_knit$set(root.dir = tempdir())
```
## Installation
Install the development package from GitHub:
```{r installation, eval = FALSE}
# install.packages("pak")
pak::pak("CTTIR/hexmakR")
```
## Start with a fresh logo
```{r fresh-logo}
library(hexmakR)
design <- logo_design("My package")
```
This creates a hexagonal frame and name with no archived scientific motif.
The name sits inside the lower part of the frame. A pentagon or square is
available with `shape = "pentagon"` or `shape = "square"`.
Add your own artwork as individually editable parts:
```{r first-parts}
design <- hex_add_part(design, "circle", x = .5, y = .6, r = .15)
design <- hex_add_part(design, "line",
x = c(.3, .7), y = c(.6, .6), col = "white", lwd = 3)
hex_layers(design)
print(design)
```
Parts have stable IDs such as `part_0001`. The native frame and name have
`layer_` IDs. Obtain the current IDs from `hex_layers()` before editing.
```{r edit-part}
design <- hex_edit_layer(design, "part_0001", fill = "#45B59A", dx = .04)
design <- hex_duplicate_part(design, "part_0001")
design <- hex_edit_layer(design, "part_0003", dx = -.2, scale = .7)
```
## Use an icon or archive artwork
All 46 generic icons remain available:
```{r icon-logo}
logo_design("Study", shape = "square", icon = "microscope")
```
Archive reuse is optional. Add selected artwork to the design you are making:
```{r archive-reuse}
head(hex_catalog())
design <- hex_reuse_part(design, "phenoscapR")
```
This imports the source motif's editable parts while retaining your name,
frame, palette and existing parts. An explicit `hex_design("phenoscapR")`
instead starts from that whole archived design. A call to `hex_design()`
without a package also starts fresh; `logo_design("My package")` is the direct
way to set your own project name.
## Save and continue later
Use `hex_import_art(design, "figure.png")` to add an embedded PNG/JPEG image,
or supply an SVG file for separately editable vector shapes. Supported SVG
curves become vector polylines. The editor provides the same feature under
**Add an image or vector drawing**. Uploads are capped at 10 MiB; outline text
and flatten gradients, masks or intersecting clips first. See `?hex_import_art`
for the supported SVG subset. Item labels and groups can be organised with
`hex_label_layer()` and `hex_group_layers()`.
```{r save-project, eval = capabilities("cairo")}
hex_save_design(design, "my-package.json")
restored <- hex_read_design("my-package.json")
hex_export(restored, "my-package.svg")
hex_export(restored, "my-package.png", width = 1600)
hex_export(restored, "my-package.pdf")
hex_recipe(restored, "reproduce.R")
```
PNG has a transparent exterior. SVG and PDF contain native vector artwork
and outlined name glyphs, so they do not depend on locally installed fonts.
JSON stores validated settings and parts; opening a project does not evaluate
R code. A project must fit within the same 20 MiB limit when saved and reopened.
## Open the manual editor
```{r launch-editor, eval = FALSE}
hexmakr_app()
```
The Designer opens a new logo. Add parts, select one, and use **Apply part
edit** after changing its colours, position, size, opacity or points.
Click a part to select it and drag it to move it. Rename items, organise groups
and switch the mouse target to move a whole group together. The CTTIR Gallery
tab is secondary; browsing it leaves the current logo unchanged.
The original generic sticker interface remains available through
`hexmakr_app(workspace = "classic")`. Its `hex_sticker()` function returns a
ggplot object and supports 28 themes, led by the nine CTTIR v5 families,
font choices including the bundled JetBrains Mono, and uploaded images.
See `vignette("cttir-library")` for archive reuse and editable projects, and
`vignette("shiny-app")` for the manual workflow.