Skip to content

Instantly share code, notes, and snippets.

@viniciusfbb
Created January 22, 2023 14:07
Show Gist options
  • Save viniciusfbb/495cebd012f33167333e9a0499d50037 to your computer and use it in GitHub Desktop.
Save viniciusfbb/495cebd012f33167333e9a0499d50037 to your computer and use it in GitHub Desktop.
Text shadow example using the Skia4Delphi library
uses
Skia, Skia.FMX.Graphics;
procedure TForm1.SkPaintBox1Draw(ASender: TObject; const ACanvas: ISkCanvas;
const ADest: TRectF; const AOpacity: Single);
var
LTextLayout: TSkTextLayout;
LPaint: ISkPaint;
begin
LTextLayout := TSkTextLayout.Create;
try
LTextLayout.BeginUpdate;
try
LTextLayout.Text := 'Test shadow';
LTextLayout.Font.Size := 22;
LTextLayout.Color := TAlphaColors.Crimson;
LTextLayout.TopLeft := PointF(100, 100);
finally
LTextLayout.EndUpdate;
end;
LPaint := TSkPaint.Create;
LPaint.ImageFilter := TSkImageFilter.MakeDropShadow(6, 6, 4, 4, TAlphaColors.Black);
ACanvas.SaveLayer(LPaint);
try
LTextLayout.RenderLayout(ACanvas);
finally
ACanvas.Restore;
end;
finally
LTextLayout.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment