XgaletteX
Messages postés102Date d'inscriptionsamedi 14 mai 2005StatutMembreDernière intervention12 août 2005
-
9 juin 2005 à 09:59
adec0127
Messages postés53Date d'inscriptionsamedi 7 août 2004StatutMembreDernière intervention22 février 2008
-
28 juil. 2005 à 09:14
Bonjour,
Je voudrai un dégradé de couleur de rouge clair vers rouge foncé, es ce que quelqu'un sait comment faire cela?
A voir également:
Dégradé de rouge code couleur
Code couleur dégradé - Meilleures réponses
Dégradé de toutes les couleurs - Meilleures réponses
procedure TGradient.SetDireccion(Valor : TDireccion);
begin
if FDireccion <> valor then
begin
FDireccion := Valor;
Repaint;
end;
end;
procedure TGradient.SetColorDesde(Valor : TColor);
begin
if FColorDesde <> Valor then
begin
FColorDesde := Valor;
Repaint;
end;
end;
procedure TGradient.SetColorHasta(Valor : TColor);
begin
if FColorHasta <> Valor then
begin
FColorHasta := Valor;
Repaint;
end;
end;
procedure TGradient.Paint;
var
RGBDesde, RGBHasta, RGBDif : array[0..2] of byte;
contador, Rojo, Verde, Azul : integer;
Banda : TRect;
Factor : array[0..2] of shortint;
begin
RGBDesde[0]:=GetRValue(ColorToRGB(FColorDesde));
RGBDesde[1]:=GetGValue(ColorToRGB(FColorDesde));
RGBDesde[2]:=GetBValue(ColorToRGB(FColorDesde));
RGBHasta[0]:=GetRValue(ColorToRGB(FColorHasta));
RGBHasta[1]:=GetGValue(ColorToRGB(FColorHasta));
RGBHasta[2]:=GetBValue(ColorToRGB(FColorHasta));
for contador:=0 to 2 do
begin
RGBDif[contador]:=Abs(RGBHasta[contador]-RGBDesde[contador]);
If RGBHasta[contador]>RGBDesde[contador] then factor[contador]:=1 else factor[contador]:=-1;
end;
Canvas.Pen.Style:=psSolid; Canvas.Pen.Mode:=pmCopy;
if FDireccion = dHorizontal then
begin
Banda.Left:=0;
Banda.Right:=Width;
for contador:=0 to 255 do
begin
Banda.Top:=MulDiv(contador,height,256);
Banda.Bottom:=MulDIv(contador+1,height,256);
Rojo:=RGBDesde[0]+factor[0]*MulDiv(contador,RGBDif[0],255);
Verde:=RGBDesde[1]+factor[1]*MulDiv(contador,RGBDif[1],255);
Azul:=RGBDesde[2]+factor[2]*MulDiv(contador,RGBDif[2],255);
Canvas.Brush.Color:=RGB(Rojo,Verde,Azul);
Canvas.FillRect(Banda);
end;
end;
if FDireccion = dVertical then
begin
Banda.Top:=0;
Banda.Bottom:=Height;
for contador:=0 to 255 do
begin
Banda.Left:=MulDiv(contador,width,256);
Banda.Right:=MulDIv(contador+1,width,256);
Rojo:=RGBDesde[0]+factor[0]*MulDiv(contador,RGBDif[0],255);
Verde:=RGBDesde[1]+factor[1]*MulDiv(contador,RGBDif[1],255);
Azul:=RGBDesde[2]+factor[2]*MulDiv(contador,RGBDif[2],255);
Canvas.Brush.Color:=RGB(Rojo,Verde,Azul);
Canvas.FillRect(Banda);
end;
end;
end;
procedure Register;
begin
RegisterComponents('Gradient', [TGradient]);
end;
end.