Title: | Generate a Monochromatic Palette |
---|---|
Description: | Generate a palette of tints, shades or both from a single colour. |
Authors: | Sebastian Dalgarno [aut, cre], Joe Thorley [ctb] |
Maintainer: | Sebastian Dalgarno <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9001 |
Built: | 2024-11-21 06:21:17 UTC |
Source: | https://github.com/sebdalgarno/tinter |
Checks that x is a string (non-missing character vector of length 1) that specifies a color.
chk_color
checks if a color string.
chk_colour
checks if a color string.
chk_color(x, x_name = NULL) chk_colour(x, x_name = NULL)
chk_color(x, x_name = NULL) chk_colour(x, x_name = NULL)
x |
The object to check. |
x_name |
A string of the name of object x or NULL. |
NULL
, invisibly. Called for the side effect of throwing an error
if the condition is not met.
chk_color
: Check Color String Object
chk_colour
: Check Color String Object
# chk_color chk_color("blue") try(chk_color("glue")) # chk_colour chk_colour("blue") try(chk_colour("glue"))
# chk_color chk_color("blue") try(chk_color("glue")) # chk_colour chk_colour("blue") try(chk_colour("glue"))
Darken colour.
darken(x, amount)
darken(x, amount)
x |
A vector of strings of colours in any format accepted by grDevices::col2rgb(). |
amount |
A number from 0 to 1. |
A vector of modified colours.
darken(tinter("blue"), 0.2)
darken(tinter("blue"), 0.2)
Lighten colour.
lighten(x, amount)
lighten(x, amount)
x |
A vector of strings of colours in any format accepted by grDevices::col2rgb(). |
amount |
A number from 0 to 1. |
A vector of modified colours.
lighten(tinter("blue"), 0.2)
lighten(tinter("blue"), 0.2)
Generate shades, tints or both from a colour.
tinter(x, steps = 5, crop = 1, direction = "both", adjust = 0)
tinter(x, steps = 5, crop = 1, direction = "both", adjust = 0)
x |
A string of a colour in any format accepted by grDevices::col2rgb(). |
steps |
An integer indicating how many shades/tints to generate (excluding x). |
crop |
An integer indicating how many extreme colours to remove (e.g. crop = 1 eliminates 'black' and 'white'). |
direction |
A string indicating whether to include 'tints', 'shades' or 'both'. |
adjust |
A number between -1 and 1. Values between 0 and -1 increasingly darken colour; values between 0 and 1 increasingly lighten colour. |
A vector of colours.
tinter("blue") tinter("#fa6a5c", steps = 10, crop = 3) tinter("#fa6a5c", direction = "tints")
tinter("blue") tinter("#fa6a5c", steps = 10, crop = 3) tinter("#fa6a5c", direction = "tints")
Validates whether x is a string (non-missing character vector of length 1) that specifies a color.
vld_color(x) vld_colour(x)
vld_color(x) vld_colour(x)
x |
The object to check. |
A flag indicating whether the object was validated.
vld_color
: Validate Color String
vld_colour
: Validate Colour String
# vld_color vld_color("blue") vld_color("glue") # vld_color vld_colour("blue") vld_colour("glue")
# vld_color vld_color("blue") vld_color("glue") # vld_color vld_colour("blue") vld_colour("glue")