Skip to content
Open
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
18 changes: 14 additions & 4 deletions hexwall.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ hexwall <- function(path, sticker_row_size = 16, sticker_width = 500, remove_sma
sort_mode <- match.arg(sort_mode)

# Load stickers
sticker_files <- list.files(path)
stickers <- file.path(path, sticker_files) %>%
stickers <- c() # Initialize empty vector
for(p in path) { # Setup a loop to make it vectorized
if(tools::file_ext(p) == "") {
# Surely a folder name
stickers <- c(stickers, file.path(p, list.files(p)) )
} else {
# Surely a direct path, add it "as is"
stickers <- c(stickers, p)
}
}

stickers <- stickers %>%
map(function(path){
switch(tools::file_ext(path),
svg = image_read_svg(path),
Expand All @@ -25,7 +35,7 @@ hexwall <- function(path, sticker_row_size = 16, sticker_width = 500, remove_sma
}) %>%
map(image_transparent, "white") %>%
map(image_trim) %>%
set_names(sticker_files)
set_names(stickers)

# Low resolution stickers
low_res <- stickers %>%
Expand Down Expand Up @@ -134,4 +144,4 @@ hexwall <- function(path, sticker_row_size = 16, sticker_width = 500, remove_sma
),
.init = canvas)
}
}
}