From 4495829879abeca00b58f7298f3b7b196a334143 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Agostino Date: Mon, 13 Jun 2022 12:27:44 +0800 Subject: [PATCH] added compression as mentioned in issue #2 --- NAMESPACE | 1 + R/alamak.R | 140 ++++++++++++++++++++++++++++++++---------- R/pixpals.R | 16 +++-- R/sysdata.rda | Bin 3392 -> 3646 bytes man/alamak.Rd | 14 ++++- man/compressPixPal.Rd | 27 ++++++++ man/makePixPal.Rd | 5 +- man/pixpals.Rd | 18 ++++++ 8 files changed, 178 insertions(+), 43 deletions(-) create mode 100644 man/compressPixPal.Rd create mode 100644 man/pixpals.Rd diff --git a/NAMESPACE b/NAMESPACE index ddc80a8..b385307 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(alamak) export(makePixPal) importFrom(cli,console_width) +importFrom(crayon,combine_styles) importFrom(crayon,make_style) importFrom(crayon,red) importFrom(grDevices,rgb) diff --git a/R/alamak.R b/R/alamak.R index 30178a6..afe4b29 100644 --- a/R/alamak.R +++ b/R/alamak.R @@ -4,11 +4,13 @@ #' Generates a pixel pal from a PNG file #' #' @param filepath a character indicating a path to a .PNG file. +#' @param compress logical, should the Pixel Pal be compressed to take up fewer +#' spaces in the terminal? Default is TRUE. #' #' @return a character string converted to color ASCII through \code{crayon} #' #' @importFrom png readPNG -#' @importFrom crayon make_style +#' @importFrom crayon make_style combine_styles #' @importFrom grDevices rgb #' #' @examples @@ -34,7 +36,7 @@ #' #' @export -makePixPal <- function(filepath) { +makePixPal <- function(filepath, compress = TRUE) { pix = readPNG(filepath, native = FALSE) @@ -42,13 +44,17 @@ makePixPal <- function(filepath) { pix = matrix(pixcols, nrow = dim(pix)[1], byrow = TRUE) - crayonstrings <- matrix( - unlist(sapply(pixcols, function(x) { - make_style(x, bg = TRUE)(" ")})), - nrow = nrow(pix)) + if(compress) { + crayonstrings <- compressPixPal(pix) + } else { + crayonstrings <- matrix( + unlist(sapply(pixcols, function(x) { + make_style(x, bg = TRUE)(" ")})), + nrow = nrow(pix)) - crayonstrings[t(pix) == "#00000000"] = " " - crayonstrings[,ncol(crayonstrings)] <- paste(crayonstrings[,ncol(crayonstrings)], "\n", sep = "") + crayonstrings[t(pix) == "#00000000"] = " " + crayonstrings[,ncol(crayonstrings)] <- paste(crayonstrings[,ncol(crayonstrings)], "\n", sep = "") + } return(crayonstrings) } @@ -70,8 +76,15 @@ makePixPal <- function(filepath) { #' #' @examples #' +#' # Error message #' alamak(a + 4) #' +#' # Warning message +#' alamak(as.numeric("alamak")) +#' +#' # Change Pixel Pal +#' alamak(as.numeric("alamak"), "Lenny") +#' #' @importFrom crayon red #' @importFrom cli console_width #' @@ -79,6 +92,7 @@ makePixPal <- function(filepath) { alamak <- function(f, pixpal = "Jerry"){ + # Input checks if(all(class(pixpal) == "character" & pixpal %in% c("Jerry", "Lenny", "Buster", "Oniji", "E10N"))) { pixpal = pixpals[[pixpal]] } else if(class(pixpal) != "list") { @@ -92,36 +106,37 @@ alamak <- function(f, pixpal = "Jerry"){ stop("Not a valid Pixel Pal! Needs \"Error\" and \"Warning\" elements. See ?makePixPal for an example") } - warns = list() - errs = list() + #Error catching + warnings = list() + errors = list() out <- tryCatch(withCallingHandlers( expr = f, - warning = function(w) { - warns <<- c(warns, list(w)) - invokeRestart("muffleWarning") - }), - + warnings <<- c(warnings, list(w)) + invokeRestart("muffleWarning")}), error = function(e) { - errs <<- c(errs, list(e)) - } + errors <<- c(errors, list(e))} ) - if(length(errs) > 0 | length(warns) > 0) { - if(length(errs) > 0){ + if(length(errors) > 0 | length(warnings) > 0) { + + if(length(errors) > 0){ errtype = "Error" - errmess = paste0(errtype, ": ", unlist(lapply(errs, function(x) { + errmess = paste0(errtype, ": ", unlist(lapply(errors, function(x) { mess = gsub(x = as.character(x$message), pattern = "\\033\\[[0-9][0-9+]m", replacement = "", perl = TRUE) return(mess) }))) - } else if(length(warns) > 0) { + } else if(length(warnings) > 0) { errtype = "Warning" - errmess = paste0(errtype, ": ", unlist(lapply(warns, function(x) { + errmess = paste0(errtype, ": ", unlist(lapply(warnings, function(x) { mess = gsub(x = as.character(x$message), pattern = "\\033\\[[3[0-9+]m", replacement = "", perl = TRUE) return(mess) }))) } + + # Message wrangling + pal = pixpal$crayon consolew = min(2*console_width() - 2 - ncol(pal), 100) @@ -143,11 +158,8 @@ alamak <- function(f, pixpal = "Jerry"){ max_text_col = column_sizes[max_col_size] - #print(max_text_col) - #print(message_to_add[1]) - - finalmess = c(" ", rep("_", max_text_col), "____\n|", - rep(" ", max_text_col), " |\n") + finalmess = c("\u250c", rep("\u2500", max_text_col + 3), "\u2510\n\u2502", + rep(" ", max_text_col), " \u2502\n") for(i in message_to_add) { if(grepl("\\033\\[31", i, perl = TRUE)) { @@ -156,11 +168,12 @@ alamak <- function(f, pixpal = "Jerry"){ padding = nchar(i) } finalmess = c(finalmess, - "| ", i, - rep(" ", max_text_col - padding), " |\n") + "\u2502 ", i, + rep(" ", max_text_col - padding), " \u2502\n") } - finalmess = c(finalmess, "|_", rep("_", max_text_col), "___|\n") + finalmess = c(finalmess, "\u2502", rep(" ", max_text_col + 3), "\u2502\n", + "\u2514", rep("\u2500", max_text_col + 3), "\u2518\n") finalmess_print = unlist(strsplit(paste0(finalmess, collapse = ""), split = "\n")) @@ -168,7 +181,7 @@ alamak <- function(f, pixpal = "Jerry"){ if(difference > 0) { pal = rbind(pal, do.call(rbind, - lapply(seq_len(difference), function(x) c(rep(" ", ncol(pal)-1), " \n")) + lapply(seq_len(difference), function(x) c(rep(" ", ncol(pal)-1), "\n")) ) ) } @@ -181,12 +194,71 @@ alamak <- function(f, pixpal = "Jerry"){ crayonmap_with_message[right_lines[i]] = gsub(x = crayonmap[right_lines[i]], pattern = "\n", replacement = paste0(" ", finalmess_print[i], "\n")) - } - cat(crayonmap_with_message, sep = "") + } + + # Printing + cat("\n", crayonmap_with_message, "\n", sep = "") } - if(length(errs) == 0) return(out) + if(length(errors) == 0) return(out) + +} + +#' Compress a pixel pal +#' +#' Compresses a pixel pal using Unicode Blocks +#' +#' @param pix a character indicating a path to a .PNG file. +#' +#' @return returns a compressed Pixel Pal character matrix that occupies half the +#' space in the terminal +#' +#' @details Internal use only. Note: the Apple Terminal does not deal well with +#' Unicode blocks. When the package is loaded, if Apple Terminal is detected, +#' compression is disabled. +#' +#' @references kindly suggested in https://github.com/gdagstn/alamak/issues/2 +#' by Trevor L. Davis +#' +#' @importFrom crayon make_style combine_styles + +compressPixPal <- function(pix){ + + pix = t(pix) + + complist = list() + + for(i in seq(1,nrow(pix), by = 2)) { + + two_rows = t(pix[i:(i + 1),]) + + compressed = apply(two_rows, 1, function(x) { + + if(x[1] == "#00000000" & x[2] != "#00000000") { + background1 = FALSE + x[1] = x[2] + pixel_char = "\u2584" + } else if(x[1] != "#00000000" & x[2] == "#00000000") { + x[2] = x[1] + background1 = FALSE + pixel_char = "\u2580" + } else if(x[1] == "#00000000" & x[2] == "#00000000"){ + background1 = FALSE + pixel_char = " " + } else if(x[1] != "#00000000" & x[2] != "#00000000"){ + background1 = TRUE + pixel_char = "\u2584" + } + + combine_styles(make_style(x[1], bg = background1), + make_style(x[2], bg = FALSE))(pixel_char) + }) + + complist[[i]] = c(compressed, "\n") + + } + return(do.call(rbind, complist[!is.null(complist)])) } diff --git a/R/pixpals.R b/R/pixpals.R index d69f61f..cf57a85 100644 --- a/R/pixpals.R +++ b/R/pixpals.R @@ -1,6 +1,12 @@ +#' Code to create initial Pixel Pals +#' Sourced on loading + pixpals = list() -pixpals$Buster = list("crayon" = makePixPal("inst/extdata/buster.png"), +term = Sys.getenv("TERM_PROGRAM") +if(term == "Apple_Terminal") compression = FALSE else compression = TRUE + +pixpals$Buster = list("crayon" = makePixPal("inst/extdata/buster.png", compress = compression), "messages" = list( @@ -23,7 +29,7 @@ pixpals$Buster = list("crayon" = makePixPal("inst/extdata/buster.png"), ) ) -pixpals$Jerry = list("crayon" = makePixPal("inst/extdata/jerry.png"), +pixpals$Jerry = list("crayon" = makePixPal("inst/extdata/jerry.png", compress = compression), "messages" = list( @@ -52,7 +58,7 @@ pixpals$Jerry = list("crayon" = makePixPal("inst/extdata/jerry.png"), ) ) -pixpals$Oniji = list("crayon" = makePixPal("inst/extdata/oniji.png"), +pixpals$Oniji = list("crayon" = makePixPal("inst/extdata/oniji.png", compress = compression), "messages" = list( "Error" = c("A single function / Mysterious operations / It has failed again.", @@ -73,7 +79,7 @@ pixpals$Oniji = list("crayon" = makePixPal("inst/extdata/oniji.png"), ) -pixpals$Lenny = list("crayon" = makePixPal("inst/extdata/lenny.png"), +pixpals$Lenny = list("crayon" = makePixPal("inst/extdata/lenny.png", compress = compression), "messages" = list( "Error" = c("You got this!", @@ -100,7 +106,7 @@ pixpals$Lenny = list("crayon" = makePixPal("inst/extdata/lenny.png"), ) ) -pixpals$E10N = list("crayon" = makePixPal("inst/extdata/e10n.png"), +pixpals$E10N = list("crayon" = makePixPal("inst/extdata/e10n.png", compress = compression), "messages" = list( diff --git a/R/sysdata.rda b/R/sysdata.rda index fbcffec18b5564c2705e101b9736485b74076019..5dd3edd3768b682380ff9936c67ebc2284c880bd 100644 GIT binary patch literal 3646 zcmV-E4#Dw4T4*^jL0KkKS!zwMF90fS|Kb1peog=X|NZ~}-{?R8|L{aW0RRvH00H0; z|9rF=Rk#9!X8-^I4d*M$`LRijty_ENq_;Th73H(8?V2k~!KQ>vKurY7W=%||qflgM zdO@Sq4FEJ4ng9<`r=-cC8fXYXG|-w&H8nO->JLp#2Gjwd&;S4c00u+U281OKQKo}U zG-v<~02qxL18RDYPRr^)e#Ih1t2tXav``q2^v`7 zCL{>ll$g*MR2G3R=G2EHrTwA`AkZtgFZqP$UNM%?E$;XSN6~iU;OFVA*#& zDL&foklchRb&FmR|FS=xMb1m$g1l1*|yHLhOF+aCDc%1orZ^58QFG%FMNWK z5(2;^qRJ0j@wkWxRzfJf6SRnEY-M3!19=q(>IH}qh!7GG7v13y^R%nFLn$Yi@aoi; z`pATZ1gJ>OKvF7D(8|op%}N6;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$eobwwPStd!_XkQg*dL(u3b6|M`OIHWiq zB_KrtB26+veCir7yu`rOXG(pH_p?hVavOuB8B4Bl1`#Ei4FnD^M*S}{@Ik}nM zy*{1Q4`Cw3L|6)^6S2v=7EWU#@xLStW_RGaMX8p`TE$w70+}#_wDA%KXLB)awT$lb zNT5ch$3|3wD3)-G_(QQ2R7Igp8)H=>3oxZsG?huKsdXoMQSa;OcldGdvB3_tfqv|O zkdo1G)8(QJ2PBz9oLFsZ(5o$P1OE~uFuRbf&P10DflW|?ghLpK4lJ~_04njU;B(02 z`!Jx((FY6Eqp5>qON%F~=JIL34hC4eKQLdUkg`Zl%@#=)&jDd zvhZbS^_X0V?z$`<5m2QO3<=_4Nt=AA3lS$i_S3YiTW`nP)$HlEi>i};RkupO;W2a; zz@o{{l-kuT=S|`n-&NU8Z!YH;vJ{S4684a#J#E?zVI1ID+N{r0!LP}PKdIC9zwSmw8 zBm}haXu)7ka`!BwZk&$2PIHHs5SwPX4zh6+p&+WV1OrLk1xXC2Lm~g4x(O&C7fUCt zo!5)!BGwzU9jQ3PJXKx(S}P&9cQ1AFA?z46NrLkLw>nxkW>B1vd#ih*)I>(31k`YP zq;DlclnBKI2;hZ^mbZA-ByK0rM+nQqtfFX)283L#D?Ac&V-|I1+OtIJSrDe}<};yw WU9Uw0^c`_O;_gVN3KAK`GXx;6Fz%lK diff --git a/man/alamak.Rd b/man/alamak.Rd index 27ef7b0..29d68c8 100644 --- a/man/alamak.Rd +++ b/man/alamak.Rd @@ -10,9 +10,10 @@ alamak(f, pixpal = "Jerry") \item{f}{a function} \item{pixpal}{a Pixel Pal, one of "Lenny" (supportive velociraptor), "Buster" -(cool lemon), "Jerry" (a parrot that hates you) and "Oniji" (Edo period -Japanese kabuki actor who speaks in haiku only). Alternatively, a Pixel -Pal made following the instructions at \code{?makePixPal}.} +(cool lemon), "Jerry" (a parrot that hates you), "Oniji" (Edo period +Japanese kabuki actor who speaks in haiku only), and "E10N" (a robot from +the future). Alternatively, a Pixel Pal can be created manually following +the instructions at \code{?makePixPal}.} } \value{ the output of \code{f} if there are no errors, otherwise @@ -25,6 +26,13 @@ Catches an error or warning and lets a pixel pal tell you all about it } \examples{ +# Error message alamak(a + 4) +# Warning message +alamak(as.numeric("alamak")) + +# Change Pixel Pal +alamak(as.numeric("alamak"), "Lenny") + } diff --git a/man/compressPixPal.Rd b/man/compressPixPal.Rd new file mode 100644 index 0000000..31cee37 --- /dev/null +++ b/man/compressPixPal.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/alamak.R +\name{compressPixPal} +\alias{compressPixPal} +\title{Compress a pixel pal} +\usage{ +compressPixPal(pix) +} +\arguments{ +\item{pix}{a character indicating a path to a .PNG file.} +} +\value{ +returns a compressed Pixel Pal character matrix that occupies half the + space in the terminal +} +\description{ +Compresses a pixel pal using Unicode Blocks +} +\details{ +Internal use only. Note: the Apple Terminal does not deal well with + Unicode blocks. When the package is loaded, if Apple Terminal is detected, + compression is disabled. +} +\references{ +kindly suggested in https://github.com/gdagstn/alamak/issues/2 + by Trevor L. Davis +} diff --git a/man/makePixPal.Rd b/man/makePixPal.Rd index 6e04345..e84ebbc 100644 --- a/man/makePixPal.Rd +++ b/man/makePixPal.Rd @@ -4,10 +4,13 @@ \alias{makePixPal} \title{Make a pixel pal} \usage{ -makePixPal(filepath) +makePixPal(filepath, compress = TRUE) } \arguments{ \item{filepath}{a character indicating a path to a .PNG file.} + +\item{compress}{logical, should the Pixel Pal be compressed to take up fewer +spaces in the terminal? Default is TRUE.} } \value{ a character string converted to color ASCII through \code{crayon} diff --git a/man/pixpals.Rd b/man/pixpals.Rd new file mode 100644 index 0000000..50b4579 --- /dev/null +++ b/man/pixpals.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pixpals.R +\docType{data} +\name{pixpals} +\alias{pixpals} +\title{Code to create initial Pixel Pals +Sourced on loading} +\format{ +An object of class \code{list} of length 5. +} +\usage{ +pixpals +} +\description{ +Code to create initial Pixel Pals +Sourced on loading +} +\keyword{datasets}