Ignore:
Timestamp:
Dec 22, 2016, 8:49:19 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Updated BGRABitmap package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/bgraarrow.pas

    r472 r494  
    66
    77uses
    8   Classes, SysUtils, BGRABitmapTypes, Graphics;
     8  Classes, SysUtils, BGRABitmapTypes, BGRAGraphics;
    99
    1010type
    11 
    1211  { TBGRAArrow }
    1312
    14   TBGRAArrow = class
     13  TBGRAArrow = class(TBGRACustomArrow)
    1514  private
    1615    FLineCap: TPenEndCap;
     
    3837        ATipStyle: TPenJoinStyle; ALineCap: TPenEndCap; const AWidth: single; AOffsetX: single;
    3938        ARepeatCount: integer; ARelativePenWidth: single; ATriangleBackOffset: single): ArrayOfTPointF;
    40     function GetIsEndDefined: boolean;
    41     function GetIsStartDefined: boolean;
    42     procedure SetEndOffsetX(AValue: single);
    43     procedure SetEndRepeatCount(AValue: integer);
    44     procedure SetEndSizeFactor(AValue: TPointF);
    45     procedure SetLineCap(AValue: TPenEndCap);
    46     procedure SetStartOffsetX(AValue: single);
    47     procedure SetStartRepeatCount(AValue: integer);
    48     procedure SetStartSizeFactor(AValue: TPointF);
    4939    procedure SetWidth(AValue: single);
     40  protected
     41    function GetEndRepeatCount: integer; override;
     42    function GetEndSizeFactor: TPointF; override;
     43    function GetIsEndDefined: boolean; override;
     44    function GetIsStartDefined: boolean; override;
     45    function GetEndOffsetX: single; override;
     46    function GetStartOffsetX: single; override;
     47    function GetStartRepeatCount: integer; override;
     48    function GetStartSizeFactor: TPointF; override;
     49    procedure SetEndOffsetX(AValue: single); override;
     50    procedure SetEndRepeatCount(AValue: integer); override;
     51    procedure SetEndSizeFactor(AValue: TPointF); override;
     52    procedure SetStartOffsetX(AValue: single); override;
     53    procedure SetStartRepeatCount(AValue: integer); override;
     54    procedure SetStartSizeFactor(AValue: TPointF); override;
     55    function GetLineCap: TPenEndCap; override;
     56    procedure SetLineCap(AValue: TPenEndCap); override;
     57    procedure SetStart(AStyle: TBGRAArrowStyle; ATipStyle: TPenJoinStyle = pjsMiter; ARelativePenWidth: single = 1; ATriangleBackOffset: single = 0);
     58    procedure SetEnd(AStyle: TBGRAArrowStyle; ATipStyle: TPenJoinStyle = pjsMiter; ARelativePenWidth: single = 1; ATriangleBackOffset: single = 0);
    5059  public
    5160    constructor Create;
    52     procedure SetStart(AStyle: TBGRAArrowStyle; ATipStyle: TPenJoinStyle;
    53         ARelativePenWidth: single; ATriangleBackOffset: single);
    54     procedure SetEnd(AStyle: TBGRAArrowStyle; ATipStyle: TPenJoinStyle;
    55         ARelativePenWidth: single; ATriangleBackOffset: single);
    56     function ComputeStartAt(const APosition: TPointF; const ADirection: TPointF; const AWidth: single; const ACurrentPos: single): ArrayOfTPointF;
    57     function ComputeEndAt(const APosition: TPointF; const ADirection: TPointF; const AWidth: single; const ACurrentPos: single): ArrayOfTPointF;
    58     property IsStartDefined: boolean read GetIsStartDefined;
    59     property IsEndDefined: boolean read GetIsEndDefined;
    60     property LineCap: TPenEndCap read FLineCap write SetLineCap;
    61     property StartSize: TPointF read FStartSizeFactor write SetStartSizeFactor;
    62     property EndSize: TPointF read FEndSizeFactor write SetEndSizeFactor;
    63     property StartOffsetX: single read FStartOffsetX write SetStartOffsetX;
    64     property EndOffsetX: single read FEndOffsetX write SetEndOffsetX;
    65     property StartRepeatCount: integer read FStartRepeatCount write SetStartRepeatCount;
    66     property EndRepeatCount: integer read FEndRepeatCount write SetEndRepeatCount;
     61    procedure StartAsNone; override;
     62    procedure StartAsClassic(AFlipped: boolean = false; ACut: boolean = false; ARelativePenWidth: single = 1); override;
     63    procedure StartAsTriangle(ABackOffset: single = 0; ARounded: boolean = false; AHollow: boolean = false; AHollowPenWidth: single = 0.5); override;
     64    procedure StartAsTail; override;
     65    procedure EndAsNone; override;
     66    procedure EndAsClassic(AFlipped: boolean = false; ACut: boolean = false; ARelativePenWidth: single = 1); override;
     67    procedure EndAsTriangle(ABackOffset: single = 0; ARounded: boolean = false; AHollow: boolean = false; AHollowPenWidth: single = 0.5); override;
     68    procedure EndAsTail; override;
     69    function ComputeStartAt(const APosition: TPointF; const ADirection: TPointF; const AWidth: single; const ACurrentPos: single): ArrayOfTPointF; override;
     70    function ComputeEndAt(const APosition: TPointF; const ADirection: TPointF; const AWidth: single; const ACurrentPos: single): ArrayOfTPointF; override;
     71
    6772  end;
    6873
     
    258263end;
    259264
     265function TBGRAArrow.GetEndOffsetX: single;
     266begin
     267  result := FEndOffsetX;
     268end;
     269
     270function TBGRAArrow.GetStartOffsetX: single;
     271begin
     272  result := FStartOffsetX;
     273end;
     274
     275function TBGRAArrow.GetStartRepeatCount: integer;
     276begin
     277  result := FStartRepeatCount;
     278end;
     279
     280function TBGRAArrow.GetStartSizeFactor: TPointF;
     281begin
     282  result := FStartSizeFactor;
     283end;
     284
    260285procedure TBGRAArrow.SetEndOffsetX(AValue: single);
    261286begin
     
    264289  FEndComputed:= false;
    265290  FEnd := nil;
     291end;
     292
     293function TBGRAArrow.GetLineCap: TPenEndCap;
     294begin
     295  result := FLineCap;
    266296end;
    267297
     
    324354end;
    325355
     356function TBGRAArrow.GetEndRepeatCount: integer;
     357begin
     358  Result:= FEndRepeatCount;
     359end;
     360
     361function TBGRAArrow.GetEndSizeFactor: TPointF;
     362begin
     363  Result:= FEndSizeFactor;
     364end;
     365
    326366constructor TBGRAArrow.Create;
    327367begin
     
    329369  FStartSizeFactor := PointF(2,2);
    330370  FEndSizeFactor := PointF(2,2);
     371end;
     372
     373procedure TBGRAArrow.StartAsNone;
     374begin
     375  SetStart(asNone);
     376end;
     377
     378procedure TBGRAArrow.StartAsClassic(AFlipped: boolean; ACut: boolean;
     379  ARelativePenWidth: single);
     380var join: TPenJoinStyle;
     381begin
     382  if (LineCap = pecRound) and not ACut then join := pjsRound else join := pjsMiter;
     383  if ACut then
     384  begin
     385    if AFlipped then
     386      SetStart(asFlippedCut,join,ARelativePenWidth)
     387    else
     388      SetStart(asCut,join,ARelativePenWidth)
     389  end
     390  else
     391  begin
     392    if AFlipped then
     393      SetStart(asFlipped,join,ARelativePenWidth)
     394    else
     395      SetStart(asNormal,join,ARelativePenWidth)
     396  end;
     397end;
     398
     399procedure TBGRAArrow.StartAsTriangle(ABackOffset: single; ARounded: boolean;
     400  AHollow: boolean; AHollowPenWidth: single);
     401var join: TPenJoinStyle;
     402begin
     403  if ARounded then join := pjsRound else join := pjsMiter;
     404  if AHollow then
     405    SetStart(asHollowTriangle, join,AHollowPenWidth, ABackOffset)
     406  else
     407    SetStart(asTriangle, join,1,ABackOffset);
     408end;
     409
     410procedure TBGRAArrow.StartAsTail;
     411begin
     412  SetStart(asTail);
     413end;
     414
     415procedure TBGRAArrow.EndAsNone;
     416begin
     417  SetEnd(asNone);
     418end;
     419
     420procedure TBGRAArrow.EndAsClassic(AFlipped: boolean; ACut: boolean;
     421  ARelativePenWidth: single);
     422var join: TPenJoinStyle;
     423begin
     424  if (LineCap = pecRound) and not ACut then join := pjsRound else join := pjsMiter;
     425  if ACut then
     426  begin
     427    if AFlipped then
     428      SetEnd(asFlippedCut,join,ARelativePenWidth)
     429    else
     430      SetEnd(asCut,join,ARelativePenWidth)
     431  end
     432  else
     433  begin
     434    if AFlipped then
     435      SetEnd(asFlipped,join,ARelativePenWidth)
     436    else
     437      SetEnd(asNormal,join,ARelativePenWidth)
     438  end;
     439end;
     440
     441procedure TBGRAArrow.EndAsTriangle(ABackOffset: single; ARounded: boolean;
     442  AHollow: boolean; AHollowPenWidth: single);
     443var join: TPenJoinStyle;
     444begin
     445  if ARounded then join := pjsRound else join := pjsMiter;
     446  if AHollow then
     447    SetEnd(asHollowTriangle, join,AHollowPenWidth, ABackOffset)
     448  else
     449    SetEnd(asTriangle, join,1, ABackOffset);
     450end;
     451
     452procedure TBGRAArrow.EndAsTail;
     453begin
     454  SetEnd(asTail);
    331455end;
    332456
Note: See TracChangeset for help on using the changeset viewer.