简体   繁体   English

如何在paper.js中绘制样条线

[英]How to Draw Splines in paper.js

I'm currently working on a project to display DXF files on a paper.js canvas. 我目前正在研究一个在paper.js画布上显示DXF文件的项目。 However, when I read the spline objects in the DXF file, I am completely confused by the naming and how I should translate them into paper.js curve objects. 但是,当我读取DXF文件中的样条线对象时,我对命名以及如何将它们转换为paper.js curve对象感到完全困惑。

DXF has: degree , control points and know values DXF具有: degreecontrol pointsknow values

Paper.js has: http://paperjs.org/reference/curve/ Paper.js具有: http ://paperjs.org/reference/curve/

Here is an example of the DXF Spline data object : 这是DXF样条线数据对象的示例:

controlPoints:(15) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}],
degreeOfSplineCurve:5,
handle:"100",
knotValues:(21) [0, 0, 0, 0, 0, 0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6, 0.7, 0.7999999999999999, 0.8999999999999999, 1, 1, 1, 1, 1, 1],
layer:"0",
numberOfControlPoints:15,
numberOfFitPoints:0,
numberOfKnots:21,
planar:true,
type:"SPLINE"

Let me know if you need more information 如果您需要更多信息,请与我们联系

DXF curves are implemented as arbitrary degree Nonuniform rational B-splines (NURBS https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline ), while paper.js supports only cubic bezier curves. DXF曲线实现为任意程度的非均匀有理B样条曲线(NURBS https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline ),而paper.js仅支持三次贝塞尔曲线。 In Paper.js a segment of bezier curve is defined with a point and handleIn and handleOut vectors. 在Paper.js中,贝塞尔曲线的一段通过点和handleIn和handleOut向量定义。 See http://paperjs.org/reference/segment/ 参见http://paperjs.org/reference/segment/

NURBS is a more general representation than Bezier, so it might not be possible to present any NURBS with an exact bezier curve, but you can still find a close enough approximation of curve in DXF either using bezier curves or by using straight line segments. NURBS是比Bezier更通用的表示形式,因此可能无法显示任何具有精确Bezier曲线的NURBS,但是您仍然可以使用Bezier曲线或直线段在DXF中找到足够接近的曲线近似值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM