54 lines
1.9 KiB
Matlab
54 lines
1.9 KiB
Matlab
classdef clr
|
|
properties (Constant)
|
|
% Set1 colormap
|
|
Set1 = struct( ...
|
|
'red', [0.8941, 0.1020, 0.1098], ...
|
|
'blue', [0.2157, 0.4941, 0.7216], ...
|
|
'green', [0.3020, 0.6863, 0.2902], ...
|
|
'purple', [0.5961, 0.3059, 0.6392], ...
|
|
'orange', [1.0000, 0.4980, 0.0000], ...
|
|
'yellow', [1.0000, 1.0000, 0.2000], ...
|
|
'brown', [0.6510, 0.3373, 0.1569], ...
|
|
'pink', [0.9686, 0.5059, 0.7490], ...
|
|
'gray', [0.6000, 0.6000, 0.6000]);
|
|
|
|
% Paired colormap
|
|
Paired = struct( ...
|
|
'lightblue', [0.6510, 0.8078, 0.8902], ...
|
|
'blue', [0.1216, 0.4706, 0.7059], ...
|
|
'lightgreen', [0.6980, 0.8745, 0.5412], ...
|
|
'green', [0.2000, 0.6275, 0.1725], ...
|
|
'lightred', [0.9843, 0.6039, 0.6000], ...
|
|
'red', [0.8902, 0.1020, 0.1098], ...
|
|
'lightorange',[0.9922, 0.7490, 0.4353], ...
|
|
'orange', [1.0000, 0.4980, 0.0000], ...
|
|
'lightpurple',[0.7922, 0.6980, 0.8392], ...
|
|
'purple', [0.4157, 0.2392, 0.6039], ...
|
|
'lightyellow',[1.0000, 1.0000, 0.6000], ...
|
|
'brown', [0.6941, 0.3490, 0.1569]);
|
|
|
|
end
|
|
|
|
methods (Static)
|
|
function showRGB(colorArray, names)
|
|
% Visualize colors in a horizontal bar chart
|
|
if nargin < 2
|
|
names = repmat({''}, size(colorArray, 1), 1);
|
|
end
|
|
|
|
figure;
|
|
hold on;
|
|
for i = 1:size(colorArray, 1)
|
|
fill([0 1 1 0], [i-1 i-1 i i], colorArray(i, :), 'EdgeColor', 'k');
|
|
text(1.1, i-0.5, names{i}, 'FontSize', 12, 'Interpreter', 'none');
|
|
end
|
|
ylim([0, size(colorArray, 1)]);
|
|
xlim([0, 1.5]);
|
|
axis off;
|
|
title('Color Preview');
|
|
hold off;
|
|
end
|
|
|
|
end
|
|
end
|