czy wie ktos jak zrobic pasek gradientowy?
chodzi o to ze uzytkownik wybiera kolor poczatkowy i koncowy, a progsik
rysuje mu ladne przejscie z koloru poczatkowego do koncowego :)---=[ Delphi 3, 6 ]=-
-=-==[ LKS ]==-=-
LKS w dniu 1.4.2002 17:20 napisal:
czy wie ktos jak zrobic pasek gradientowy?
>chodzi o to ze uzytkownik wybiera kolor poczatkowy i koncowy, a progsik
>rysuje mu ladne przejscie z koloru poczatkowego do koncowego :)
>
>--
>-=[ Delphi 3, 6 ]=-
>-=-==[ LKS ]==-=-
Mozesz narysować gradient za pomocą kompomentu VrGradien.
Znajduje sie on na delphi.icm.edu w packu Varian Work Shop
<<<<<<Delphi 6 >>>>>>>>>>--Lopi22
a jezeli ja nie chcĘ uzywac gotowego komponentu? :)---=[ Delphi 3, 6 ]=-
-=-==[ LKS ]==-=-
{ (c) by Kent Residorph }
procedure TMainForm.FormPaint(Sender: TObject);
const
Num = 64;
var
Bitmap : TBitmap;
I, Size : Integer;
{ An array of color values. }
Colors : array [0..Num - 1] of TColor;
LogPal : PLogPalette;
Pal : HPalette;
R : TRect;
begin
{ Create a memory bitmap. }
Bitmap := TBitmap.Create;
Bitmap.Width := Width;
Bitmap.Height := Height;
{ Create a palette for the Bitmap with 64 shades of blue. }
{ NOTE: This code is not necessary for display drivers using }
{ more than 256 colors. }
GetMem(LogPal, (SizeOf(TLogPalette) +
(Num - 1) * SizeOf(TPaletteEntry)));
LogPal.palVersion := $300;
for I := 0 to Pred(Num) do begin
LogPal.palPalEntry[i].peBlue := I * (256 div Num);
LogPal.palPalEntry[i].peRed := 0;
LogPal.palPalEntry[i].peGreen := 0;
LogPal.palPalEntry[i].peFlags := 0;
{ Add the color to the array of colors and set the high }
{ order bit to 2 so that the colors are obtained from }
{ the logical palette. }
colors[Num - I - 1] :=
TColor(RGB(0, 0, I * (256 div Num)) or $02000000);
end;
Pal := CreatePalette(LogPal^);
{ Set the Bitmap's palette to the palette just created. }
Bitmap.Palette := Pal;
{ Draw the required number of bands, each with a }
{ different shade of blue from the colors array. }
Size := (ClientHeight div Num) + 1;
for I := 0 to Pred(Num) do begin
R := Rect(0, I * Size, ClientWidth, (I * Size) + Size);
Bitmap.Canvas.Brush.Color := Colors[I];
Bitmap.Canvas.FillRect(R);
end;
{ Copy the memory Bitmap to the form's canvas. }
Canvas.Draw(0, 0, Bitmap);
{ Clean up. }
Bitmap.Free;
FreeMem(LogPal);
end;
--Pozdrawiam!
Adam Boduch
www.4programmers.net
dzieki :)
---=[ Delphi 3, 6 ]=-
-=-==[ LKS ]==-=-