The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
{bittermelon}
provides functions for creating and modifying bitmaps.bm_bitmap()
and bm_pixmap()
objects it also supports modifying {magick}
’s “magick-image” objects and base R’s “nativeRaster” and “raster” objects.library("bittermelon") # remotes::install_github("trevorld/bittermelon")
<- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font_file <- read_hex(font_file)
font <- as_bm_list("RSTATS", font = font)
bml # With vertical compression
<- bml |> bm_call(cbind) |> bm_compress("vertical")
bm print(bm)
██▀▀▀█▄ ▄█▀▀▀▀▀ ▀▀▀██▀▀▀▄█▀▀▀█▄ ▀▀▀██▀▀▀▄█▀▀▀▀▀
██ ██ ██ ██ ██ ██ ██ ██
██▀▀▀█▄ ▀▀▀▀█▄ ██ ██▀▀▀██ ██ ▀▀▀▀█▄
██ ██ ██ ██ ██ ██ ██ ██
██ ██ ▄▄▄▄▄█▀ ██ ██ ██ ██ ▄▄▄▄▄█▀
# Upside down with ASCII characters
<- bml |>
bm bm_flip("both") |>
bm_call(cbind, direction = "RTL")
print(bm, px = px_ascii)
------------------------------------------------
------------------------------------------------
------------------------------------------------
------------------------------------------------
--@@@@@@---@@----@@---@@---@@-----@@@@@@-@@---@@
-@@--------@@----@@---@@---@@----@@------@@---@@
-@@--------@@----@@---@@---@@----@@------@@---@@
-@@--------@@----@@---@@---@@----@@------@@---@@
-@@--------@@----@@---@@---@@----@@------@@---@@
--@@@@@----@@----@@@@@@@---@@-----@@@@@---@@@@@@
------@@---@@----@@---@@---@@---------@@-@@---@@
------@@---@@----@@---@@---@@---------@@-@@---@@
------@@---@@----@@---@@---@@---------@@-@@---@@
-@@@@@@-@@@@@@@@--@@@@@-@@@@@@@@-@@@@@@---@@@@@@
------------------------------------------------
------------------------------------------------
# With a shadow effect and borders
<- bml |>
bm bm_pad(sides = 2L) |>
bm_shadow() |>
bm_extend(sides = c(2L, 1L), value = 3L) |>
bm_call(cbind) |>
bm_pad(sides = 2L, value = 3L)
print(bm)
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓
▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓
▓▓░░██████░░░░▓▓░░░██████░░░▓▓░░████████░░░▓▓░░░█████░░░░▓▓░░████████░░░▓▓░░░██████░░░▓▓
▓▓░░██▒▒▒██░░░▓▓░░██▒▒▒▒▒▒░░▓▓░░░▒▒██▒▒▒▒░░▓▓░░██▒▒▒██░░░▓▓░░░▒▒██▒▒▒▒░░▓▓░░██▒▒▒▒▒▒░░▓▓
▓▓░░██▒░░██▒░░▓▓░░██▒░░░░░░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░░░░░░▓▓
▓▓░░██▒░░██▒░░▓▓░░██▒░░░░░░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░░░░░░▓▓
▓▓░░██████▒▒░░▓▓░░░█████░░░░▓▓░░░░░██▒░░░░░▓▓░░███████▒░░▓▓░░░░░██▒░░░░░▓▓░░░█████░░░░▓▓
▓▓░░██▒▒▒██░░░▓▓░░░░▒▒▒██░░░▓▓░░░░░██▒░░░░░▓▓░░██▒▒▒██▒░░▓▓░░░░░██▒░░░░░▓▓░░░░▒▒▒██░░░▓▓
▓▓░░██▒░░██▒░░▓▓░░░░░░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░░░░░░██▒░░▓▓
▓▓░░██▒░░██▒░░▓▓░░░░░░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░░░░░░██▒░░▓▓
▓▓░░██▒░░██▒░░▓▓░░░░░░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░░░░░░██▒░░▓▓
▓▓░░██▒░░██▒░░▓▓░░██████▒▒░░▓▓░░░░░██▒░░░░░▓▓░░██▒░░██▒░░▓▓░░░░░██▒░░░░░▓▓░░██████▒▒░░▓▓
▓▓░░░▒▒░░░▒▒░░▓▓░░░▒▒▒▒▒▒░░░▓▓░░░░░░▒▒░░░░░▓▓░░░▒▒░░░▒▒░░▓▓░░░░░░▒▒░░░░░▓▓░░░▒▒▒▒▒▒░░░▓▓
▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓
▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓░░░░░░░░░░░░░▓▓░░░░░░░░░░░░▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
We can also print colored terminal output with help of {cli}
:
if (cli::num_ansi_colors() >= 16L)
print(bm, px = " ",
bg = c(cli::bg_br_white, cli::bg_blue, cli::bg_cyan, cli::bg_red))
plot(bm, col = c("white", "blue3", "cyan3", "red3"))
# Also supports {gridpattern} matrices
::pattern_weave("twill_herringbone", nrow=14L, ncol = 50L) |>
gridpatternas_bm_bitmap() |>
print(compress = "vertical")
█▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█
█▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█
█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█ █▄ ▀█
▀▀▄▄▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▄▄▀
██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀
██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ █
█ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██ ▄█▀ ██
::pattern_square(subtype=8L, nrow=8L, ncol = 50L) |>
gridpatternas_bm_pixmap(s, col = grDevices::rainbow(8L)) |>
plot()
# Also supports {mazing} mazes
set.seed(42)
<- mazing::maze(16L, 32L)
m |> as_bm_bitmap(walls = TRUE) |>
m print(compress = "vertical")
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█▀▀▀█▀▀▀▀▀█▀▀▀▀▀▀▀▀▀▀▀█▀▀▀▀▀█▀▀▀▀▀▀▀█▀▀▀▀▀▀▀█▀▀▀█
█ █▀▀▀▀▀▀▀▀▀█ ▀▀▀ █ ▀ █ █ █ █ ▀▀█▀▀▀▀ ▀ █▀▀ █ █▀▀ █ ▀ █▀▀▀█ █ █ █
█ █ ▀▀▀▀█▀▀ ▀▀▀▀█▀█▀▀▀▀ █ █ █▀▀ █▀▀▀█▀█▀▀ █▀▀▀▀ █▀▀▀▀▀█ ▀▀▀ █ █ █
█ █▀▀ █▀▀ █▀▀▀▀ █ █ ▀▀█▀█ ▀▀█ █▀▀ █ █ ▀ ▀▀▀ █▀▀▀▀▀▀▀▀ █ ▀▀█▀▀▀▀ █
█ ▀▀▀▀█ █▀█ █▀▀▀▀ █▀▀ █ █▀▀ █ █ █▀█ ▀▀█▀▀▀▀▀█ █▀█ ▀▀▀▀▀▀▀ █ █ ▀▀█
█▀▀▀▀ █ █ ▀ █ █▀█ █ █▀▀ █ █▀▀ █ ▀ ▀▀█ █ █ ▀▀█ █ ▀▀▀▀▀▀█▀▀▀▀ ▀▀█ █
█ █▀▀▀▀ █ ▀▀█ █ ▀ █ █▀▀ █ █ █ ▀▀▀ █▀▀ █ █▀▀ █ ▀ █▀▀▀█ █▀▀▀▀▀▀▀█ █
█ ▀ █▀█▀▀▀▀ █ ▀▀▀▀█ █ █ █ ▀▀▀▀█ ▀▀█ ▀▀▀▀█ ▀▀▀▀▀▀▀ █ █ ▀ █▀▀▀█ ▀ █
█▀▀▀▀ █ █▀▀▀▀ ▀▀█ █ █ ▀▀▀▀▀▀█ █ █▀▀▀█▀▀ █ █▀▀▀▀ █▀▀▀█▀▀▀█ █ ▀▀█ █
█ ▀▀█ ▀ █ ▀▀█▀▀▀▀ █ ▀▀█ █ ▀▀▀ █ █ █ █ ▀▀█ █ █ █▀▀ █ ▀ █ ▀ ▀▀█ █ █
█▀▀ ▀▀▀▀▀▀█▀▀ █▀▀ █▀▀ █ █▀▀▀█ ▀▀▀ █ ▀▀▀ █▀▀ █▀▀ █▀▀▀█▀▀▀▀▀▀▀▀ █ █
█ █▀▀▀▀▀█ ▀ █▀▀ ▀▀█ ▀▀▀▀▀ █ █▀█▀▀▀▀▀▀▀▀▀▀ ▀▀█ █▀▀ █▀▀ █▀▀▀█ █▀▀ █
█ █ ▀▀█ █▀▀▀▀▀▀▀█ █▀▀▀▀▀█▀█ █ ▀ █▀▀▀█▀▀▀▀▀█ ▀ █▀▀ █ █▀▀ █ ▀▀█ █▀█
█ █▀█ █ ▀ █▀▀▀█ █ ▀▀█ █ ▀ █ █ ▀▀█ ▀▀▀ █ ▀▀▀▀▀▀▀ █ █ ▀ █▀▀▀█ █ █ █
█ █ █ █▀▀▀▀ █ █ ▀▀█ ▀ █ █▀▀ █▀█ █▀▀▀█ █▀▀ █▀▀▀█▀▀ █▀▀▀▀▀▀ █ ▀ █ █
█ ▀ █ ▀▀▀▀█ ▀▀▀▀▀ ▀▀▀▀▀▀▀ █▀▀ ▀ ▀ █ ▀▀▀ █▀▀ ▀▀▀ ▀▀▀▀▀▀▀ █ ▀▀▀▀▀ █
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
# Can also visualize the maze solutions
<- grDevices::palette.colors()
pal |> as_bm_pixmap(start = "top", end = "bottom",
m col = c(pal[6L], "white", pal[7L], pal[5L])) |>
bm_pad(sides = 1L) |>
plot()
# Contains some built-in farming crops sprites
<- farming_crops_16x16()
crops names(crops)
[1] "avocado" "cassava" "coffee" "corn" "cucumber"
[6] "eggplant" "grapes" "lemon" "melon" "orange"
[11] "pineapple" "potato" "rice" "rose" "strawberry"
[16] "sunflower" "tomato" "tulip" "turnip" "wheat"
<- crops$corn$portrait
corn <- crops$grapes$portrait
grapes <- crops$orange$stage5
orange <- crops$tulip$portrait
tulip <- cbind(corn, grapes, orange, tulip) pm
We can pretty print sprites to the terminal with help of {cli}
:
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L)
print(pm, compress = "v", bg = "white")
plot(pm)
{bittermelon}
has a builtin versions of the 8x16 Spleen font as well as 4x6 and 6x13 Fixed fonts.
<- read_hex(system.file("fonts/spleen/spleen-8x16.hex.gz",
spleen_8x16 package = "bittermelon"))
<- read_yaff(system.file("fonts/fixed/4x6.yaff.gz",
fixed_4x6 package = "bittermelon"))
<- read_yaff(system.file("fonts/fixed/5x8.yaff.gz",
fixed_5x8 package = "bittermelon"))
<- read_yaff(system.file("fonts/fixed/6x13.yaff.gz",
fixed_6x13 package = "bittermelon"))
as_bm_bitmap("RSTATS", font = spleen_8x16) |> bm_compress("v")
██▀▀▀█▄ ▄█▀▀▀▀▀ ▀▀▀██▀▀▀▄█▀▀▀█▄ ▀▀▀██▀▀▀▄█▀▀▀▀▀
██ ██ ██ ██ ██ ██ ██ ██
██▀▀▀█▄ ▀▀▀▀█▄ ██ ██▀▀▀██ ██ ▀▀▀▀█▄
██ ██ ██ ██ ██ ██ ██ ██
██ ██ ▄▄▄▄▄█▀ ██ ██ ██ ██ ▄▄▄▄▄█▀
as_bm_bitmap("RSTATS", font = fixed_4x6) |> bm_compress("v")
█▀▄ ▄▀▀ ▀█▀ ▄▀▄ ▀█▀ ▄▀▀
█▀▄ ▀▄ █ █▀█ █ ▀▄
▀ ▀ ▀▀ ▀ ▀ ▀ ▀ ▀▀
as_bm_bitmap("RSTATS", font = fixed_5x8) |> bm_compress("v")
▄▄▄ ▄▄ ▄▄▄ ▄▄ ▄▄▄ ▄▄
█ █ ▀▄ ▀ █ █ █ █ ▀▄ ▀
█▀▀▄ ▄ ▀▄ █ █▀▀█ █ ▄ ▀▄
▀ ▀ ▀▀ ▀ ▀ ▀ ▀ ▀▀
as_bm_bitmap("RSTATS", font = fixed_6x13) |> bm_compress("v")
█▀▀▀▄ ▄▀▀▀▄ ▀▀█▀▀ ▄▀▄ ▀▀█▀▀ ▄▀▀▀▄
█ █ █ █ █ █ █ █
█▀█▀ ▀▀▀▄ █ █▄▄▄█ █ ▀▀▀▄
█ ▀▄ ▄ █ █ █ █ █ ▄ █
▀ ▀ ▀▀▀ ▀ ▀ ▀ ▀ ▀▀▀
The {hexfont} package includes a helper function unifont()
which loads several GNU Unifont hex fonts as a single {bittermelon}
bm_font()
object. GNU Unifont is a monoscale bitmap font (8x16 and 16x16 glyphs) that pretty much covers all of the official Unicode glyphs plus several of the artificial scripts in the (Under-)ConScript Unicode Registry.
library("hexfont")
system.time(font <- unifont()) # Unifont is a **big** font
user system elapsed
101.054 0.180 101.259
length(font) |> prettyNum(big.mark = ",") # number of glyphs
[1] "125,472"
object.size(font) |> format(units = "MB") # memory used
[1] "198.7 Mb"
# Faster to load from a cache
system.time(font <- unifont(cache = TRUE))
user system elapsed
0.708 0.000 0.707
# Or just load the subset of GNU Unifont you need
<- "R很棒!"
s system.time(font_s <- unifont(ucp = str2ucp(s)))
user system elapsed
0.644 0.000 0.644
# Mandarin Chinese
as_bm_bitmap(s, font = font_s) |> bm_compress("v")
█ ▄▄▄▄▄▄▄ █ █
▄▄▄▄▄▄▄ ▄▀ █ █ █ ▀▀▀▀█▀▀▀▀ ▄█▄
█ ▀▄ ▀ █ █▀▀▀▀▀█ ▀▀▀█▀▀ ▀▀█▀▀▀▀ ███
█ ▄▀ ▄█ █▄▄▄▄▄█ ██▄ ▀▀█▀▀▀█▀▀ ▀█▀
█▀▀▀█▀ ▄▀ █ █ █ ▄▀ █ █ ▀▄▀ █ ▀▄ █
█ ▀▄ █ █ █▀ ▀ █ ▀▀█▀▀
▄█▄ ▄█▄ █ █ ▄ ▀▄ █ ▀▀▀▀█▀▀▀▀ █
█ █▀ ▀▀ █ █
# Emoji
as_bm_bitmap("🐭🐲🐵", font = font) |> bm_compress("v")
▄▄ ▄▄ ▄▄▄ ▄▄
▄▀ ▀▄▄▄▄▄▀ ▀▄ ▄█▀ ▄█▀██▀█▄
█ ▀ ▀ █ ▄████ ▄▀█ ▄▄ ▄▄ █▀▄
▄█ ▀ ▀ █▄ ▄▄██▄█████ ▀▄█ ▀▀ ▀▀ █▄▀
▄█▀ ▄ ▀█▄ ▄█▄███████████ ▄▀ ▀▄
▀▄ ▀▀▀ ▄▀ ▀▀▀▀▀███▀▀█████ █ ▀▄▄▄▄▀ █
▀▀▄▄▄▀▀ ▄███ ████▀ ▀▀▄▄▄▄▀▀
▀▀▀ ▀▀▀
# Klingon
as_bm_list("", font = font) |>
bm_pad(type = "trim", left = 1L, right = 1L) |>
bm_call(cbind) |>
bm_compress("v")
▄█▄ ▄▄██▀▀ ▀▀████████ ▄▀ ▄█▄ ▄█▀ ▀█▄ ▄▄
▄▄██████▀ ▀██ ▀ ▄█▀ ███▀▀ ███ ██ ▀████████
▀██ ██ ▄███ ▄█ ▄██ ██▀ ▀██▄▄█▀ ██▀ ▀██
▀ █▄ ███ ███▄▄▄▄▄██ ▄███ ▀███▀ ▄█▀ █▀
█▄ ▀█▄ ██▀▀▀▀▀▀███ ▄██████▄ ▀█▄ ▄█▀ █▀
▀▄ ▀▀▄ ▄▀ ▀█▄ ▀▀▄ ▀▀▄ ▄▀ ▀
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.