Changeset 494 for GraphicTest/Packages/bgrabitmap/bgraarrow.pas
- Timestamp:
- Dec 22, 2016, 8:49:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/bgraarrow.pas
r472 r494 6 6 7 7 uses 8 Classes, SysUtils, BGRABitmapTypes, Graphics;8 Classes, SysUtils, BGRABitmapTypes, BGRAGraphics; 9 9 10 10 type 11 12 11 { TBGRAArrow } 13 12 14 TBGRAArrow = class 13 TBGRAArrow = class(TBGRACustomArrow) 15 14 private 16 15 FLineCap: TPenEndCap; … … 38 37 ATipStyle: TPenJoinStyle; ALineCap: TPenEndCap; const AWidth: single; AOffsetX: single; 39 38 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);49 39 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); 50 59 public 51 60 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 67 72 end; 68 73 … … 258 263 end; 259 264 265 function TBGRAArrow.GetEndOffsetX: single; 266 begin 267 result := FEndOffsetX; 268 end; 269 270 function TBGRAArrow.GetStartOffsetX: single; 271 begin 272 result := FStartOffsetX; 273 end; 274 275 function TBGRAArrow.GetStartRepeatCount: integer; 276 begin 277 result := FStartRepeatCount; 278 end; 279 280 function TBGRAArrow.GetStartSizeFactor: TPointF; 281 begin 282 result := FStartSizeFactor; 283 end; 284 260 285 procedure TBGRAArrow.SetEndOffsetX(AValue: single); 261 286 begin … … 264 289 FEndComputed:= false; 265 290 FEnd := nil; 291 end; 292 293 function TBGRAArrow.GetLineCap: TPenEndCap; 294 begin 295 result := FLineCap; 266 296 end; 267 297 … … 324 354 end; 325 355 356 function TBGRAArrow.GetEndRepeatCount: integer; 357 begin 358 Result:= FEndRepeatCount; 359 end; 360 361 function TBGRAArrow.GetEndSizeFactor: TPointF; 362 begin 363 Result:= FEndSizeFactor; 364 end; 365 326 366 constructor TBGRAArrow.Create; 327 367 begin … … 329 369 FStartSizeFactor := PointF(2,2); 330 370 FEndSizeFactor := PointF(2,2); 371 end; 372 373 procedure TBGRAArrow.StartAsNone; 374 begin 375 SetStart(asNone); 376 end; 377 378 procedure TBGRAArrow.StartAsClassic(AFlipped: boolean; ACut: boolean; 379 ARelativePenWidth: single); 380 var join: TPenJoinStyle; 381 begin 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; 397 end; 398 399 procedure TBGRAArrow.StartAsTriangle(ABackOffset: single; ARounded: boolean; 400 AHollow: boolean; AHollowPenWidth: single); 401 var join: TPenJoinStyle; 402 begin 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); 408 end; 409 410 procedure TBGRAArrow.StartAsTail; 411 begin 412 SetStart(asTail); 413 end; 414 415 procedure TBGRAArrow.EndAsNone; 416 begin 417 SetEnd(asNone); 418 end; 419 420 procedure TBGRAArrow.EndAsClassic(AFlipped: boolean; ACut: boolean; 421 ARelativePenWidth: single); 422 var join: TPenJoinStyle; 423 begin 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; 439 end; 440 441 procedure TBGRAArrow.EndAsTriangle(ABackOffset: single; ARounded: boolean; 442 AHollow: boolean; AHollowPenWidth: single); 443 var join: TPenJoinStyle; 444 begin 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); 450 end; 451 452 procedure TBGRAArrow.EndAsTail; 453 begin 454 SetEnd(asTail); 331 455 end; 332 456
Note:
See TracChangeset
for help on using the changeset viewer.