このホームページで作成されたバリエーションを検討することからわかることから、バリエーションを作成するためにHSL値を個別に変更するだけでは十分ではないようです。
本当に?インターフェイスは、どのような変更を加えるかについて十分に明確になっているようです。「色相」、「彩度」、「輝度」のいずれかを選択すると、そのチャンネルに9つのバリエーションが表示されます。次のMATLABスクリプトは、さまざまなバリエーションを同様の方法でプロットします(ただし、HSLではなくHSVカラースペースで)。
% display n variations of HTML-style color code.
function [] = colorwheel ( hex, n )
% parse color code.
rgb = hex2rgb(hex);
% render all variations.
h = figure();
for j = 1 : 3,
% build n variations on current channel.
colors = variantsof(rgb, j, n);
% display variations.
for i = 1 : n,
% generate patch of specified color.
I = zeros(128, 128, 3);
I(:,:,1) = colors(i, 1);
I(:,:,2) = colors(i, 2);
I(:,:,3) = colors(i, 3);
% render patches side-by-side to show progression.
imshow(I, 'parent', ...
subplot(3, n, (j-1)*n+i, 'parent', h));
end
end
end
% parse HTML-style color code.
function [ rgb ] = hex2rgb ( hex )
r = double(hex2dec(hex(1:2))) / 255;
g = double(hex2dec(hex(3:4))) / 255;
b = double(hex2dec(hex(5:6))) / 255;
rgb = [r g b];
end
% generate n variants of color on j-th channel.
function [ colors ] = variantsof ( rgb, j, n )
colors = zeros(n, 3);
for i = 1 : n,
% convert to HSV.
color = rgb2hsv(rgb);
% apply variation to selected channel.
color(j) = color(j) + ((i-1) / n);
if color(j) > 1.0,
color(j) = color(j) - 1.0;
end
% convert to RGB.
colors(i,:) = hsv2rgb(color);
end
% order colors with respect to channel.
if j > 1,
colors = sortrows(colors, j);
end
end
次のように、「ゴールデンロッド」サンプルカラーを使用します。
colorwheel('daa520', 9);
私は得る:
最初の行は色相のバリエーション、2番目の行は彩度、3番目の行は値です。出力はcoloreminder.comの出力に正確に対応していませんが、これは色空間の違いと順列で使用される正確な値によって説明されます。