This class stores an extended list of colors by their full name and their corresponding 1x3 RGB (e.g. Red-Green-Blue) arrays in a single container map.
Color Properties:
All this class properties are protected or private to promote object oriented reuse.
Color Methods:
language - returns the language used by the current instance of Color to identify clor keys. Supported languages are english, french, and spanish.
rgb - returns the RGB triplet array of one or more colors identified by their name. If a color does not fit inside the list of supported colors it is simply ignored. When input colors is a cell string each line in the returned RGB matrix corresponds to one color.
list - prints a list of supported colors by this class into the console.
colors - returns the list of supported colors as a cell string.
plot - plots a graphic/chart of all supported colors which could be used to quickly localize a given color name.
Examples:
(1) list available colors:
list(Color)
aliceblue
antiquewhite
aqua
aquamarine
...
(2) plot a chart of all available colors:
plot(Color);
(3) get RGB color triplet for 'Maroon:
[RGB,~] = rgb(Color,'Maroon')
RGB =
0.5020 0 0
(4) get RGB color matrx for colors 'Beige' 'Maroon' 'SeaShell' and 'deep pink' plus one erroneous color name (neglected):
rgb(Color,{'Beige' 'Maroon' 'SeaShell' 'deep pink' 'error'})
ans =
0.9608 0.9608 0.8627
0.5020 0 0
1.0000 0.9608 0.9333
1.0000 0.0784 0.5765
(5) plot the sine function with a 'deep pink' color:
plot(linspace(0,2*pi,100),sin(linspace(0,2*pi,100)), 'color',rgb(Color,'deep pink'));
legend('sin(x)')
(6) load a Color object with French color names, get RGB triplet for 'orchidée sombre' color, and plot a chart with French colors:
clr_fr = Color('Language','francais');
rgb(clr_fr,'orchidée sombre')
ans =
0.6000 0.1961 0.8000
plot(clr_fr);
(7) load a Color object with Spanish color names, get RGB triplet for 'azul' color, and plot a chart with Spanish colors:
clr_es = Color('Language','espanol');
rgb(clr_es,'azul')
ans =
0 0 1
REFERENCES
[1] 'RGB Color Codes Chart', http://www.rapidtables.com/web/color/RGB_Color.htm
[2] 'HTML Color Codes', http://www.rapidtables.com/web/color/html-color-codes.htm
[3] 'CSS Color Module Level 3', https://www.w3.org/TR/css3-color/
Versions:
1.0 - Released 27/04/2017
Compatible with the RGB Color Codes Chart see reference [1].
2.0 - Released 02/05/2017
Compatible also with HTML/CSS3 color codes (see references [2,3]).
Accepts case insensitive color names so 'darksalmon', 'dark salmon', 'DarkSalmon', 'Dark Salmon' are all equivalent.
Some functions were renamed (i.e. getRGB to rgb, and plotColors changed to plot).
3.0 - Released 03/05/2017
Add French and Spanish languages support.
引用格式
Adil Sbai (2025). Multilanguage Color Management Class (https://www.mathworks.com/matlabcentral/fileexchange/62714-multilanguage-color-management-class), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- MATLAB > Graphics > Formatting and Annotation > 3-D Scene Control > Lighting, Transparency, and Shading >
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!