Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions data-raw/Hex/CreateHex.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,87 @@

# devtools::install_github("GuangchuangYu/hexSticker")

library(magick)

# 1. Load your background image
img <- image_read("minpatch_balanced.png")
info <- image_info(img)
w <- info$width
h <- info$height

# 2. Open the magick drawing device
mask <- image_blank(w, h, color = "transparent")
img_mask <- image_draw(mask)

# 3. Scale the Hexagon down (80% of image height)
# This provides a 10% margin at the top and 10% at the bottom
hex_h <- h * 0.8
hex_w <- hex_h * (sqrt(3)/2)

# Calculate the start points to keep it perfectly centered
start_y <- (h - hex_h) / 2
start_x <- (w - hex_w) / 2

# Precise "Pointy-Topped" coordinates with space around them
x_coords <- c(w/2, w - start_x, w - start_x, w/2, start_x, start_x)
y_coords <- c(start_y, start_y + (hex_h * 0.25), start_y + (hex_h * 0.75), h - start_y, start_y + (hex_h * 0.75), start_y + (hex_h * 0.25))

# 4. Draw the polygon
polygon(x_coords, y_coords, col = "white", border = NA)
dev.off()

# 5. Clip and Save
clipped_img <- image_composite(img_mask, img, operator = "In")

# Trim the excess transparency so the hexSticker package
# doesn't have to deal with a lot of empty space
final_img <- image_trim(clipped_img)
image_write(final_img, "minpatch_centered_hex.png")


hexSticker::sticker(
subplot = "minpatch_centered_hex.png",
package = "minPatch",
p_size = 86,
p_y = 1.2,
p_color = "#00441b",
s_x = 1,
s_y = 1,
s_width = 0.8,
s_height = 0.8,
h_fill = "#FFFFFF",
h_color = "#00441b",
filename = "minpatch.png",
dpi = 1000,
)

# First, load a nice font (requires sysfonts)
sysfonts::font_add_google("Montserrat", "montserrat")
showtext::showtext_auto()

hexSticker::sticker(
subplot = "minpatch_centered_hex.png",
package = "minPatch",
p_size = 86, # Adjusted for showtext/standard scaling
p_y = 1.15, # Lowered slightly to feel more centered
p_color = "#00441b",
p_family = "sans", # Or "montserrat" if loaded
p_fontface = "bold", # Bold is key for the 'pop'
s_x = 1,
s_y = 1,
s_width = 0.8, # Since we pre-cropped, let's fill the hex
s_height = 0.8,
h_fill = "#FFFFFF",
h_color = "#00441b", # Match border to text for a 'unified' look
h_size = 1.5, # Slightly thicker border adds 'premium' feel
spotlight = TRUE, # Adds a subtle radial gradient to the background
l_alpha = 0.3, # Softness of the spotlight
filename = "data-raw/minpatch.png",
dpi = 1000
)






Expand Down
Binary file added data-raw/minpatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.