Title: | Official Lego Color Palettes |
---|---|
Description: | Provides a dataset containing several color naming conventions established by multiple sources, along with associated color metadata. The package also provides related helper functions for mapping among the different Lego color naming conventions and between Lego colors, hex colors, and 'R' color names, making it easy to convert any color palette to one based on existing Lego colors while keeping as close to the original color palette as possible. The functions use nearest color matching based on Euclidean distance in RGB space. Naming conventions for color mapping include those from 'BrickLink' (<https://www.bricklink.com>), 'The Lego Group' (<https://www.lego.com>), 'LDraw' (<https://www.ldraw.org/>), and 'Peeron' (<http://www.peeron.com/>). |
Authors: | Matthew Leonawicz [aut, cre] |
Maintainer: | Matthew Leonawicz <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0 |
Built: | 2024-11-10 06:00:44 UTC |
Source: | https://github.com/leonawicz/legocolors |
These functions are analogs to familiar R color palettes but based on Lego colors.
lc_terrain(n) lc_topo(n) lc_heat(n)
lc_terrain(n) lc_topo(n) lc_heat(n)
n |
if not provided, return the vector of official Lego colors defining
the palette. If provided, return an interpolated palette, which will contain
non-Lego colors only if |
character vector of hex colors
lc_terrain() lc_terrain(4) lc_topo() lc_heat()
lc_terrain() lc_terrain(4) lc_topo() lc_heat()
Map between hex and color names.
hex_to_color(x, approx = TRUE, prefix = "~") hex_to_legocolor( x, def = c("bricklink", "ldraw", "tlg", "peeron"), approx = TRUE, prefix = "~", material = NULL, retired = FALSE ) legocolor_to_hex(x, def = c("bricklink", "ldraw", "tlg", "peeron")) view_legopal( x, def = c("bricklink", "ldraw", "tlg", "peeron"), approx = TRUE, prefix = "~", material = NULL, retired = FALSE, show_labels = FALSE, label_size = 1 )
hex_to_color(x, approx = TRUE, prefix = "~") hex_to_legocolor( x, def = c("bricklink", "ldraw", "tlg", "peeron"), approx = TRUE, prefix = "~", material = NULL, retired = FALSE ) legocolor_to_hex(x, def = c("bricklink", "ldraw", "tlg", "peeron")) view_legopal( x, def = c("bricklink", "ldraw", "tlg", "peeron"), approx = TRUE, prefix = "~", material = NULL, retired = FALSE, show_labels = FALSE, label_size = 1 )
x |
character, hex color or color name. May be a vector. See details. |
approx |
logical, find and return closest color name when an exact match does not exist. |
prefix |
character, prefix for approximate color matches. |
def |
character, the Lego color name definition to apply: |
material |
logical, consider only the subset of Lego color names by
filtering on levels of |
retired |
logical, filter out Lego colors that are retired, defaults to
|
show_labels |
logical, show color name and hex value in palette preview. |
label_size |
numeric, text size. |
These functions map between hex color codes and color names. Convert any color palette to a palette of the most closely matched official Lego colors.
The two complimentary Lego color mapping functions are hex_to_legocolors()
and legocolors_to_hex()
. The first takes a hex color string and converts to
the nearest valid Lego color name by Euclidean distance. The second takes a
valid Lego color name and converts to hex.
Valid Lego color names are determined by the definition, def
. The four
options provide different name sets for existing Lego colors. The default is
def = "bricklink"
. BrickLink is the
default naming convention source for several reasons:
It is the most comprehensive and widely used.
In terms of obtaining Lego parts online:
BrickLink serves more countries worldwide than The Lego Group's (TLG) Pick-A-Brick service.
BrickLink offers far more variety, quantity and custom order filling than Pick-A-Brick.
Pick-A-Brick has far higher prices and a vastly smaller selection of items and colors.
The Adult Fans of Lego (AFOL) community is centered around BrickLink and members, buyers and sellers alike, are well versed in BrickLink Lego color naming conventions. Few are as familiar with official Lego color names.
Lego color naming conventions established by other entities, including the official Lego color names known to the public, are less complete.
There is also the BrickOwl website for custom part ordering, which uses official TLG color names, but is much smaller than BrickLink and tends to have significantly higher prices.
Essentially, when converting an image or 3D model in R into a set of Lego parts that must be custom ordered to construct your design, BrickLink is the clear best option for obtaining the most complete set of parts required and at the lowest price.
If approx = FALSE
, an unmatched element returns NA
.
hex_to_color
is provided for general convenience. It converts hex color
codes to the familiar R color names. Consistent with the Lego-specific mapping
functions, by default approx = TRUE
returns the nearest color name based on
Euclidean distance. prefix
allows for prepending an identifier to the
beginning of any color name that a hex color code does not match exactly.
character vector of color names or hex colors
hex_to_color(c("#ff0000", "#ff0001")) hex_to_legocolor("#ff0000") hex_to_legocolor("#ff0000", material = "solid") legocolor_to_hex("Red") hex_to_color(legocolor_to_hex("Red")) if(interactive()){ view_legopal(rainbow(9), material = "solid", show_labels = TRUE, label_size = 0.7) }
hex_to_color(c("#ff0000", "#ff0001")) hex_to_legocolor("#ff0000") hex_to_legocolor("#ff0000", material = "solid") legocolor_to_hex("Red") hex_to_color(legocolor_to_hex("Red")) if(interactive()){ view_legopal(rainbow(9), material = "solid", show_labels = TRUE, label_size = 0.7) }
Provides a dataset containing several color naming conventions established by multiple sources, along with associated color metadata. The package also provides related helper functions for mapping among the different Lego color naming conventions and between Lego colors, hex colors, and 'R' color names, making it easy to convert any color palette to one based on existing Lego colors while keeping as close to the original color palette as possible. The functions use nearest color matching based on Euclidean distance in RGB space. Naming conventions for color mapping include those from 'BrickLink' (https://www.bricklink.com), 'The Lego Group' (https://www.lego.com), 'LDraw' (https://www.ldraw.org/), and 'Peeron' (http://www.peeron.com/).
Maintainer: Matthew Leonawicz [email protected]
Useful links:
Report bugs at https://github.com/leonawicz/legocolors/issues
A data frame containing Lego color data.
legoCols
legoCols
A data frame with 12 columns and 167 rows.
A named list of nine Lego color palettes based on legoCols$material
.
Because these palettes represent a meaningful segmentation of Lego material types,
they are not intended to represent useful color palettes for mapping data values to colors.
legoPals
legoPals
A named list of nine color palettes.