📄 flexpath.int
字号:
/////////////////////////////////////////////////////////
// //
// FlexGraphics library //
// Copyright (c) 2002-2009, FlexGraphics software. //
// //
// Path procedures and functions //
// //
/////////////////////////////////////////////////////////
unit FlexPath;
{$I FlexDefs.inc}
interface
uses
Windows, Classes, FlexUtils;
type
TPointType = ( ptNode, ptEndNode, ptEndNodeClose, ptControl );
TPointArray = packed array of TPoint;
TPointTypeArray = packed array of TPointType;
TSelectedArray = packed array of boolean;
TRectArray = packed array of TRect;
TPathEditFunc = ( pfOffset, {pfDelete, }pfJoin, pfBreak, pfClose,
pfToLine, pfToCurve );
TPathEditFuncs = set of TPathEditFunc;
PPathEditParams = ^TPathEditParams;
TPathEditParams = record
{$IFNDEF FG_C10}
case TPathEditFunc of
pfOffset: (
{$ENDIF}
Offset: TPoint;
MoveControls: boolean;
{$IFNDEF FG_C10}
);
{$ENDIF}
end;
PNearestPoint = ^TNearestPoint;
TNearestPoint = record
Point: TPoint;
Index0: integer;
Index1: integer;
MinIndex: integer;
MinSqrDist: single;
CurvePos: single;
IsNewMin: boolean;
end;
PPathFigureInfo = ^TPathFigureInfo;
TPathFigureInfo = record
FirstNode: integer;
LastNode: integer;
LastPoint: integer;
IsClosed: boolean;
IsCurve: boolean;
end;
TPathFigureInfos = array of TPathFigureInfo;
PPathInfo = ^TPathInfo;
TPathInfo = record
PointCount: integer;
IsCurve: boolean;
Figures: TPathFigureInfos;
end;
TRerouteMode = (
rmAlways,
rmAsNeeded,
rmNever
);
PRerouteParams = ^TRerouteParams;
TRerouteParams = record
RangeA: TRect;
RangeB: TRect;
Mode: TRerouteMode;
Ortogonal: boolean;
LinkMinGap: integer;
SelfLink: boolean;
LinkPointA: TPoint;
LinkPointB: TPoint;
end;
function CalcPath(const Points: TPointArray; const Types: TPointTypeArray;
var Range: TRect; Info: PPathInfo = Nil): boolean;
function CreatePath(DC: HDC; const Points: TPointArray;
const Types: TPointTypeArray; UseClosed, UseNotClosed: boolean;
var Complete: boolean; OriginalBezier: boolean = false;
Info: PPathInfo = Nil): boolean;
function PointOnLine(const p, p0, p1: TPoint; StrokeWidth: integer;
ScanLinePoints: TList = Nil; Nearest: PNearestPoint = Nil): boolean;
function PointOnPath(const Points: TPointArray; const Types: TPointTypeArray;
const Point: TPoint; Stroked, Filled: boolean; StrokeWidth: integer = 0;
Nearest: PNearestPoint = Nil; Info: PPathInfo = Nil;
LengthPos: PSingle = Nil): boolean;
function FlattenPath(var Points: TPointArray; var Types: TPointTypeArray;
Curvature: single; Info: PPathInfo = Nil): boolean;
function ConnectorReroute(var Points: TPointArray;
var PointTypes: TPointTypeArray; const Params: TRerouteParams): boolean;
function PathLength(const Points: TPointArray; const Types: TPointTypeArray;
Info: PPathInfo = Nil): single;
function PathLengthPos(const Points: TPointArray; const Types: TPointTypeArray;
PathPos: single; Nearest: PNearestPoint; Info: PPathInfo = Nil): boolean;
function FindNearestPathSegment(const Points: TPointArray;
const Types: TPointTypeArray; const Point: TPoint;
var FirstIndex, NextIndex: integer; Nearest: PNearestPoint = Nil;
Info: PPathInfo = Nil; ForInsert: boolean = true): boolean;
function InsertPathPoint(var Points: TPointArray; var Types: TPointTypeArray;
FirstIndex, NextIndex: integer; const Point: TPoint;
StickThreshold: integer = 0; Info: PPathInfo = Nil): integer;
function InsertNearestPoint(var Points: TPointArray;
var Types: TPointTypeArray; const Point: TPoint;
StickThreshold: integer = 0; Info: PPathInfo = Nil): integer;
function GetEditPathCaps(const Points: TPointArray;
const Types: TPointTypeArray; const Selected: TSelectedArray): TPathEditFuncs;
function EditPath(var Points: TPointArray; var Types: TPointTypeArray;
const Selected: TSelectedArray; Func: TPathEditFunc;
Params: PPathEditParams = Nil): boolean; overload;
function EditPath(var Points: TPointArray; var Types: TPointTypeArray;
const Indexes: array of integer; Func: TPathEditFunc;
Params: PPathEditParams = Nil): boolean; overload;
procedure GetPathInfo(const Points: TPointArray; const Types: TPointTypeArray;
var Info: TPathInfo);
function GetFigureIndex(const Info: TPathInfo; PointIndex: integer): integer;
function ChangePathCount(var Points: TPointArray; var Types: TPointTypeArray;
Index, Delta: integer): boolean;
implementation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -