Class TBGRACanvas2D

Unit

Declaration

type TBGRACanvas2D = class(IBGRAPath)

Description

Implementation of a canvas similar to HTML Canvas2d.

TBGRACanvas2D is the surface to use when rendering with TBGRASVG, TBGRACustomTypeWriter and TBGRAVectorizedFont.

Comparison between TBGRACanvas2D and Javascript HTML canvas:

blue_circular_bevel_js

BGRABitmap

JavaScript

uses BGRABitmap, BGRABitmapTypes, BGRACanvas2D;

procedure TForm1.FormPaint(Sender: TObject);
var
  bmp: TBGRABitmap;
  ctx: TBGRACanvas2D;
  gradient: IBGRACanvasGradient2D;
begin
  bmp := TBGRABitmap.Create(ClientWidth, ClientHeight,
                            StrToBGRA('#E0E2E5'));
  ctx := bmp.Canvas2d;

  // Draw the outer rounded rectangle
  gradient := ctx.createLinearGradient(100, 20, 100, 180);
  gradient.addColorStop(0, 'white');
  gradient.addColorStop(1, '#7C878A');
  ctx.fillStyle(gradient);
  ctx.beginPath();
  ctx.roundRect(20, 20, 160, 160, 20);
  ctx.save();
  ctx.shadowBlur := 10;
  ctx.shadowColor('rgba(0,0,0, .8)');
  ctx.shadowOffsetX := 0;
  ctx.shadowOffsetY := 10;
  ctx.fill();
  ctx.restore();

  // Draw the blue circle with gradient
  gradient := ctx.createLinearGradient(100, 30, 100, 170);
  gradient.addColorStop(0, '#CAEBF5');
  gradient.addColorStop(1, '#0F5369');
  ctx.strokeStyle(gradient);
  ctx.beginPath();
  ctx.arc(100, 100, 70, 0, Pi * 2);
  ctx.lineWidth := 10;
  ctx.stroke();

  gradient := ctx.createLinearGradient(100, 50, 100, 150);
  gradient.addColorStop(0, '#003C50');
  gradient.addColorStop(1, '#53E6FF');
  ctx.strokeStyle(gradient);
  ctx.beginPath();
  ctx.arc(100, 100, 60, 0, Pi * 2);
  ctx.lineWidth := 10;
  ctx.stroke();

  bmp.Draw(Canvas, 0,0, true);
  bmp.Free;
end;

Try on JSFiddle

var my_canvas = document.getElementById('canvas'),
    ctx = my_canvas.getContext("2d");

ctx.fillStyle = "#E0E2E5";
ctx.fillRect(0, 0, 200, 200);

// Draw the outer rounded rectangle
var gradient = ctx.createLinearGradient(100, 20, 100, 180);
gradient.addColorStop(0, "white");
gradient.addColorStop(1, "#7C878A");
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.roundRect(20, 20, 160, 160, 20);
ctx.save();
ctx.shadowBlur = 10;
ctx.shadowColor = "rgba(0,0,0, .6)";
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 10;
ctx.fill();
ctx.restore();

// Draw the blue circle with gradient
gradient = ctx.createLinearGradient(100, 30, 100, 170);
gradient.addColorStop(0, "#CAEBF5");
gradient.addColorStop(1, "#0F5369");
ctx.strokeStyle = gradient;
ctx.beginPath();
ctx.arc(100, 100, 70, 0, Math.PI * 2);
ctx.lineWidth = 10;
ctx.stroke();

gradient = ctx.createLinearGradient(100, 50, 100, 150);
gradient.addColorStop(0, "#003C50");
gradient.addColorStop(1, "#53E6FF");
ctx.strokeStyle = gradient;
ctx.beginPath();
ctx.arc(100, 100, 60, 0, Math.PI * 2);
ctx.lineWidth = 10;
ctx.stroke();

Hierarchy

Overview

Fields

Public antialiasing: boolean;
Public gradientGammaCorrection: boolean;
Public linearBlend: boolean;

Methods

Public constructor Create(ASurface: TBGRACustomBitmap);
Public destructor Destroy; override;
Public function createLinearGradient(x0,y0,x1,y1: single; Colors: TBGRACustomGradient): IBGRACanvasGradient2D; overload;
Public function createLinearGradient(p0,p1: TPointF; Colors: TBGRACustomGradient): IBGRACanvasGradient2D; overload;
Public function createLinearGradient(p0,p1: TPointF): IBGRACanvasGradient2D; overload;
Public function createLinearGradient(x0,y0,x1,y1: single): IBGRACanvasGradient2D; overload;
Public function createPattern(texture: IBGRAScanner): IBGRACanvasTextureProvider2D; overload;
Public function createPattern(image: TBGRACustomBitmap; repetition: string): IBGRACanvasTextureProvider2D; overload;
Public function createRadialGradient(p0: TPointF; r0: single; p1: TPointF; r1: single; Colors: TBGRACustomGradient; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
Public function createRadialGradient(x0,y0,r0,x1,y1,r1: single; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
Public function createRadialGradient(x0,y0,r0,x1,y1,r1: single; Colors: TBGRACustomGradient; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
Public function createRadialGradient(p0: TPointF; r0: single; p1: TPointF; r1: single; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
Public class function CSSFontNameToLCL(AName: string): string;
Public class function FontNameListToStr(AList: ArrayOfString): string;
Public function getLineStyle: TBGRAPenStyle;
Public function getShadowColor: TBGRAPixel;
Public function isPointInPath(pt: TPointF): boolean; overload;
Public function isPointInPath(x,y: single): boolean; overload;
Public function measureText(AText: string): TCanvas2dTextSize;
Public class function StrToFontNameList(AText: string): ArrayOfString;
Public function toDataURL(mimeType: string = 'image/png'): string;
Public procedure addPath(ASvgPath: string); overload;
Public procedure addPath(APath: IBGRAPath); overload;
Public procedure arc(x, y, radius, startAngleRadCW, endAngleRadCW: single); overload;
Public procedure arc(x, y, radius, startAngleRadCW, endAngleRadCW: single; anticlockwise: boolean); overload;
Public procedure arc(cx, cy, rx,ry, xAngleRadCW, startAngleRadCW, endAngleRadCW: single; anticlockwise: boolean); overload;
Public procedure arc(constref arcDef: TArcDef); overload;
Public procedure arc(cx, cy, rx,ry, xAngleRadCW, startAngleRadCW, endAngleRadCW: single); overload;
Public procedure arcTo(x1, y1, x2, y2, radius: single); overload;
Public procedure arcTo(p1,p2: TPointF; radius: single); overload;
Public procedure arcTo(rx, ry, xAngleRadCW: single; largeArc,anticlockwise: boolean; x, y: single);
Public procedure beginPath;
Public procedure bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y: single); overload;
Public procedure bezierCurveTo(constref cp1,cp2,pt: TPointF); overload;
Public procedure circle(x,y,r: single);
Public procedure clearPath;
Public procedure clearRect(x,y,w,h: single);
Public procedure clip;
Public procedure closedSpline(const pts: array of TPointF; style: TSplineStyle);
Public procedure closePath;
Public procedure copyStateFrom(AOtherCanvas2D: TBGRACanvas2D);
Public procedure drawImage(image: TBGRACustomBitmap; dx,dy: single; AFilter: TResampleFilter = rfLinear); overload;
Public procedure drawImage(image: TBGRACustomBitmap; dx,dy,dw,dh: single; AFilter: TResampleFilter = rfLinear); overload;
Public procedure ellipse(x,y,rx,ry: single);
Public procedure fill; overload;
Public procedure fill(AFillProc: TBGRAPathFillProc; AData: pointer); overload;
Public procedure fill(AFillProc: TBGRAPathFillProc; const AMatrix: TAffineMatrix; AData: pointer); overload;
Public procedure fillOverStroke;
Public procedure fillRect(x,y,w,h: single);
Public procedure fillStyle(color: TBGRAPixel); overload;
Public procedure fillStyle(provider: IBGRACanvasTextureProvider2D); overload;
Public procedure fillStyle(color: string); overload;
Public procedure fillStyle(texture: IBGRAScanner); overload;
Public procedure fillStyle(color: TColor); overload;
Public procedure fillText(AText: string; x,y: single);
Public procedure lineStyle(const AValue: array of single); overload;
Public procedure lineStyle(AStyle: TPenStyle); overload;
Public procedure lineTo(constref pt: TPointF); overload;
Public procedure lineTo(x,y: single); overload;
Public procedure mask(image: TBGRACustomBitmap; dx,dy: single; AFilter: TResampleFilter = rfLinear); overload;
Public procedure mask(image: TBGRACustomBitmap; dx,dy,dw,dh: single; AFilter: TResampleFilter = rfLinear); overload;
Public procedure moveTo(x,y: single); overload;
Public procedure moveTo(constref pt: TPointF); overload;
Public procedure openedSpline(const pts: array of TPointF; style: TSplineStyle);
Public procedure path(APath: IBGRAPath); overload;
Public procedure path(ASvgPath: string); overload;
Public procedure polylineTo(const pts: array of TPointF);
Public procedure quadraticCurveTo(cpx,cpy,x,y: single); overload;
Public procedure quadraticCurveTo(constref cp,pt: TPointF); overload;
Public procedure rect(x,y,w,h: single);
Public procedure resetTransform;
Public procedure restore;
Public procedure rotate(angleRadCW: single);
Public procedure roundRect(x,y,w,h,radius: single); overload;
Public procedure roundRect(x,y,w,h,rx,ry: single); overload;
Public procedure save;
Public procedure scale(x,y: single); overload;
Public procedure scale(factor: single); overload;
Public procedure setTransform(m11,m21, m12,m22, m13,m23: single);
Public procedure shadowColor(color: TBGRAPixel); overload;
Public procedure shadowColor(color: string); overload;
Public procedure shadowColor(color: TColor); overload;
Public procedure shadowNone;
Public procedure skewx(angleRadCW: single);
Public procedure skewy(angleRadCW: single);
Public procedure spline(const pts: array of TPointF; style: TSplineStyle= ssOutside);
Public procedure splineTo(const pts: array of TPointF; style: TSplineStyle= ssOutside);
Public procedure stroke(ADrawProc: TBGRAPathDrawProc; AData: pointer); overload;
Public procedure stroke(ADrawProc: TBGRAPathDrawProc; const AMatrix: TAffineMatrix; AData: pointer); overload;
Public procedure stroke; overload;
Public procedure strokeOverFill;
Public procedure strokeRect(x,y,w,h: single);
Public procedure strokeResetTransform;
Public procedure strokeScale(x,y: single);
Public procedure strokeSkewx(angleRadCW: single);
Public procedure strokeSkewy(angleRadCW: single);
Public procedure strokeStyle(color: TBGRAPixel); overload;
Public procedure strokeStyle(provider: IBGRACanvasTextureProvider2D); overload;
Public procedure strokeStyle(color: TColor); overload;
Public procedure strokeStyle(texture: IBGRAScanner); overload;
Public procedure strokeStyle(color: string); overload;
Public procedure strokeText(AText: string; x,y: single);
Public procedure text(AText: string; x,y: single);
Public procedure toSpline(closed: boolean; style: TSplineStyle= ssOutside);
Public procedure transform(AMatrix: TAffineMatrix); overload;
Public procedure transform(m11,m21, m12,m22, m13,m23: single); overload;
Public procedure translate(x,y: single);
Public procedure unclip;

Properties

Public property currentPath: ArrayOfTPointF read GetCurrentPathAsPoints;
Public property direction: TFontBidiMode read GetTextDirection write SetTextDirection;
Public property fillMode: TFillMode read GetFillMode write SetFillMode;
Public property font: string read GetFontString write SetFontString;
Public property fontEmHeight: single read GetFontEmHeight write SetFontEmHeight;
Public property fontName: string read GetFontName write SetFontName;
Public property fontRenderer: TBGRACustomFontRenderer read GetFontRenderer write SetFontRenderer;
Public property fontStyle: TFontStyles read GetFontStyle write SetFontStyle;
Public property globalAlpha: single read GetGlobalAlpha write SetGlobalAlpha;
Public property hasShadow: boolean read GetHasShadow;
Public property height: Integer read GetHeight;
Public property lineCap: string read GetLineCap write SetLineCap;
Public property lineCapLCL: TPenEndCap read GetLineCapLCL write SetLineCapLCL;
Public property lineJoin: string read GetlineJoin write SetLineJoin;
Public property lineJoinLCL: TPenJoinStyle read GetlineJoinLCL write SetLineJoinLCL;
Public property lineWidth: single read GetLineWidth write SetLineWidth;
Public property matrix: TAffineMatrix read GetMatrix write SetMatrix;
Public property miterLimit: single read GetMiterLimit write SetMiterLimit;
Public property pixelCenteredCoordinates: boolean read GetPixelCenteredCoordinates write SetPixelCenteredCoordinates;
Public property shadowBlur: single read GetShadowBlur write SetShadowBlur;
Public property shadowFastest: boolean read GetShadowFastest write SetShadowFastest;
Public property shadowOffset: TPointF read GetShadowOffset write SetShadowOffset;
Public property shadowOffsetX: single read GetShadowOffsetX write SetShadowOffsetX;
Public property shadowOffsetY: single read GetShadowOffsetY write SetShadowOffsetY;
Public property strokeMatrix: TAffineMatrix read GetStrokeMatrix write SetStrokeMatrix;
Public property surface: TBGRACustomBitmap read FSurface;
Public property textAlign: string read GetTextAlign write SetTextAlign;
Public property textAlignLCL: TAlignment read GetTextAlignLCL write SetTextAlignLCL;
Public property textBaseline: string read GetTextBaseline write SetTextBaseline;
Public property width: Integer read GetWidth;

Description

Fields

Public antialiasing: boolean;

Whether to apply antialiasing when drawing

Public gradientGammaCorrection: boolean;

Whether to use gamma correction in gradient interpolation.

It is less accurate but it reflects more how HTML Canvas works.

Public linearBlend: boolean;

Whether to use linear blending when merging colors.

In this case, gamma correction won't be applied. It is less accurate but it reflects more how HTML Canvas works.

Methods

Public constructor Create(ASurface: TBGRACustomBitmap);

Create an new instance with its own context.

Public destructor Destroy; override;

Destroys the canvas context including the font renderer.

Public function createLinearGradient(x0,y0,x1,y1: single; Colors: TBGRACustomGradient): IBGRACanvasGradient2D; overload;

Creates a linear gradient with custom color stops.

Public function createLinearGradient(p0,p1: TPointF; Colors: TBGRACustomGradient): IBGRACanvasGradient2D; overload;

Creates a linear gradient with custom color stops using TPointF.

Public function createLinearGradient(p0,p1: TPointF): IBGRACanvasGradient2D; overload;

Creates a linear gradient between two points using TPointF.

Public function createLinearGradient(x0,y0,x1,y1: single): IBGRACanvasGradient2D; overload;

Creates a linear gradient between two points.

Public function createPattern(texture: IBGRAScanner): IBGRACanvasTextureProvider2D; overload;

Creates a pattern using a scanner interface.

Public function createPattern(image: TBGRACustomBitmap; repetition: string): IBGRACanvasTextureProvider2D; overload;

Creates a pattern using an image.

repetition can be:

  • repeat-x: repetition along X axis

  • repeat-y: repetition along Y axis

  • no-repeat: image is drawn only once

Public function createRadialGradient(p0: TPointF; r0: single; p1: TPointF; r1: single; Colors: TBGRACustomGradient; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;

Creates a radial gradient with custom color stops using TPointF.

Public function createRadialGradient(x0,y0,r0,x1,y1,r1: single; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;

Creates a radial gradient between two circles.

Public function createRadialGradient(x0,y0,r0,x1,y1,r1: single; Colors: TBGRACustomGradient; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;

Creates a radial gradient with custom color stops.

Public function createRadialGradient(p0: TPointF; r0: single; p1: TPointF; r1: single; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;

Creates a radial gradient between two circles using TPointF.

Public class function CSSFontNameToLCL(AName: string): string;

Converts CSS font name to LCL font name.

Public class function FontNameListToStr(AList: ArrayOfString): string;

Converts a list of font names to a string.

Public function getLineStyle: TBGRAPenStyle;

Gets the current line style.

Public function getShadowColor: TBGRAPixel;

Retrieves the current color used for shadows.

Public function isPointInPath(pt: TPointF): boolean; overload;

Checks if a given TPointF is inside the current path.

Public function isPointInPath(x,y: single): boolean; overload;

Checks if a given point is inside the current path.

Public function measureText(AText: string): TCanvas2dTextSize;

Measures the size of the given text.

Public class function StrToFontNameList(AText: string): ArrayOfString;

Converts a string of font names to a list.

Public function toDataURL(mimeType: string = 'image/png'): string;

Converts the image to code that can be put in an image href

Public procedure addPath(ASvgPath: string); overload;

Adds an SVG path to the current drawing.

Public procedure addPath(APath: IBGRAPath); overload;

Adds a path to the current drawing.

Public procedure arc(x, y, radius, startAngleRadCW, endAngleRadCW: single); overload;

Adds an arc around the specified point in the clockwise direction.

Public procedure arc(x, y, radius, startAngleRadCW, endAngleRadCW: single; anticlockwise: boolean); overload;

Adds an arc around the specified point.

Public procedure arc(cx, cy, rx,ry, xAngleRadCW, startAngleRadCW, endAngleRadCW: single; anticlockwise: boolean); overload;

Adds an elliptical arc around the specified point.

Public procedure arc(constref arcDef: TArcDef); overload;

Adds an elliptical arc using TArcDef.

Public procedure arc(cx, cy, rx,ry, xAngleRadCW, startAngleRadCW, endAngleRadCW: single); overload;

Adds an elliptical arc around the specified point in the clockwise direction.

Public procedure arcTo(x1, y1, x2, y2, radius: single); overload;

Adds an arc from current position.

Public procedure arcTo(p1,p2: TPointF; radius: single); overload;

Adds an arc from current position using TPointF.

Public procedure arcTo(rx, ry, xAngleRadCW: single; largeArc,anticlockwise: boolean; x, y: single);

Adds an elliptic arc of the given angle from current position.

Public procedure beginPath;

Begins a new path or resets the current path.

Public procedure bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y: single); overload;

Adds a cubic Bézier curve to a specified point.

Public procedure bezierCurveTo(constref cp1,cp2,pt: TPointF); overload;

Adds a cubic Bézier curve to a specified point using TPointF.

Public procedure circle(x,y,r: single);

Adds a full circle.

Public procedure clearPath;

Clears the area represented by the current path, making the canvas transparent

Public procedure clearRect(x,y,w,h: single);

Directly clears a rectangle, making it fully transparent.

Public procedure clip;

Clips the drawing region to the current path.

Public procedure closedSpline(const pts: array of TPointF; style: TSplineStyle);

Adds an closed spline to the current path

Public procedure closePath;

Closes the current path.

Public procedure copyStateFrom(AOtherCanvas2D: TBGRACanvas2D);

Save the current state and copy the canvas state from another canvas.

Public procedure drawImage(image: TBGRACustomBitmap; dx,dy: single; AFilter: TResampleFilter = rfLinear); overload;

Draws an image at the specified location.

Public procedure drawImage(image: TBGRACustomBitmap; dx,dy,dw,dh: single; AFilter: TResampleFilter = rfLinear); overload;

Draws an image with scaling.

Public procedure ellipse(x,y,rx,ry: single);

Adds a full ellipse.

Public procedure fill; overload;

Fills the current path with the current fill style.

Public procedure fill(AFillProc: TBGRAPathFillProc; AData: pointer); overload;

Fills the current path using the specified function.

Public procedure fill(AFillProc: TBGRAPathFillProc; const AMatrix: TAffineMatrix; AData: pointer); overload;

Fills the current path using the specified function and transformation matrix.

Public procedure fillOverStroke;

Fill and stroke at the same time, with filling being on top

Public procedure fillRect(x,y,w,h: single);

Directly fills a rectangle with the current fill style.

Public procedure fillStyle(color: TBGRAPixel); overload;

Sets the fill style to a solid color specified as TBGRAPixel

Public procedure fillStyle(provider: IBGRACanvasTextureProvider2D); overload;

Sets the fill style to a texture using a texture provider.

Public procedure fillStyle(color: string); overload;

Sets the fill style to a solid color specified as CSS string

Public procedure fillStyle(texture: IBGRAScanner); overload;

Sets the fill style to a texture defined by IBGRAScanner interface.

The texture can be a TBGRABitmap object or any custom scanner.

Public procedure fillStyle(color: TColor); overload;

Sets the fill style to a solid color specified as TColor

Public procedure fillText(AText: string; x,y: single);

Fills directly the specified text using current fill style.

Public procedure lineStyle(const AValue: array of single); overload;

Sets the style for lines.

Public procedure lineStyle(AStyle: TPenStyle); overload;

Sets the style for lines using a predefined style.

Public procedure lineTo(constref pt: TPointF); overload;

Connects a line to a specified point using TPointF.

Public procedure lineTo(x,y: single); overload;

Connects with a line to a specified point.

Public procedure mask(image: TBGRACustomBitmap; dx,dy: single; AFilter: TResampleFilter = rfLinear); overload;

Applies the specified mask at the specified location for future drawings.

Public procedure mask(image: TBGRACustomBitmap; dx,dy,dw,dh: single; AFilter: TResampleFilter = rfLinear); overload;

Applies the specified mask with scaling for future drawings.

Public procedure moveTo(x,y: single); overload;

Moves the pen to a new location.

Public procedure moveTo(constref pt: TPointF); overload;

Moves the pen to a new location using TPointF.

Public procedure openedSpline(const pts: array of TPointF; style: TSplineStyle);

Adds an opened spline to the current path

Public procedure path(APath: IBGRAPath); overload;

Replaces the current defined path.

Public procedure path(ASvgPath: string); overload;

Replaces the current defined path defined as SVG path.

Public procedure polylineTo(const pts: array of TPointF);

Add multiple connected lines.

Public procedure quadraticCurveTo(cpx,cpy,x,y: single); overload;

Adds a quadratic Bézier curve to a specified point.

Public procedure quadraticCurveTo(constref cp,pt: TPointF); overload;

Adds a quadratic Bézier curve to a specified point using TPointF.

Public procedure rect(x,y,w,h: single);

Adds a rectangle specified by its top-left corner, width and height

Public procedure resetTransform;

Resets the current transformation matrix to the identity matrix.

Public procedure restore;

Restores the most recently saved canvas state by popping the top entry in the drawing state stack.

If there is no saved state, this method does nothing.

Public procedure rotate(angleRadCW: single);

Rotates the canvas around the origin (0,0) by the given angle in radians, clockwise.

Example rotating around the center of a 200x200 canvas:

canvas2D.translate(100, 100);
canvas2D.rotate(Pi);
canvas2D.translate(-100, -100);

Public procedure roundRect(x,y,w,h,radius: single); overload;

Adds a rounded rectangle.

Public procedure roundRect(x,y,w,h,rx,ry: single); overload;

Adds a rounded rectangle with different x and y radii.

Public procedure save;

Saves the entire state of the canvas by pushing the current state onto a stack.

The drawing state consists of:

  • the current transformation matrix.

  • the current clipping region.

  • the font parameters.

  • the various properties of stroke and fill style.

  • the shadow parameters.

Public procedure scale(x,y: single); overload;

Apply scaling to the canvas with independent x and y scales.

Public procedure scale(factor: single); overload;

Apply uniform scaling to the canvas.

Public procedure setTransform(m11,m21, m12,m22, m13,m23: single);

Resets the current transform to the identity matrix, then applies the new transformation.

Public procedure shadowColor(color: TBGRAPixel); overload;

Sets the color of the shadow specified as TBGRAPixel

Public procedure shadowColor(color: string); overload;

Sets the color of the shadow specified as CSS string

Public procedure shadowColor(color: TColor); overload;

Sets the color of the shadow specified as TColor

Public procedure shadowNone;

Removes any shadow effect from future drawings.

Public procedure skewx(angleRadCW: single);

Skews the drawing on the canvas along the X axis by the given angle in radians.

Public procedure skewy(angleRadCW: single);

Skews the drawing on the canvas along the Y axis by the given angle in radians.

Public procedure spline(const pts: array of TPointF; style: TSplineStyle= ssOutside);

Adds a spline to the current path.

It will be closed if the last point is equal to the first one.

Public procedure splineTo(const pts: array of TPointF; style: TSplineStyle= ssOutside);

Continues from current position with an opened spline.

Public procedure stroke(ADrawProc: TBGRAPathDrawProc; AData: pointer); overload;

Strokes the current path using the specified function.

Public procedure stroke(ADrawProc: TBGRAPathDrawProc; const AMatrix: TAffineMatrix; AData: pointer); overload;

Strokes the current path using the specified function and transformation matrix.

Public procedure stroke; overload;

Strokes the current path with the current stroke style.

Public procedure strokeOverFill;

Fill and stroke at the same time, with stroke being on top

Public procedure strokeRect(x,y,w,h: single);

Directly strokes a rectangle with the current stroke style.

Public procedure strokeResetTransform;

Resets the stroke transformation matrix to the identity matrix, removing any stroke transformations.

Public procedure strokeScale(x,y: single);

Apply scaling to the stroke. Can specify x and y scales independently.

Public procedure strokeSkewx(angleRadCW: single);

Skews the stroke on the canvas along the X axis by the given angle in radians.

Public procedure strokeSkewy(angleRadCW: single);

Skews the stroke on the canvas along the Y axis by the given angle in radians.

Public procedure strokeStyle(color: TBGRAPixel); overload;

Sets the stroke to a solid color specified as TBGRAPixel

Public procedure strokeStyle(provider: IBGRACanvasTextureProvider2D); overload;

Sets the stroke to a texture using a texture provider.

Public procedure strokeStyle(color: TColor); overload;

Sets the stroke to a solid color specified as TColor

Public procedure strokeStyle(texture: IBGRAScanner); overload;

Sets the stroke to a texture defined by IBGRAScanner interface.

The texture can be a TBGRABitmap object or any custom scanner.

Public procedure strokeStyle(color: string); overload;

Sets the stroke to a solid color specified as CSS string

Public procedure strokeText(AText: string; x,y: single);

Draws directly the outline of the specified text using current stroke style.

Public procedure text(AText: string; x,y: single);

Adds the path of a text.

Public procedure toSpline(closed: boolean; style: TSplineStyle= ssOutside);

Converts the current polyline path to a spline.

Public procedure transform(AMatrix: TAffineMatrix); overload;

Applies a pre-built transformation matrix to the canvas.

Public procedure transform(m11,m21, m12,m22, m13,m23: single); overload;

Applies a transformation matrix to the canvas.

Public procedure translate(x,y: single);

Translates the canvas origin to a new location.

Public procedure unclip;

Reintroduce the current path in the drawing region.

Properties

Public property currentPath: ArrayOfTPointF read GetCurrentPathAsPoints;

The current path as an array of points.

Public property direction: TFontBidiMode read GetTextDirection write SetTextDirection;

The direction of the text (left-to-right, right-to-left).

Public property fillMode: TFillMode read GetFillMode write SetFillMode;

The rule to use for filling shapes (non-zero winding, even-odd alternate).

Public property font: string read GetFontString write SetFontString;

Combined font properties in CSS-like string format.

Public property fontEmHeight: single read GetFontEmHeight write SetFontEmHeight;

The size of the font's em square in pixels.

Public property fontName: string read GetFontName write SetFontName;

The name of the font for text drawing.

Public property fontRenderer: TBGRACustomFontRenderer read GetFontRenderer write SetFontRenderer;

The renderer used for custom font drawing.

Public property fontStyle: TFontStyles read GetFontStyle write SetFontStyle;

The style of the font using LCL enumeration set.

Public property globalAlpha: single read GetGlobalAlpha write SetGlobalAlpha;

The global alpha (transparency) applied to drawings.

Public property hasShadow: boolean read GetHasShadow;

Indicates if any shadow is set.

A shadow is visible if the shadow color is set and the offset or the radius is set.

Public property height: Integer read GetHeight;

The height of the underlying bitmap.

Public property lineCap: string read GetLineCap write SetLineCap;

The shape used at the end of lines (butt, round, square).

Public property lineCapLCL: TPenEndCap read GetLineCapLCL write SetLineCapLCL;

Line cap style using LCL enumeration.

Public property lineJoin: string read GetlineJoin write SetLineJoin;

The type of corner created when two lines meet (miter, round, bevel).

Public property lineJoinLCL: TPenJoinStyle read GetlineJoinLCL write SetLineJoinLCL;

Line join style using LCL enumeration.

Public property lineWidth: single read GetLineWidth write SetLineWidth;

The width of lines drawn on the canvas.

Public property matrix: TAffineMatrix read GetMatrix write SetMatrix;

The transformation matrix applied to the path.

Public property miterLimit: single read GetMiterLimit write SetMiterLimit;

The maximum miter length when connecting lines.

Public property pixelCenteredCoordinates: boolean read GetPixelCenteredCoordinates write SetPixelCenteredCoordinates;

Determines if coordinates are centered on pixels (false by default).

Public property shadowBlur: single read GetShadowBlur write SetShadowBlur;

The blur level of the shadow.

Public property shadowFastest: boolean read GetShadowFastest write SetShadowFastest;

If true, uses a faster but less accurate shadow algorithm.

Public property shadowOffset: TPointF read GetShadowOffset write SetShadowOffset;

The offset of the shadow as a TPointF.

Public property shadowOffsetX: single read GetShadowOffsetX write SetShadowOffsetX;

The horizontal offset of the shadow from the shape.

Public property shadowOffsetY: single read GetShadowOffsetY write SetShadowOffsetY;

The vertical offset of the shadow from the shape.

Public property strokeMatrix: TAffineMatrix read GetStrokeMatrix write SetStrokeMatrix;

The transformation matrix applied to pen.

Public property surface: TBGRACustomBitmap read FSurface;

The underlying bitmap where the canvas draws.

Public property textAlign: string read GetTextAlign write SetTextAlign;

Horizontal alignment of text (left, right, center, start, end).

Public property textAlignLCL: TAlignment read GetTextAlignLCL write SetTextAlignLCL;

Horizontal alignment of text using LCL enumeration.

Public property textBaseline: string read GetTextBaseline write SetTextBaseline;

Vertical alignment of text (top, middle, alphabetic, bottom).

Public property width: Integer read GetWidth;

The width of the underlying bitmap.