Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #9

Merged
merged 7 commits into from
Oct 20, 2019
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
^inst\docs\.Rmd$
^cran-comments\.md$
^CRAN-RELEASE$
^pkgdown$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.Ruserdata
*.txt
inst/docs/
inst/doc
8 changes: 6 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: tvthemes
Title: TV Show Themes and Color Palettes for 'ggplot2' Graphics
Version: 1.0.0
Version: 1.1.0
Authors@R:
person(given = "Ryo",
family = "Nakagawara",
Expand All @@ -28,7 +28,11 @@ Suggests:
dplyr (>= 0.8.0.1),
spelling (>= 2.0),
cowplot (>= 0.9.4),
png (>= 0.1-7)
png (>= 0.1-7),
stringr,
knitr,
rmarkdown
URL: https://github.com/Ryo-N7/tvthemes
BugReports: https://github.com/Ryo-N7/tvthemes/issues
Language: en-US
VignetteBuilder: knitr
15 changes: 14 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,33 @@

export(attackOnTitan_pal)
export(avatarTLA_pal)
export(avatar_pal)
export(bigHero6_pal)
export(brooklyn99_pal)
export(gravityFalls_pal)
export(hilda_pal)
export(import_ChelseaMarket)
export(import_avatar)
export(import_chelseaMarket)
export(import_cinzel)
export(import_gravitationFalls)
export(import_rickAndMorty)
export(import_robotoCondensed)
export(import_roboto_condensed)
export(import_simpsons)
export(import_spongeBob)
export(import_theLastAirbender)
export(import_titilliumWeb)
export(import_titillium_web)
export(kimPossible_pal)
export(paintBikiniBottom)
export(parksAndRec_pal)
export(rickAndMorty_pal)
export(scale_color_attackOnTitan)
export(scale_color_avatar)
export(scale_color_avatarTLA)
export(scale_color_bigHero6)
export(scale_color_brooklyn99)
export(scale_color_gravityFalls)
export(scale_color_hilda)
export(scale_color_kimPossible)
export(scale_color_parksAndRec)
Expand All @@ -29,9 +37,11 @@ export(scale_color_simpsons)
export(scale_color_spongeBob)
export(scale_color_westeros)
export(scale_colour_attackOnTitan)
export(scale_colour_avatar)
export(scale_colour_avatarTLA)
export(scale_colour_bigHero6)
export(scale_colour_brooklyn99)
export(scale_colour_gravityFalls)
export(scale_colour_hilda)
export(scale_colour_kimPossible)
export(scale_colour_parksAndRec)
Expand All @@ -40,9 +50,11 @@ export(scale_colour_simpsons)
export(scale_colour_spongeBob)
export(scale_colour_westeros)
export(scale_fill_attackOnTitan)
export(scale_fill_avatar)
export(scale_fill_avatarTLA)
export(scale_fill_bigHero6)
export(scale_fill_brooklyn99)
export(scale_fill_gravityFalls)
export(scale_fill_hilda)
export(scale_fill_kimPossible)
export(scale_fill_parksAndRec)
Expand All @@ -52,6 +64,7 @@ export(scale_fill_spongeBob)
export(scale_fill_westeros)
export(simpsons_pal)
export(spongeBob_pal)
export(theme_avatar)
export(theme_brooklyn99)
export(theme_hildaDay)
export(theme_hildaDusk)
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# tvthemes 1.1.0

* New palette:
* Gravity Falls
* New font:
* "Gravitation Falls"
* Renamed functions to fit `*_camelCase()` style:
* `import_titilliumWeb()`, `import_robotoCondensed()`, `import_chelseaMarket()`
* Renamed 'Avatar: The Last Airbender' functions:
* `scale_*_avatar()`, `theme_avatar()`
* Deprecated functions:
* `import_titillium_web()`, `import_roboto_condensed()`, `scale_*_avatarTLA()`,
`theme_theLastAirbender()`
* Deleted functions:
* `import_ChelseaMarket()` (replaced by `import_chelseaMarket()`)
* Added `{packagedown}` website
* Split README into vignettes
* Added more tests

# tvthemes 1.0.0

* Released on CRAN! (September 3rd, 2019)
Expand Down
117 changes: 117 additions & 0 deletions R/gravityfalls_palette.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
gravityFalls_palette <- c(
"#417BA1", ## dipper light blue
"#ff1493", ## mabel pink #DF504C
"#ffff2e", ## bill cipher yellow #ffff2e #fff400
"#345634", ## soos green
"#8b0000", ## fez burgundy #8b0000 #732335
"#ff6700", ## wendy orange
"#93C0D5", ## lil gideon skyblue
"#8b4513", ## mcgucket brown #8b4513 #8E6537
"#9248A7", ## pacifica purple
"#1c8859", ## wendy green
"#474747", ## grunkle grey
"#8fbc8f", ## sheriff blubs green
"#d2b48c", ## stanford coat beige #d2b48c #dfbe58
"#000000" ## robbie black
)

#' @title Gravity Falls palette
#' @description Gravity Falls palette
#' @inheritDotParams ggplot2::discrete_scale
#' @param n number of colors
#' @param type discrete or continuous
#' @param reverse reverse order, Default: FALSE
#' @rdname gravityFalls_pal
#' @export
#' @examples
#' library(scales)
#' show_col(gravityFalls_pal()(5))
#' @importFrom scales manual_pal
#' @importFrom glue glue
#' @importFrom grDevices colorRampPalette

gravityFalls_pal <- function(n, type = c("discrete", "continuous"),
reverse = FALSE){
gravityFalls <- gravityFalls_palette

if (reverse == TRUE) {
gravityFalls <- rev(gravityFalls)
}

if (missing(n)) {
n <- length(gravityFalls)
}

type <- match.arg(type)

if (type == "discrete" && n > length(gravityFalls)) {
stop(glue::glue("Palette does not have {n} colors, maximum is {length(gravityFalls)}!"))
}

gravityFalls <- switch(type,
continuous = grDevices::colorRampPalette(gravityFalls)(n),
discrete = gravityFalls[1:n])

gravityFalls <- scales::manual_pal(gravityFalls)

return(gravityFalls)
}

#' @title scale_color_gravityFalls
#' @rdname gravityFalls_pal
#' @export
#' @examples
#'
#' library(ggplot2)
#' ggplot(airquality, aes(x = Day, y = Temp,
#' group = as.factor(Month), color = as.factor(Month))) +
#' geom_point(size = 3.5) +
#' scale_color_gravityFalls()
#' @importFrom ggplot2 discrete_scale scale_color_gradientn

scale_color_gravityFalls <- function(n, type = "discrete",
reverse = FALSE, ...){
if (type == "discrete") {
ggplot2::discrete_scale("color", "gravityFalls",
gravityFalls_pal(n = n, type = type,
reverse = reverse), ...)
} else { ## needs work...
ggplot2::scale_color_gradientn(colors = gravityFalls_pal(n = n, type = type,
reverse = reverse)(8))
}
}

#' @title scale_colour_gravityFalls
#' @rdname gravityFalls_pal
#' @export
#' @examples
#'
#' ggplot(airquality, aes(x = Day, y = Temp,
#' group = as.factor(Month), color = as.factor(Month))) +
#' geom_point(size = 3.5) +
#' scale_colour_gravityFalls()
#' @importFrom ggplot2 discrete_scale scale_color_gradientn

scale_colour_gravityFalls <- scale_color_gravityFalls

#' @title scale_fill_gravityFalls
#' @rdname gravityFalls_pal
#' @export
#' @examples
#'
#' ggplot(mpg, aes(displ)) +
#' geom_histogram(aes(fill = class), col = "black", size = 0.1) +
#' scale_fill_gravityFalls()
#' @importFrom ggplot2 discrete_scale scale_fill_gradientn

scale_fill_gravityFalls <- function(n, type = "discrete",
reverse = FALSE, ...){
if (type == "discrete") {
ggplot2::discrete_scale("fill", "gravityFalls",
gravityFalls_pal(n = n, type = type,
reverse = reverse), ...)
} else { ## needs work...
ggplot2::scale_fill_gradientn(colors = gravityFalls_pal(n = n, type = type,
reverse = reverse)(8))
}
}
98 changes: 96 additions & 2 deletions R/import_fonts.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@
#' @importFrom extrafont font_import

import_titillium_web <- function() {
.Deprecated("import_titiliumWeb")
titillium_web_font_dir <- system.file("fonts", "Titillium-Web", package = "tvthemes")

suppressWarnings(suppressMessages(extrafont::font_import(paths = titillium_web_font_dir, prompt = FALSE)))

message(
sprintf(
"You should install these fonts on your system directly. The files are located in [%s]",
titillium_web_font_dir
)
)
}

#' @title import_titilliumWeb
#' @description Imports Titillium Web
#' @details import_*() functions taken from hrbrthemes.
#' @seealso
#' \code{\link[extrafont]{font_import}}
#' @rdname import_titilliumWeb
#' @export
#' @importFrom extrafont font_import

import_titilliumWeb <- function() {

titillium_web_font_dir <- system.file("fonts", "Titillium-Web", package = "tvthemes")

Expand All @@ -32,6 +55,29 @@ import_titillium_web <- function() {
#' @importFrom extrafont font_import

import_roboto_condensed <- function() {
.Deprecated("import_robotoCondensed")
rc_font_dir <- system.file("fonts", "Roboto-Condensed", package = "tvthemes")

suppressWarnings(suppressMessages(extrafont::font_import(paths = rc_font_dir, prompt = FALSE)))

message(
sprintf(
"You will likely need to install these fonts on your system as well.\n\nYou can find them in [%s]",
rc_font_dir)
)
}

#' @title import_robotoCondensed
#' @description taken from hrbrthemes
#' @details import_*() functions taken from hrbrthemes.
#' You may still need to install each font on your system directly by finding the .ttf file and clicking "Install".
#' @seealso
#' \code{\link[extrafont]{font_import}}
#' @rdname import_robotoCondensed
#' @export
#' @importFrom extrafont font_import

import_robotoCondensed <- function() {

rc_font_dir <- system.file("fonts", "Roboto-Condensed", package = "tvthemes")

Expand Down Expand Up @@ -144,6 +190,29 @@ import_spongeBob <- function() {
#' @importFrom extrafont font_import

import_theLastAirbender <- function() {
.Deprecated("import_avatar")
theLastAirbender_font_dir <- system.file("fonts", "Slayer", package = "tvthemes")

suppressWarnings(suppressMessages(extrafont::font_import(paths = theLastAirbender_font_dir, prompt = FALSE)))

message(
sprintf(
"You should install these fonts on your system directly. The files are located in [%s]",
theLastAirbender_font_dir
)
)
}

#' @title import_avatar
#' @description The Last Airbender font ("Slayer")
#' @details Actual font is Herculanum.
#' import_*() functions taken from hrbrthemes.
#' You may still need to install each font on your system directly by finding the .ttf file and clicking "Install".
#' @rdname import_avatar
#' @export
#' @importFrom extrafont font_import

import_avatar <- function() {
theLastAirbender_font_dir <- system.file("fonts", "Slayer", package = "tvthemes")

suppressWarnings(suppressMessages(extrafont::font_import(paths = theLastAirbender_font_dir, prompt = FALSE)))
Expand All @@ -159,13 +228,14 @@ import_theLastAirbender <- function() {
#' @title import_chelseaMarket
#' @description Imports Chelsea Market (Hilda)
#' @details import_*() functions taken from hrbrthemes.
#' Formerly `import_ChelseaMarket()`.
#' @seealso
#' \code{\link[extrafont]{font_import}}
#' @rdname import_ChelseaMarket
#' @rdname import_chelseaMarket
#' @export
#' @importFrom extrafont font_import

import_ChelseaMarket <- function() {
import_chelseaMarket <- function() {

ChelseaMarket_font_dir <- system.file("fonts", "ChelseaMarket", package = "tvthemes")

Expand All @@ -178,3 +248,27 @@ import_ChelseaMarket <- function() {
)
)
}

#' @title import_gravitationFalls
#' @description Imports Gravitation Falls font (Gravity Falls)
#' @details import_*() functions taken from hrbrthemes.
#' Font made by MaxiGamer on DeviantArt!
#' @seealso
#' \code{\link[extrafont]{font_import}}
#' @rdname import_gravitationFalls
#' @export
#' @importFrom extrafont font_import

import_gravitationFalls <- function() {

gravitationFalls_font_dir <- system.file("fonts", "GravitationFalls", package = "tvthemes")

suppressWarnings(suppressMessages(extrafont::font_import(paths = gravitationFalls_font_dir, prompt = FALSE)))

message(
sprintf(
"You should install these fonts on your system directly. The files are located in [%s]",
gravitationFalls_font_dir
)
)
}
13 changes: 7 additions & 6 deletions R/onattach.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## For tvthemes 1.0.0
## Only add for MAJOR version changes

.onAttach <- function(libname, pkgname) {
packageStartupMessage(
"Welcome to {tvthemes} 1.0.0! There's been a few changes to the palette functions ",
"so please take a look at the README on Github! (https://github.com/Ryo-N7/tvthemes)"
)
}
# .onAttach <- function(libname, pkgname) {
# packageStartupMessage(
# "Welcome to {tvthemes} 1.0.0! There's been a few changes to the palette functions ",
# "so please take a look at the README on Github! (https://github.com/Ryo-N7/tvthemes)"
# )
# }
Loading