Title: | Learn to Roughly Assess Colour Hex Codes By Eye |
---|---|
Description: | Follow David DeSandro's method to quickly generate a rough colour name (e.g. 'light washed yellow') by looking only at its hex code (e.g. #F2D359). Contains standalone functions and a Shiny app for learning the process interactively. |
Authors: | Matt Dray [aut, cre] |
Maintainer: | Matt Dray <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2 |
Built: | 2024-10-23 02:58:17 UTC |
Source: | https://github.com/matt-dray/dehex |
Rather than manually typing functions of dehex into your console, you can instead run this Shiny app to be guided through the process of learning to read a random colour hex code.
dh_app()
dh_app()
Opens a Shiny app.
## Not run: dh_app()
## Not run: dh_app()
Takes a three-character hex colour shortcode and prints to the console a bar chart of the red (R), green (G) and blue (B) values using unicode blocks. This provides a quick visual assessment of the relative amounts of each colour expressed by the hex shortcode.
dh_graph( hex_short, text = NULL, adorn_h = TRUE, adorn_s = TRUE, adorn_l = TRUE, crayon = TRUE )
dh_graph( hex_short, text = NULL, adorn_h = TRUE, adorn_s = TRUE, adorn_l = TRUE, crayon = TRUE )
hex_short |
Character. A valid hex-colour shortcode starting with a hash mark (#) and followed by three alphanumeric characters, which must take the values 0 to 9 or A to F (case insensitive). |
text |
Character. An optional string to place above the plot. If NULL (default), then the shortcode will be automatically selected. |
adorn_h |
Logical. Add an optional value showing the relative rank of the RGB values (i.e. am indicator of hue)? A visual aid. |
adorn_s |
Logical. Add an optional bar showing where the range of the RGB values falls (i.e. am indicator of saturation)? A visual aid. |
adorn_l |
Logical. Add an optional bar showing where the mean of the RGB values falls (i.e. am indicator of lightness)? A visual aid. |
crayon |
Logical. Do you want to print to the console in colour, using the crayon package? |
The amount of red (R), green (G) and blue (B) is calculated on the basis that hex shortcodes contain one character for each colour. Since they're hexadecimal, they can take one of 16 possible values: 0 to 9 and then alphabetic characters from A to F (i.e. 10 to 15). That means that a shortcode of '#18F' has relative RGB values of 1, 8 and 16.
Nothing. Prints to the console with cat() a bar chart.
dh_graph("#D83")
dh_graph("#D83")
Print bar charts of RGB values that represent simplified groupings of hue, saturation or lightness levels in the HSL system. Intended for use as a reference to assess which RGB profiles most closely represents a user's hex shortcode.
dh_guide(type = c("H", "S", "L"), crayon = TRUE)
dh_guide(type = c("H", "S", "L"), crayon = TRUE)
type |
Character. Which of hue ('H'), saturation ('S') or light ('L') that you want to print the guide for. |
crayon |
Logical. Do you want to print to the console in colour, using the crayon package? |
The hue guide prints guides for the primary (red, green, blue), secondary (yellow, cyan, magenta) and tertiary (orange, chartreuse, aquamarine, azure, violet, rose) hues. For saturation, the guide contains 'washed' (i.e. the largest range in RGB values), muted, and grey (i.e. no difference between RGB values). In the lightness guide they're 'light' (i.e.high mean value of RGB), 'middle', and 'dark' (i.e. small range in RGB values).
Nothing. Prints bar charts of RGB values to the console, made with unicode blocks.
dh_guide("L")
dh_guide("L")
The purpose of {dehex} is to train how to 'read' the colour from a hex code. This function generates a random hex code for you so you can test your skills.
dh_random(shorten = FALSE)
dh_random(shorten = FALSE)
shorten |
Logical. Shorten six-character hex colour code to three characters? The three-character hex code is what is used to interpret the colour in the {dehex} 'training' context. |
Character string of length one. A three- or six-character hex code preceded by a hash mark, '#'.
dh_random(TRUE)
dh_random(TRUE)
Takes a hex code like '#C0FFEE' and simplifies to '#CFE' (i.e. the first character from each character pair).
dh_shorten(hex_code)
dh_shorten(hex_code)
hex_code |
Character. A valid hex colour code starting with a hash mark (#). Characters must take the values 0 to 9 or A to F (case insensitive). |
Character. A shortened hex colour code: a hash mark followed by three characters (0 to 9, A to F).
dh_shorten("#C0FFEE")
dh_shorten("#C0FFEE")
Convert a colour hex code to an English string that roughly describes its colour in terms of hue, saturation and lightness, like 'dark saturated azure'. Optionally plot a block with the colour that the hex code encodes. Optionally print to the console the hue, saturation and lightness graphs that best approximate that hex code.
dh_solve(hex_code, swatch = FALSE, graphs = FALSE, crayon = TRUE)
dh_solve(hex_code, swatch = FALSE, graphs = FALSE, crayon = TRUE)
hex_code |
Character. A valid hex colour code starting with a hash mark (#). Characters must take the values 0 to 9 or A to F (case insensitive). |
swatch |
Logical. Print to a graphical device a plot of the colour represented by (three-digit) hex code? Defaults to FALSE. |
graphs |
Logical. Do you want to print the result and associated hue, saturation and lightness bar charts to the console? Defaults to FALSE. |
crayon |
Logical. Do you want to print to the console in colour, using the crayon package? |
A character string. Optionally some console output and a plot.
dh_solve("#08F", graphs = FALSE, swatch = FALSE)
dh_solve("#08F", graphs = FALSE, swatch = FALSE)
Check the colour of an input hex colour code by plotting it.
dh_swatch(hex_code)
dh_swatch(hex_code)
hex_code |
Character. A valid hex colour code starting with a hash mark (#). Characters must take the values 0 to 9 or A to F (case insensitive). |
A plot.
dh_swatch("#F14362")
dh_swatch("#F14362")