1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| const
ColorMaxValue = 200;
function ComputeColorForValue(const Value: Integer): TBGRAPixel;
begin
// Simple hue-only, using Value in range 0-MaxValue, wrapping.
// Hue must be in range 0-1, so wrap to MaxValue and then shrink 0-1.
Result := ColorToBGRA(HSVtoRGB((Value mod ColorMaxValue) / ColorMaxValue, 1.0, 1.0));
end;
var
ColorTab: array[0..199] of TBGRAPixel;
function ColorForValue(const Value: Integer): TBGRAPixel;
begin
result := ColorTab[Value mod ColorMaxValue];
end;
var i: integer;
initialization
for i := 0 to ColorMaxValue-1 do
ColorTab[i] := ComputeColorForValue(i);
end. |
Partager