Class TBGRACustomArrow

Unit

Declaration

type TBGRACustomArrow = class(TObject)

Description

Generic class configuring and rendering an arrow.

Example using different kind of arrows:

arrows

uses BGRABitmap, BGRABitmapTypes;

procedure TForm1.FormPaint(Sender: TObject);
var bmp:TBGRABitmap;
  w: single;
begin
  bmp := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRAWhite);
  w := sqrt(ClientWidth*ClientHeight)/50;

  // diagonal arrow
  bmp.Arrow.StartAsTail;
  bmp.Arrow.StartRepeatCount := 2;
  bmp.Arrow.EndAsTriangle(0.25,False,True);
  bmp.DrawPolyLineAntialias(
    bmp.ComputeOpenedSpline([PointF(80,80),PointF(ClientWidth-160,ClientHeight div 2),PointF(ClientWidth-80,ClientHeight-20)],ssCrossingWithEnds),
    BGRABlack,w);
  bmp.Arrow.StartRepeatCount := 1; //restore default value

  // top arrow
  bmp.Arrow.StartAsClassic(True,True,3);
  bmp.Arrow.StartOffsetX := -8;
  bmp.Arrow.EndAsClassic(False,True);
  bmp.DrawPolyLineAntialias(
    bmp.ComputeOpenedSpline([PointF(40,60),PointF(ClientWidth div 3,20),PointF(ClientWidth-80,40)],ssCrossingWithEnds),
    BGRABlack,w);
  bmp.Arrow.StartOffsetX := 0; //restore default value

  // left arrow
  bmp.Arrow.StartAsClassic(True,True);
  bmp.Arrow.StartSize := PointF(1,2);
  bmp.Arrow.StartOffsetX := -5.5;
  bmp.Arrow.StartRepeatCount := 3;
  bmp.Arrow.EndAsTriangle(0.75);
  bmp.DrawLineAntialias(20,90, 80,ClientHeight-40,
    BGRABlack,w);
  bmp.Arrow.StartSize := PointF(2,2); //restore default values
  bmp.Arrow.StartOffsetX := 0;
  bmp.Arrow.StartRepeatCount := 1;

  // right arrow
  bmp.Arrow.StartAsClassic;
  bmp.Arrow.EndAsClassic(False,False,2);
  bmp.DrawLineAntialias(ClientWidth-40,40,ClientWidth-40,ClientHeight-80,BGRABlack,w);

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

Hierarchy

Overview

Methods

Public function ComputeEndAt(const APosition, ADirection: TPointF; const AWidth, ACurrentPos: single): ArrayOfTPointF; virtual; abstract;
Public function ComputeStartAt(const APosition, ADirection: TPointF; const AWidth, ACurrentPos: single): ArrayOfTPointF; virtual; abstract;
Protected function GetEndOffsetX: single; virtual; abstract;
Protected function GetEndRepeatCount: integer; virtual; abstract;
Protected function GetEndSizeFactor: TPointF; virtual; abstract;
Protected function GetIsEndDefined: boolean; virtual; abstract;
Protected function GetIsStartDefined: boolean; virtual; abstract;
Protected function GetLineCap: TPenEndCap; virtual; abstract;
Protected function GetStartOffsetX: single; virtual; abstract;
Protected function GetStartRepeatCount: integer; virtual; abstract;
Protected function GetStartSizeFactor: TPointF; virtual; abstract;
Public procedure EndAsClassic(AFlipped: boolean = false; ACut: boolean = false; ARelativePenWidth: single = 1); virtual; abstract;
Public procedure EndAsNone; virtual; abstract;
Public procedure EndAsTail; virtual; abstract;
Public procedure EndAsTriangle(ABackOffset: single = 0; ARounded: boolean = false; AHollow: boolean = false; AHollowPenWidth: single = 0.5); virtual; abstract;
Public procedure StartAsClassic(AFlipped: boolean = false; ACut: boolean = false; ARelativePenWidth: single = 1); virtual; abstract;
Public procedure StartAsNone; virtual; abstract;
Public procedure StartAsTail; virtual; abstract;
Public procedure StartAsTriangle(ABackOffset: single = 0; ARounded: boolean = false; AHollow: boolean = false; AHollowPenWidth: single = 0.5); virtual; abstract;
Protected procedure SetEndOffsetX(AValue: single); virtual; abstract;
Protected procedure SetEndRepeatCount(AValue: integer); virtual; abstract;
Protected procedure SetEndSizeFactor(AValue: TPointF); virtual; abstract;
Protected procedure SetLineCap(AValue: TPenEndCap); virtual; abstract;
Protected procedure SetStartOffsetX(AValue: single); virtual; abstract;
Protected procedure SetStartRepeatCount(AValue: integer); virtual; abstract;
Protected procedure SetStartSizeFactor(AValue: TPointF); virtual; abstract;

Properties

Public property EndOffsetX: single read GetEndOffsetX write SetEndOffsetX;
Public property EndRepeatCount: integer read GetEndRepeatCount write SetEndRepeatCount;
Public property EndSize: TPointF read GetEndSizeFactor write SetEndSizeFactor;
Public property IsEndDefined: boolean read GetIsEndDefined;
Public property IsStartDefined: boolean read GetIsStartDefined;
Public property LineCap: TPenEndCap read GetLineCap write SetLineCap;
Public property StartOffsetX: single read GetStartOffsetX write SetStartOffsetX;
Public property StartRepeatCount: integer read GetStartRepeatCount write SetStartRepeatCount;
Public property StartSize: TPointF read GetStartSizeFactor write SetStartSizeFactor;

Description

Methods

Public function ComputeEndAt(const APosition, ADirection: TPointF; const AWidth, ACurrentPos: single): ArrayOfTPointF; virtual; abstract;

Computes the end of the arrow at a given position and direction

Public function ComputeStartAt(const APosition, ADirection: TPointF; const AWidth, ACurrentPos: single): ArrayOfTPointF; virtual; abstract;

Computes the start of the arrow at a given position and direction

Protected function GetEndOffsetX: single; virtual; abstract;

Retrieves the X-offset for the end of the arrow

Protected function GetEndRepeatCount: integer; virtual; abstract;

Retrieves the repeat count for the end symbol

Protected function GetEndSizeFactor: TPointF; virtual; abstract;

Retrieves the size factor for the end of the arrow

Protected function GetIsEndDefined: boolean; virtual; abstract;

Determines if the end of the arrow is defined

Protected function GetIsStartDefined: boolean; virtual; abstract;

Determines if the start of the arrow is defined

Protected function GetLineCap: TPenEndCap; virtual; abstract;

Retrieves the line cap style for the classic arrow

Protected function GetStartOffsetX: single; virtual; abstract;

Retrieves the X-offset for the start of the arrow

Protected function GetStartRepeatCount: integer; virtual; abstract;

Retrieves the repeat count for the start symbol

Protected function GetStartSizeFactor: TPointF; virtual; abstract;

Retrieves the size factor for the start of the arrow

Public procedure EndAsClassic(AFlipped: boolean = false; ACut: boolean = false; ARelativePenWidth: single = 1); virtual; abstract;

Sets the end of the arrow to a classic style

Public procedure EndAsNone; virtual; abstract;

Sets the end of the arrow to no style

Public procedure EndAsTail; virtual; abstract;

Sets the end of the arrow to a tail style

Public procedure EndAsTriangle(ABackOffset: single = 0; ARounded: boolean = false; AHollow: boolean = false; AHollowPenWidth: single = 0.5); virtual; abstract;

Sets the end of the arrow to a triangle style

Public procedure StartAsClassic(AFlipped: boolean = false; ACut: boolean = false; ARelativePenWidth: single = 1); virtual; abstract;

Sets the start of the arrow to a classic style

Public procedure StartAsNone; virtual; abstract;

Sets the start of the arrow to no style

Public procedure StartAsTail; virtual; abstract;

Sets the start of the arrow to a tail style

Public procedure StartAsTriangle(ABackOffset: single = 0; ARounded: boolean = false; AHollow: boolean = false; AHollowPenWidth: single = 0.5); virtual; abstract;

Sets the start of the arrow to a triangle style

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

Sets the X-offset for the end of the arrow

Protected procedure SetEndRepeatCount(AValue: integer); virtual; abstract;

Sets the repeat count for the end symbol

Protected procedure SetEndSizeFactor(AValue: TPointF); virtual; abstract;

Sets the size factor for the end of the arrow

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

Sets the line cap style for the classic arrow

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

Sets the X-offset for the start of the arrow

Protected procedure SetStartRepeatCount(AValue: integer); virtual; abstract;

Sets the repeat count for the start symbol

Protected procedure SetStartSizeFactor(AValue: TPointF); virtual; abstract;

Sets the size factor for the start of the arrow

Properties

Public property EndOffsetX: single read GetEndOffsetX write SetEndOffsetX;

X-offset for the end of the arrow

Public property EndRepeatCount: integer read GetEndRepeatCount write SetEndRepeatCount;

Repeat count for the end symbol

Public property EndSize: TPointF read GetEndSizeFactor write SetEndSizeFactor;

Size factor for the end of the arrow

Public property IsEndDefined: boolean read GetIsEndDefined;

Check if the end of the arrow is defined

Public property IsStartDefined: boolean read GetIsStartDefined;

Check if the start of the arrow is defined

Public property LineCap: TPenEndCap read GetLineCap write SetLineCap;

Line cap style

Public property StartOffsetX: single read GetStartOffsetX write SetStartOffsetX;

X-offset for the start of the arrow

Public property StartRepeatCount: integer read GetStartRepeatCount write SetStartRepeatCount;

Repeat count for the start symbol

Public property StartSize: TPointF read GetStartSizeFactor write SetStartSizeFactor;

Size factor for the start of the arrow