Skip to content

Commit 8c42b86

Browse files
authored
Merge pull request #25 from openep/hotfix/v1.0.01
Hotfix/v1.0.01
2 parents a8847bf + 7547e83 commit 8c42b86

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
File renamed without changes.
File renamed without changes.

private/colorspec2rgb.m

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function rgb = colorspec2rgb(c)
2+
% COLORSPEC2RGB converts a colorspec to truecolor.
3+
% Usage:
4+
% rgb = colorspec2rgb(c)
5+
% Where:
6+
% c is a color - either rgb or any of the letters in 'rgbwcmyk'
7+
%
8+
% COLORSPEC2RGB converts a character colorspec into a truecolor rgb
9+
% representation. If c is not a character then it is returned as rgb - so
10+
% that it will not affect index or truecolor variables that are input.
11+
%
12+
% Author: Nick Linton (2011)
13+
% Modifications -
14+
15+
16+
rgbspec = [1 0 0;0 1 0;0 0 1;1 1 1;0 1 1;1 0 1;1 1 0;0 0 0];
17+
cspec = 'rgbwcmyk';
18+
19+
% Deal with string color specifications.
20+
if ischar(c),
21+
k = find(cspec==c(1));
22+
if isempty(k)
23+
error('COLORSPEC2RGB: Unknown color string.');
24+
end
25+
if k~=3 || length(c)==1,
26+
rgb = rgbspec(k,:);
27+
elseif length(c)>2,
28+
if strcmpi(c(1:3),'bla')
29+
rgb = [0 0 0];
30+
elseif strcmpi(c(1:3),'blu')
31+
rgb = [0 0 1];
32+
else
33+
error('COLORSPEC2RGB: Unknown color string.');
34+
end
35+
end
36+
elseif isreal(c) && size(c,2)==3
37+
rgb = c;
38+
else
39+
error('COLORSPEC2RGB: Unknown color format.');
40+
end
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+

0 commit comments

Comments
 (0)