Skip to content

[Feature Request] GradientFill for TFPCustomCanvas

Summary

The canvas of fcl-image, TFPCustomCanvas, is lacking the GradientFill() method available in the canvas of Lazarus, TCanvas.

The attached patch implements this method.

gradientfill.diff

Example Project

The following project demonstrates the new feature:

program project1;
uses
  Types, FPImage, FPCanvas, FPImgCanv, FPWriteBMP;
var
  img: TFPMemoryImage;
  canv: TFPCustomCanvas;
begin
  img := TFPMemoryImage.Create(256, 128);
  try
    canv := TFPImageCanvas.Create(img);
    try
      canv.GradientFill(Rect(0, 0, 128, img.Height), colRed, colYellow, gdVertical);
      canv.GradientFill(Rect(128, 0, 256, img.Height), colRed, colYellow, gdHorizontal);
      img.SaveToFile('test.bmp');
    finally
      canv.Free;
    end;
  finally
    img.Free;
  end;
end.

grafik

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information