Skip to content

MATLAB function for Intuitive RGB color values from XKCD

Notifications You must be signed in to change notification settings

chadagreene/rgb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rgb

MATLAB function for intuitive RGB color values from XKCD

The rgb function returns the RGB triple of the 949 most common names for colors, according to the results of an XKCD survey. A chart of color options can be found here.

Syntax

RGB = rgb('Color Name') 
RGB = rgb('Color Name 1','Color Name 2',...,'Color Name N') 
RGB = rgb({'Color Name 1','Color Name 2',...,'Color Name N'}) 

Description

RGB = rgb('Color Name') returns the rgb triple of the color described by the string 'Color Name'. Try any color name you can think of, it'll probably work.

RGB = rgb('Color Name 1','Color Name 2',...,'Color Name N') returns an N by 3 matrix containing RGB triplets for each color name.

RGB = rgb({'Color Name 1','Color Name 2',...,'Color Name N'}) accepts list of color names as a character array.

Example 1

Get the RGB values of chartreuse:

>> rgb('chartreuse')
ans =
          0.76          0.97          0.04

Example 2

Get the RGB values of multiple colors

>> myColors = {'leather','swamp','light bluish green','butterscotch','cinnamon','radioactive green'};
>> rgb_vals = rgb(myColors)
rgb_vals =
          0.67          0.45          0.20
          0.41          0.51          0.22
          0.46          0.99          0.66
          0.99          0.69          0.28
          0.67          0.31          0.02
          0.17          0.98          0.12

Author Info

This function was written by Chad A. Greene using data from a survey designed by Randall Munroe.

About

MATLAB function for Intuitive RGB color values from XKCD

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published