-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca347ee
commit 0af580d
Showing
13 changed files
with
184 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: emphatic | ||
Type: Package | ||
Title: Exploration of Data.Frames, Matrices using ANSI Colouring | ||
Version: 0.1.6.9002 | ||
Version: 0.1.6.9003 | ||
Author: mikefc | ||
Maintainer: mikefc <[email protected]> | ||
Description: Colour data.frame, matrix and vector output in the console. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
#' Convert R colours to hex colours | ||
#' | ||
#' @param colours Character vector of R colours | ||
#' | ||
#' @return Character vector of 6-char hex colours | ||
#' | ||
#' @noRd | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
col2hex_latex <- function(colours) { | ||
|
||
colours <- grDevices::col2rgb(colours) | ||
colours <- structure(sprintf("%02X", colours), dim = dim(colours)) | ||
colours <- apply(colours, 2, paste0, collapse = '') | ||
|
||
colours | ||
} | ||
|
||
|
||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
#' Convert a vector of colours to opening latex code for background colour | ||
#' | ||
#' @param colours Chcaracter vector of R colours | ||
#' | ||
#' @return Character vector of latex opening span tags | ||
#' | ||
#' @noRd | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
col2fill_latex <- function(colours) { | ||
no_colour <- is.na(colours) | colours == '' | ||
colours[no_colour] <- NA | ||
colours <- col2hex_latex(colours) | ||
|
||
ifelse( | ||
no_colour, | ||
"{", | ||
paste0("\\colorbox[HTML]{", colours, "}{") | ||
) | ||
|
||
} | ||
|
||
|
||
|
||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
#' Convert a vector of colours to opening latex code for text colour | ||
#' | ||
#' @param colours Chcaracter vector of R colours | ||
#' | ||
#' @return Character vector of latex opening span tags | ||
#' | ||
#' @noRd | ||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
col2text_latex <- function(colours) { | ||
no_colour <- is.na(colours) | colours == '' | ||
colours[no_colour] <- NA | ||
colours <- col2hex_latex(colours) | ||
|
||
ifelse( | ||
no_colour, | ||
"{", | ||
paste0("\\textcolor[HTML]{", colours, "}{") | ||
) | ||
|
||
} | ||
|
||
reset_latex <- "\\vrule height 3mm depth 1.25mm width 0mm}}" | ||
underline_on_latex <- r"(\underline{)" | ||
underline_off_latex <- "}" | ||
|
||
# res <- r"(\texttt{ | ||
# \colorbox{BurntOrange}{\textcolor[HTML]{AFFE90}{hello }}\colorbox[HTML]{AFFE90}{\textcolor{blue}{there}} | ||
# })" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.