![]() |
![]() |
![]() |
function ShortenPath(const path: TPathD; pathEnd: TPathEnd; amount: double): TPathD;
Shortens an open path at one or both ends depending on the pathEnd parameter. If 'amount' is long enough, vertices may also be removed from the path.
uses Image32, Image32_PNG, Image32_Vector, Image32_Draw; ... var img: TImage32; pts: array [0..3] of TPointD; path, head, tail: TPathD; lineWidth, arrowHeadSize: integer; begin pts[0] := PointD(20,20); pts[1] := PointD(130,20); pts[2] := PointD(130,240); pts[3] := PointD(240,240); lineWidth := 5; arrowHeadSize := GetDefaultArrowHeadSize(lineWidth); //create a curved path and then shorten it to accommodate arrow heads path := FlattenCBezier(pts[0], pts[1], pts[2], pts[3]); path := ShortenPath(path, peBothEnds, arrowHeadSize); //create the arrow heads tail := ArrowHead(pts[0], path[0], arrowHeadSize, asCircle); head := ArrowHead(pts[3], path[High(path)], arrowHeadSize, asFancy); //draw the path and the arrow heads img := TImage32.Create(256,256); DrawLine(img, path, lineWidth, clBlack32, esRound); DrawLine(img, tail, lineWidth, clBlack32, esClosed); DrawLine(img, head, lineWidth, clBlack32, esClosed); img.SaveToFile('arrow.png'); img.Free;
![]() |
Copyright ©2019 Angus Johnson - Image32 ver. 1.54 - Documentation last updated on 7-November-2020