rgbdiff: Color similarity

View source: R/plot_extra.R

rgbdiffR Documentation

Color similarity

Description

A naive approach to compare two colors quantitatively. Converts colors to RGB and calculates the absolute percent differences for red, green, and blue plus the average of the three.

Usage

rgbdiff(col, col2 = NULL)

Arguments

col

a vector of colors; see col2rgb; note that all choose(length(col), 2) pairs of colors will be compared

col2

an optional vector of colors to compare 1:1 with col

Value

A matrix of red, green, blue, and average overall percent differences as rows and each pair of colors as columns.

Examples

rgbdiff(1:4)
## same
rgbdiff(palette()[1:4])

## compare all combinations
rgbdiff(paste0('red', 1:4))
## only compare 1:1
rgbdiff(paste0('red', 1:4), paste0('red', 1:4))

## Not run: 
## google colors from imagemagick
go <- 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
ip <- imgpal(go)

## google colors, https://www.schemecolor.com/google-logo-colors.php
go <- c('#4285F4', '#EA4335', '#FBBC05', '#34A853')

show_pal(go)
show_pal(ip, n = 4)

rgbdiff(ip$col[1:4], go)

## End(Not run)


raredd/rawr documentation built on April 29, 2024, 10:29 a.m.