Class TBGRACustomPenStroker

Unit

Declaration

type TBGRACustomPenStroker = class(TObject)

Description

Generic class representing a pen stroker, used for drawing and styling lines with various attributes

Hierarchy

Overview

Methods

Public function ComputePolygon(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; virtual; abstract;
Public function ComputePolyline(const APoints: array of TPointF; AWidth: single; APenColor: TBGRAPixel; AClosedCap: boolean = true): ArrayOfTPointF; overload; virtual; abstract;
Public function ComputePolyline(const APoints: array of TPointF; AWidth: single; AClosedCap: boolean = true): ArrayOfTPointF; overload; virtual; abstract;
Public function ComputePolylineAutoCycle(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; virtual; abstract;
Protected function GetArrow: TBGRACustomArrow; virtual; abstract;
Protected function GetArrowOwned: boolean; virtual; abstract;
Protected function GetCustomPenStyle: TBGRAPenStyle; virtual; abstract;
Protected function GetJoinStyle: TPenJoinStyle; virtual; abstract;
Protected function GetLineCap: TPenEndCap; virtual; abstract;
Protected function GetMiterLimit: single; virtual; abstract;
Protected function GetPenStyle: TPenStyle; virtual; abstract;
Protected function GetStrokeMatrix: TAffineMatrix; virtual; abstract;
Protected procedure SetArrow(AValue: TBGRACustomArrow); virtual; abstract;
Protected procedure SetArrowOwned(AValue: boolean); virtual; abstract;
Protected procedure SetCustomPenStyle(AValue: TBGRAPenStyle); virtual; abstract;
Protected procedure SetJoinStyle(AValue: TPenJoinStyle); virtual; abstract;
Protected procedure SetLineCap(AValue: TPenEndCap); virtual; abstract;
Protected procedure SetMiterLimit(AValue: single); virtual; abstract;
Protected procedure SetPenStyle(AValue: TPenStyle); virtual; abstract;
Protected procedure SetStrokeMatrix(const AValue: TAffineMatrix); virtual; abstract;

Properties

Public property Arrow: TBGRACustomArrow read GetArrow write SetArrow;
Public property ArrowOwned: boolean read GetArrowOwned write SetArrowOwned;
Public property CustomPenStyle: TBGRAPenStyle read GetCustomPenStyle write SetCustomPenStyle;
Public property JoinStyle: TPenJoinStyle read GetJoinStyle write SetJoinStyle;
Public property LineCap: TPenEndCap read GetLineCap write SetLineCap;
Public property MiterLimit: single read GetMiterLimit write SetMiterLimit;
Public property StrokeMatrix: TAffineMatrix read GetStrokeMatrix write SetStrokeMatrix;
Public property Style: TPenStyle read GetPenStyle write SetPenStyle;

Description

Methods

Public function ComputePolygon(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; virtual; abstract;

Computes a polygon with the given points and width

Public function ComputePolyline(const APoints: array of TPointF; AWidth: single; APenColor: TBGRAPixel; AClosedCap: boolean = true): ArrayOfTPointF; overload; virtual; abstract;

Computes a polyline with the given points, width, and pen color, optionally closing the cap

Public function ComputePolyline(const APoints: array of TPointF; AWidth: single; AClosedCap: boolean = true): ArrayOfTPointF; overload; virtual; abstract;

Computes a polyline with the given points and width, optionally closing the cap

Public function ComputePolylineAutoCycle(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; virtual; abstract;

Computes a polyline with automatic cycling of points and given width

Protected function GetArrow: TBGRACustomArrow; virtual; abstract;

Retrieves the arrow style used at both ends of strokes

Protected function GetArrowOwned: boolean; virtual; abstract;

Determines if the arrow is owned (managed) by the pen stroker

Protected function GetCustomPenStyle: TBGRAPenStyle; virtual; abstract;

Gets the custom pen style

Protected function GetJoinStyle: TPenJoinStyle; virtual; abstract;

Retrieves the style of line joins (e.g., bevel, miter)

Protected function GetLineCap: TPenEndCap; virtual; abstract;

Retrieves the line cap style (e.g., butt, round)

Protected function GetMiterLimit: single; virtual; abstract;

Gets the miter limit for line joins

Protected function GetPenStyle: TPenStyle; virtual; abstract;

Retrieves the standard pen style

Protected function GetStrokeMatrix: TAffineMatrix; virtual; abstract;

Gets the stroke transformation matrix (applied only to stroke and not to path points)

Protected procedure SetArrow(AValue: TBGRACustomArrow); virtual; abstract;

Sets the arrow style used at both ends of strokes

Protected procedure SetArrowOwned(AValue: boolean); virtual; abstract;

Sets whether the arrow is owned by the pen stroker

Protected procedure SetCustomPenStyle(AValue: TBGRAPenStyle); virtual; abstract;

Sets the custom pen style

Protected procedure SetJoinStyle(AValue: TPenJoinStyle); virtual; abstract;

Sets the style of line joins

Protected procedure SetLineCap(AValue: TPenEndCap); virtual; abstract;

Sets the line cap style

Protected procedure SetMiterLimit(AValue: single); virtual; abstract;

Sets the miter limit for line joins

Protected procedure SetPenStyle(AValue: TPenStyle); virtual; abstract;

Sets the standard pen style

Protected procedure SetStrokeMatrix(const AValue: TAffineMatrix); virtual; abstract;

Sets the stroke transformation matrix (applied only to stroke and not to path points)

Properties

Public property Arrow: TBGRACustomArrow read GetArrow write SetArrow;

Arrow style at both ends of strokes

Public property ArrowOwned: boolean read GetArrowOwned write SetArrowOwned;

Is the arrow is owned by the pen stroker

Public property CustomPenStyle: TBGRAPenStyle read GetCustomPenStyle write SetCustomPenStyle;

Custom pen style (with given dash and gap lengths)

Public property JoinStyle: TPenJoinStyle read GetJoinStyle write SetJoinStyle;

Join style of lines

Public property LineCap: TPenEndCap read GetLineCap write SetLineCap;

Line cap style

Public property MiterLimit: single read GetMiterLimit write SetMiterLimit;

Miter limit for line joins

Public property StrokeMatrix: TAffineMatrix read GetStrokeMatrix write SetStrokeMatrix;

Stroke transformation matrix.

This matrix is applied only to stroke and not to path points.

Example of skew transform:

pen_skew

uses BGRABitmapTypes, BGRATransform;

procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
var
  i: Integer;
begin
  for i := 0 to 5 do
  begin
    Bitmap.Pen.StrokeMatrix := AffineMatrixSkewXDeg(-10*i);
    Bitmap.Pen.LineCap := pecSquare;
    Bitmap.DrawLineAntialias(40,40+i*80,Bitmap.Width div 2-40,40+i*80, BGRABlack,30);
    Bitmap.Pen.LineCap := pecRound;
    Bitmap.DrawLineAntialias(Bitmap.Width div 2+40,40+i*80,Bitmap.Width-40,40+i*80, BGRABlack,30);
  end;
end;

Public property Style: TPenStyle read GetPenStyle write SetPenStyle;

Standard pen style