Return to Snippet

Revision: 29654
at August 2, 2010 18:49 by icebob


Initial Code
procedure DrawGradientLine(bCanvas: TCanvas; X, Y, Width: integer;
  StartColor, EndColor: TColor);
var
  fX:integer;
  dr,dg,db:Extended;
  C1,C2:TColor;
  r1,r2,g1,g2,b1,b2:Byte;
  R,G,B:Byte;
  cnt:integer;
begin
  C1 := StartColor;
  R1 := GetRValue(C1) ;
  G1 := GetGValue(C1) ;
  B1 := GetBValue(C1) ;

  C2 := EndColor;
  R2 := GetRValue(C2) ;
  G2 := GetGValue(C2) ;
  B2 := GetBValue(C2) ;

  dr := (R2-R1) / Width;
  dg := (G2-G1) / Width;
  db := (B2-B1) / Width;

  cnt := 0;
  for fX := X to X + Width - 1 do
  begin
    R := R1+Ceil(dr*cnt) ;
    G := G1+Ceil(dg*cnt) ;
    B := B1+Ceil(db*cnt) ;

    bCanvas.Pixels[fX, Y] := RGB(R,G,B);
    inc(cnt) ;
  end;
end;

Initial URL

                                

Initial Description

                                

Initial Title
Draw a gradient line

Initial Tags

                                

Initial Language
Delphi