Created
January 22, 2023 14:07
-
-
Save viniciusfbb/495cebd012f33167333e9a0499d50037 to your computer and use it in GitHub Desktop.
Text shadow example using the Skia4Delphi library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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