Ver Mensaje Individual
  #4  
Antiguo 14-08-2025
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Prueba algo así, a ver si te sirve:
Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
begin
  DibujarDegradado(TImage1.Canvas, TImage1.ClientRect, clYellow, clRed);
end;

procedure TForm1.DibujarDegradado(ACanvas: TCanvas; ARect: TRect; Color1, Color2: TColor);
var
  i, R1, G1, B1, R2, G2, B2: Integer;
  R, G, B: Integer;
  LineRect: TRect;
begin
  // Descomponer colores
  R1 := GetRValue(ColorToRGB(Color1));
  G1 := GetGValue(ColorToRGB(Color1));
  B1 := GetBValue(ColorToRGB(Color1));

  R2 := GetRValue(ColorToRGB(Color2));
  G2 := GetGValue(ColorToRGB(Color2));
  B2 := GetBValue(ColorToRGB(Color2));

  for i := 0 to ARect.Bottom - ARect.Top do
  begin
    // Interpolación lineal de colores
    R := R1 + MulDiv(R2 - R1, i, ARect.Bottom - ARect.Top);
    G := G1 + MulDiv(G2 - G1, i, ARect.Bottom - ARect.Top);
    B := B1 + MulDiv(B2 - B1, i, ARect.Bottom - ARect.Top);

    ACanvas.Brush.Color := RGB(R, G, B);
    LineRect := Rect(ARect.Left, ARect.Top + i, ARect.Right, ARect.Top + i + 1);
    ACanvas.FillRect(LineRect);
  end;
end;
Pon un TImage en el formulario, ajusta su align o tamaño para que ocupe el área que quieras y llama a DibujarDegradado(...) con los colores que quieras.
Responder Con Cita