Package 'tinter'

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

Help Index


Check Color String

Description

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.

Usage

chk_color(x, x_name = NULL)

chk_colour(x, x_name = NULL)

Arguments

x

The object to check.

x_name

A string of the name of object x or NULL.

Value

NULL, invisibly. Called for the side effect of throwing an error if the condition is not met.

Functions

  • chk_color: Check Color String Object

  • chk_colour: Check Color String Object

See Also

vld_color()

Examples

# chk_color
chk_color("blue")
try(chk_color("glue"))

# chk_colour
chk_colour("blue")
try(chk_colour("glue"))

Darken colour.

Description

Darken colour.

Usage

darken(x, amount)

Arguments

x

A vector of strings of colours in any format accepted by grDevices::col2rgb().

amount

A number from 0 to 1.

Value

A vector of modified colours.

Examples

darken(tinter("blue"), 0.2)

Lighten colour.

Description

Lighten colour.

Usage

lighten(x, amount)

Arguments

x

A vector of strings of colours in any format accepted by grDevices::col2rgb().

amount

A number from 0 to 1.

Value

A vector of modified colours.

Examples

lighten(tinter("blue"), 0.2)

Generate shades, tints or both from a colour.

Description

Generate shades, tints or both from a colour.

Usage

tinter(x, steps = 5, crop = 1, direction = "both", adjust = 0)

Arguments

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.

Value

A vector of colours.

Examples

tinter("blue")
tinter("#fa6a5c", steps = 10, crop = 3)
tinter("#fa6a5c", direction = "tints")

Validate Color String

Description

Validates whether x is a string (non-missing character vector of length 1) that specifies a color.

Usage

vld_color(x)

vld_colour(x)

Arguments

x

The object to check.

Value

A flag indicating whether the object was validated.

Functions

  • vld_color: Validate Color String

  • vld_colour: Validate Colour String

See Also

chk_color()

Examples

# vld_color
vld_color("blue")
vld_color("glue")

# vld_color
vld_colour("blue")
vld_colour("glue")