Vcl.Skia.TSkPaintBox.OnDraw
Delphi
property OnDraw;
C++
__property OnDraw;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
event | published | Vcl.Skia.pas Vcl.Skia.hpp |
Vcl.Skia | TSkPaintBox |
Description
Fires whenever the TSkPaintBox control is redrawn.
Use this event to perform custom painting using the Skia graphics library directly on the control. The VCL TSkPaintBox is pixel-independent, automatically applying screen scaling so your drawing logic remains consistent across different DPIs.
Parameters:
- ACanvas: An
ISkCanvas
interface used for drawing with Skia. - ADest: A
TRectF
specifying the scaled drawing area. - AOpacity: A floating-point value indicating the current opacity on the interval [0, 1].
Usage:
- Use
ADest.Height
andADest.Width
to get accurate scale size. This allows your code to seamlessly adapt to any screen scale factor and avoid pixel-dependent issues. - The TSkPaintBox has an automatic cache system. Call Redraw to force redraw.
Example:
procedure TForm1.SkPaintBox1Draw(ASender: TObject; const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single);
var
LPaint: ISkPaint;
begin
LPaint := TSkPaint.Create(TSkPaintStyle.Stroke);
LPaint.AntiAlias := True;
ACanvas.DrawCircle(ADest.CenterPoint, 20, LPaint);
end;