Thema: Delphi Color mixer

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Color mixer

  Alt 27. Dez 2011, 14:53
I'm trying implement this tool:

Code:
http://www.design-lib.com/color_tool_mixer.php
I already have this:

Delphi-Quellcode:
type
  TColorArray = array of TColor;

function GetColors(const C1, C2: TColor; Steps: Byte): TColorArray;

function Blend(Color1, Color2: TColor; A: Byte): TColor; // by R. M. Klever
var
  c1, c2: LongInt;
  r, g, b, v1, v2: byte;
begin
  A:= Round(2.55 * A);
  c1 := ColorToRGB(Color1);
  c2 := ColorToRGB(Color2);
  v1:= Byte(c1);
  v2:= Byte(c2);
  r:= A * (v1 - v2) shr 8 + v2;
  v1:= Byte(c1 shr 8);
  v2:= Byte(c2 shr 8);
  g:= A * (v1 - v2) shr 8 + v2;
  v1:= Byte(c1 shr 16);
  v2:= Byte(c2 shr 16);
  b:= A * (v1 - v2) shr 8 + v2;
  Result := (b shl 16) + (g shl 8) + r;
end;

var
  V, T: Byte;
begin
  SetLength(Result, 0);

  V := 100 div (Steps + 1);
  T := 0;

  while T < 100 do
  begin
    Inc(T, V);

    SetLength(Result, Length(Result) + 1);
    Result[High(Result)] := Blend(C1, C2, T);
  end;
end;
I don't know, don't want to working as expected, F1
  Mit Zitat antworten Zitat