dsfsfsfsfsfsfs fsdfsdfsfs

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
ovural
Üye
Mesajlar: 167
Kayıt: 22 Eki 2003 10:20
İletişim:

Mesaj gönderen ovural »

Kod: Tümünü seç

  TYPE
    TfStyle = (fHorz, fVert, fRectangle, fDiagonal, fCircle);

procedure Gradient(Canvas:TCanvas;BColor, EColor : TColor; Style : TfStyle;ATop,ALeft,AHeight, AWidth : integer);
var i, H, dx, dy :integer;
  function GetColor(N,H : integer) : TColor;
  begin
    Result := RGB(Trunc(GetRValue(BColor) + (GetRValue(EColor)-GetRValue(BColor)) * N / H),
                  Trunc(GetGValue(BColor) + (GetGValue(EColor)-GetGValue(BColor)) * N / H),
                  Trunc(GetBValue(BColor) + (GetBValue(EColor)-GetBValue(BColor)) * N / H));
  end;
begin
   case Style of
   fHorz   :   for i := 0 to AWidth - 1 do begin
                Canvas.Pen.Color := GetColor(i, AWidth);
                Canvas.MoveTo(i,ATop);
                Canvas.LineTo(i,ATop+AHeight);
               end;
   fVert     : for i := 0 to AHeight - 1 do begin
                Canvas.Pen.Color := GetColor(i, AHeight);
                Canvas.MoveTo(aLeft,i+ATop);
                Canvas.LineTo(AWidth,i+Atop);
               end;
   fRectangle: begin
                 H := Trunc(SQRT(AHeight*AHeight + AWidth*AWidth)/ 4);
                 for i := H downto aTop do begin
                  dx := Trunc((AWidth/2 * i )/ H) * 2;
                  dy := Trunc((AHeight/2 * i )/ H) * 2;
                  Canvas.Pen.Color := GetColor(i, H);
                  Canvas.Brush.Color := GetColor(i, H);
                  Canvas.Rectangle(AWidth div 2 - dx , AHeight div 2 - dy,
                                   AWidth div 2 + dx , AHeight div 2 + dy);
                 end;
               end;
   fDiagonal : begin
                H := Trunc(SQRT(AHeight*AHeight + AWidth*AWidth))*2;
                for i := aTop to H do begin
                 dx := Trunc((AWidth  *2 * i )/ H);
                 dy := Trunc((AHeight *2 * i )/ H);
                 Canvas.Pen.Color := GetColor(i, H);
                 Canvas.MoveTo(aTop,dy);
                 Canvas.LineTo(dx,aTop);
                end;
               end;
   fCircle   : begin
                H := Trunc(SQRT(AHeight*AHeight + AWidth*AWidth) / 5);
                for i := H downto aTop do begin
                 dx := i * 5;
                 dy := i * 5;
                 Canvas.Pen.Color := GetColor(i, H);
                 Canvas.Brush.Color := GetColor(i, H);
                 Canvas.Ellipse(AWidth div 2 - dx, AHeight div 2 - dy,
                                AWidth div 2 + dx, AHeight div 2 + dy);
                end;
               end;
  end;
end;

bunu dene ben bunu kullanıyorum :D
Cevapla