Skip to contents

Fetches the color codes lookup table used for mapping raw RGB hex values to human-readable, purchasable color names. This enables translating technical color data into artist-friendly terminology matching popular art supply retailers.

Usage

get_color_codes(cn = NULL)

Arguments

cn

Database connection. If NULL (default), opens and closes a connection automatically via artcore::dbc()/artcore::dbd().

Value

data.table with columns:

hex

Character. Hex color code (e.g., "#FF5733")

color

Character. Human-readable color name (e.g., "Burnt Sienna")

r

Integer. Red component (0-255)

g

Integer. Green component (0-255)

b

Integer. Blue component (0-255)

Details

The color codes table maps hex colors to named colors that artists recognize and can purchase from art supply stores. This bridges the gap between technical RGB analysis and actionable artist insights.

The mapping uses RGB Euclidean distance to find the closest match: sqrt((r1-r2)^2 + (g1-g2)^2 + (b1-b2)^2)

Data Source

Data is stored in app.color_codes table. The mapping is curated to align with color names from major art supply brands.

Examples

if (FALSE) { # \dontrun{
# Fetch all color codes
colors <- get_color_codes()

# Use with existing connection
cn <- artcore::dbc()
colors <- get_color_codes(cn)
artcore::dbd(cn)

# Find closest match for a hex color
colors <- get_color_codes()
target_rgb <- grDevices::col2rgb("#FF5733")
colors[, dist := sqrt((r - target_rgb[1])^2 +
                      (g - target_rgb[2])^2 +
                      (b - target_rgb[3])^2)]
closest <- colors[which.min(dist)]
closest$color
} # }