Registriert seit: 31. Mai 2009
1.198 Beiträge
Turbo Delphi für Win32
|
AW: Color mixer
28. Dez 2011, 06:12
Delphi-Quellcode:
uses Math;
(...)
function GetColors( const C1, C2: TColor; Steps: Byte): TColorArray;
function Blend( const Color1, Color2: TColor; const A: Byte): TColor; // by Aphton
var
dA : Single;
c1 : Array[0..3] of Byte Absolute Color1;
c2 : Array[0..3] of Byte Absolute Color2;
rs : Array[0..3] of Byte Absolute Result;
begin
dA := A/100;
rs[0] := Round(c1[0] + (c2[0] - c1[0]) * dA);
rs[1] := Round(c1[1] + (c2[1] - c1[1]) * dA);
rs[2] := Round(c1[2] + (c2[2] - c1[2]) * dA);
rs[3] := 0;
end;
var
i: Integer;
V, T: Byte;
begin
if Steps < 3 then Exit;
SetLength(Result, Steps);
dec(Steps);
Result[0] := C1;
Result[Steps] := C2;
V := 100 div Steps;
T := 0;
for i := 1 to Steps - 1 do
begin
inc(T, V);
Result[i] := Blend(C1, C2, Min(T, 100));
end;
end;
10 Steps on color_tool_mixer.php = 12 with GetColors() (including Color1 and Color2)
Results in...
das Erkennen beginnt, wenn der Erkennende vom zu Erkennenden Abstand nimmt
MfG
Geändert von Aphton (28. Dez 2011 um 06:36 Uhr)
|