Reference ICanvas
Declared in Codebot.Render.Graphics.pas on line 513
ICanvas provides the main interface for generating vector graphics in this graphics unit. Canvas can be used to draw paths, images, and text. It has global properties for matrix transforms, blending, and alpha blending (aka Opacity), and methods for clipping and clearing content.
ICanvas = interface(IResourceStore)
public
function GetBlendMode: TBlendMode;
procedure SetBlendMode(Value: TBlendMode);
function GetOpacity: Float;
procedure SetOpacity(Value: Float);
function GetMatrix: IMatrix;
procedure SetMatrix(Value: IMatrix);
function GetWinding: TWinding;
procedure SetWinding(const Value: TWinding);
function GetFillRule: TFillRule;
procedure SetFillRule(const Value: TFillRule);
{ Push all canvas state to the stack }
procedure Push;
{ Pop canvas state from the stack }
procedure Pop;
{ Clip drawing to a rectangle. You can use an empty rect to remove the
clipping or combine mutliple calls to intersect the previous clipping
regions }
procedure Clip(const Rect: TRectF); overload;
{ Shortcut to remove the clipping }
procedure Clip; overload;
{ Clear all pixels in the current render or back buffer target. A render
bitmap can be used with the canvas using its Bind and Unbind methods. }
procedure Clear;
{ Measure a Float line of text }
function MeasureText(Font: IFont; const Text: string): TPointF;
{ Measure how far a line of text moves the place where text is drawn }
function MeasureAdvance(Font: IFont; const Text: string): Float;
{ Measure a the height of multiple lines of text given a width }
function MeasureMemo(Font: IFont; const Text: string; Width: Float): Float;
{ Render a Float line of text given a coordinate }
procedure DrawText(Font: IFont; const Text: string; X, Y: Float);
{ Render a multiple lines of text given a width }
procedure DrawTextMemo(Font: IFont; const Text: string; X, Y, Width: Float);
{ Raster image drawing }
procedure DrawImage(Image: IBitmap; X, Y: Float; Opacity: Float = 1; Angle: Float = 0); overload;
{ Draw part of an image stretched to fill a rectangle }
procedure DrawImage(Image: IBitmap; Source, Dest: TRectF; Opacity: Float = 1; Angle: Float = 0); overload;
{ Draw a sprite }
procedure DrawSprite(Sprite: ISprite);
{ Discards the existing path and begins a new one }
procedure BeginPath;
{ Closing the path creates a line from the last point to the first point in
the path. It does not begin a new path. }
procedure ClosePath;
{ These methods add geometry to the current path }
procedure MoveTo(X, Y: Float);
{ Add a line to a point }
procedure LineTo(X, Y: Float);
{ Add an arc which rounds the corner between two lines }
procedure ArcTo(X1, Y1, X2, Y2, Radius: Float);
{ Add a cubic bezier curve }
procedure BezierTo(CX1, CY1, CX2, CY2, X, Y: Float);
{ Add a quadratic bezier curve }
procedure QuadTo(CX, CY, X, Y: Float);
{ Add an arc of a circle between two angles }
procedure Arc(CX, CY, Radius, A0, A1: Float; Clockwise: Boolean);
{ Add a circle }
procedure Circle(X, Y, Radius: Float); overload;
{ Add an ellipse inside a rectangle }
procedure Ellipse(const R: TRectF); overload;
procedure Ellipse(X, Y, Width, Height: Float); overload;
{ Add a rectangle }
procedure Rect(const R: TRectF); overload;
procedure Rect(X, Y, Width, Height: Float); overload;
{ Add a rectangle with rounded corners }
procedure RoundRect(const R: TRectF; Radius: Float); overload;
procedure RoundRect(X, Y, Width, Height: Float; Radius: Float); overload;
{ Add a polygon from an array of points }
procedure Polygon(P: PPointF; Count: Integer; Closed: Boolean = True);
{ Radii are TL top left, TR top right, BR bottom right, and BL bottom left }
procedure RoundRectVarying(const R: TRectF; TL, TR, BR, BL: Float);
{ When preserve is false the current path is discarded and a new path begins }
procedure Fill(Brush: IBrush; Preserve: Boolean = False); overload;
procedure Fill(Color: TColorF; Preserve: Boolean = False); overload;
{ Stroke the current path with a pen or a color }
procedure Stroke(Pen: IPen; Preserve: Boolean = False); overload;
procedure Stroke(Color: TColorF; Width: Float = 1; Preserve: Boolean = False); overload;
{ Convenience methods that begin, paint, then discard a path }
procedure FillCircle(Brush: IBrush; X, Y, Radius: Float);
procedure StrokeCircle(Pen: IPen; X, Y, Radius: Float);
procedure FillRect(Brush: IBrush; const R: TRectF);
procedure StrokeRect(Pen: IPen; const R: TRectF);
procedure FillRoundRect(Brush: IBrush; const R: TRectF; Radius: Float);
procedure StrokeRoundRect(Pen: IPen; const R: TRectF; Radius: Float);
{ Global blending mode can be controlled using this property }
property BlendMode: TBlendMode read GetBlendMode write SetBlendMode;
{ Global rendering opacity can be controlled using this property }
property Opacity: Float read GetOpacity write SetOpacity;
{ Global rendering can be transformed using this property }
property Matrix: IMatrix read GetMatrix write SetMatrix;
{ Counter clockwise creates solid shapes and clockwise creates shapes with
holes. }
property Winding: TWinding read GetWinding write SetWinding;
{ The rule used by Fill to find holes in paths, fillWinding by default }
property FillRule: TFillRule read GetFillRule write SetFillRule;
end;See also
Float in Codebot.System.pas
TColorF in Codebot.Graphics.Types.pas
TPointF in Codebot.Graphics.Types.pas
TRectF in Codebot.Graphics.Types.pas