Changeset 521 for GraphicTest/Packages/bgrabitmap/bgrapen.pas
- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/bgrapen.pas
r494 r521 18 18 19 19 type 20 TPenJoinStyle = BGRAGraphics.TPenJoinStyle; 21 TPenEndCap = BGRAGraphics.TPenEndCap; 20 22 21 23 { TBGRAPenStroker } … … 56 58 constructor Create; 57 59 destructor Destroy; override; 58 function ComputePolyline(const APoints: array of TPointF; AWidth: single; AClosedCap: boolean = true): ArrayOfTPointF; over ride;59 function ComputePolyline(const APoints: array of TPointF; AWidth: single; APenColor: TBGRAPixel; AClosedCap: boolean = true): ArrayOfTPointF; over ride;60 function ComputePolyline(const APoints: array of TPointF; AWidth: single; AClosedCap: boolean = true): ArrayOfTPointF; overload; override; 61 function ComputePolyline(const APoints: array of TPointF; AWidth: single; APenColor: TBGRAPixel; AClosedCap: boolean = true): ArrayOfTPointF; overload; override; 60 62 function ComputePolylineAutocycle(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; override; 61 63 function ComputePolygon(const APoints: array of TPointF; AWidth: single): ArrayOfTPointF; override; … … 91 93 //antialiased version 92 94 procedure BGRADrawLineAntialias({%H-}dest: TBGRACustomBitmap; x1, y1, x2, y2: integer; 93 c: TBGRAPixel; DrawLastPixel: boolean; LinearBlend : boolean = false); 95 c: TBGRAPixel; DrawLastPixel: boolean; LinearBlend : boolean = false); overload; 94 96 procedure BGRAEraseLineAntialias(dest: TBGRACustomBitmap; x1, y1, x2, y2: integer; 95 calpha: byte; DrawLastPixel: boolean); 97 calpha: byte; DrawLastPixel: boolean); overload; 96 98 97 99 //antialiased version with bicolor dashes (to draw a frame) 98 100 procedure BGRADrawLineAntialias(dest: TBGRACustomBitmap; x1, y1, x2, y2: integer; 99 c1, c2: TBGRAPixel; dashLen: integer; DrawLastPixel: boolean; var DashPos: integer; LinearBlend : boolean = false); 101 c1, c2: TBGRAPixel; dashLen: integer; DrawLastPixel: boolean; var DashPos: integer; LinearBlend : boolean = false); overload; 100 102 101 103 //length added to ensure accepable alpha join (using TBGRAMultishapeFiller is still better) … … 110 112 function IsClearPenStyle(ACustomPenStyle: TBGRAPenStyle): boolean; 111 113 function DuplicatePenStyle(ACustomPenStyle: array of single): TBGRAPenStyle; 114 function PenStyleEqual(AStyle1, AStyle2: TBGRAPenStyle): boolean; 115 function BGRAToPenStyle(ACustomPenStyle: TBGRAPenStyle): TPenStyle; 112 116 113 117 implementation … … 636 640 end; 637 641 642 function BGRAToPenStyle(ACustomPenStyle: TBGRAPenStyle): TPenStyle; 643 begin 644 if IsSolidPenStyle(ACustomPenStyle) then exit(psSolid); 645 if IsClearPenStyle(ACustomPenStyle) then exit(psClear); 646 if PenStyleEqual(ACustomPenStyle, DashPenStyle) then exit(psDash); 647 if PenStyleEqual(ACustomPenStyle, DotPenStyle) then exit(psDot); 648 if PenStyleEqual(ACustomPenStyle, DashDotPenStyle) then exit(psDashDot); 649 if PenStyleEqual(ACustomPenStyle, DashDotDotPenStyle) then exit(psDashDotDot); 650 exit(psPattern); 651 end; 652 653 function PenStyleEqual(AStyle1, AStyle2: TBGRAPenStyle): boolean; 654 var 655 i: Integer; 656 begin 657 if length(AStyle1)<>length(AStyle2) then exit(false); 658 for i := 0 to high(AStyle1) do 659 if AStyle1[i] <> AStyle2[i] then exit(false); 660 exit(true); 661 end; 662 638 663 procedure ApplyPenStyle(const leftPts, rightPts: array of TPointF; const penstyle: TBGRAPenStyle; 639 664 width: single; var posstyle: single; out styledPts: ArrayOfTPointF); … … 658 683 begin 659 684 dashStartIndex := index; 660 dashLeftStartPos := leftPts[index] + (leftPts[index+1]-leftPts[index])*t; 661 dashRightStartPos := rightPts[index] + (rightPts[index+1]-rightPts[index])*t; 685 if t = 0 then 686 begin 687 dashLeftStartPos := leftPts[index]; 688 dashRightStartPos := rightPts[index]; 689 end else 690 begin 691 dashLeftStartPos := leftPts[index] + (leftPts[index+1]-leftPts[index])*t; 692 dashRightStartPos := rightPts[index] + (rightPts[index+1]-rightPts[index])*t; 693 end; 662 694 betweenDash := false; 663 695 end;
Note:
See TracChangeset
for help on using the changeset viewer.