- TPoint = record
- X,Y: Double;
- end;
- TBezier3O = record
- CPnts: array[0..3] of TPoint;
- procedure SplitByParam(Param: Double; var Seg1, Seg2: TBezier3O);
- end;
- procedure TBezier3O.SplitByParam(Param: Double; var Seg1, Seg2: TBezier3O);
- var
- Pt: TPoint;
- function CalcDivide(const Pt1, Pt2: TPoint): TPoint;
- begin
- Result := (1 - Param) * Pt1 + Param * Pt2;
- end;
- begin
- Seg1.CPnts[0] := CPnts[0];
- Seg2.CPnts[3] := CPnts[3];
- Seg1.CPnts[1] := CalcDivide(CPnts[0], CPnts[1]);
- Pt := CalcDivide(CPnts[1], CPnts[2]);
- Seg2.CPnts[2] := CalcDivide(CPnts[2], CPnts[3]);
- Seg1.CPnts[2] := CalcDivide(Seg1.CPnts[1], Pt);
- Seg2.CPnts[1] := CalcDivide(Pt, Seg2.CPnts[2]);
- Seg1.CPnts[3] := CalcDivide(Seg1.CPnts[2], Seg2.CPnts[1]);
- Seg2.CPnts[0] := Seg1.CPnts[3];
- end;
- //该片段来自于http://www.codesnippet.cn/detail/1507201614879.html
来源: http://www.codesnippet.cn/detail/1507201614879.html