转opentype为paper.js,贝塞尔曲线问题
transfer opentype to paper.js, bézier curve problem
我正在尝试将字体从 opentype 传输到 paper.js 路径对象。我正在使用 opentype.js 从信中获取要点,然后我尝试从这些要点中创建一条新的纸张路径。
听起来很简单,但不知何故我无法计算出这条曲线。我正在尝试通过 paper.js 的示例和参考来了解这是如何完成的。但我找不到它。
从 opentype.js 我得到这样的路径:
{type: "C", x: 56.3, x1: 58.4, x2: 56.3, y: 111.9, y1: 90, y2: 97.80000000000001}
(这里x/y是基本点,x1/y1和x2/y2是它的相关点处理程序。)
现在我试着把它放到 paper.js 路径中:
var segments = [];
segments.push(new Segment(
new Point(119,111.30000000000001)
));
segments.push(new Segment(
new Point(119,284.1)
));
segments.push(new Segment(
new Point(139.7,302.7),
new Point(119,300),
new Point(125.89999999999999,302.7)
));
segments.push(new Segment(
new Point(161,284.1),
new Point(150.2,302.7),
new Point(161,300.3)
));
var path = new Path(segments);
path.strokeColor = "black"
所有非曲线路径都是正确的。但是显示的处理程序没有逻辑位置...
有人有什么想法吗?
Segment.handleIn
和Segment.handleOut
是相对于锚点的坐标。确保为手柄提供相对坐标,而不是绝对坐标。
一个简单的解决方案是使用 OpenType.js 将字体转换为 SVG 宽度 Path.toSVG(decimalPlaces)
, then import it in paper.js with importSVG(svg[, options])
。
我正在尝试将字体从 opentype 传输到 paper.js 路径对象。我正在使用 opentype.js 从信中获取要点,然后我尝试从这些要点中创建一条新的纸张路径。
听起来很简单,但不知何故我无法计算出这条曲线。我正在尝试通过 paper.js 的示例和参考来了解这是如何完成的。但我找不到它。
从 opentype.js 我得到这样的路径:
{type: "C", x: 56.3, x1: 58.4, x2: 56.3, y: 111.9, y1: 90, y2: 97.80000000000001}
(这里x/y是基本点,x1/y1和x2/y2是它的相关点处理程序。)
现在我试着把它放到 paper.js 路径中:
var segments = [];
segments.push(new Segment(
new Point(119,111.30000000000001)
));
segments.push(new Segment(
new Point(119,284.1)
));
segments.push(new Segment(
new Point(139.7,302.7),
new Point(119,300),
new Point(125.89999999999999,302.7)
));
segments.push(new Segment(
new Point(161,284.1),
new Point(150.2,302.7),
new Point(161,300.3)
));
var path = new Path(segments);
path.strokeColor = "black"
所有非曲线路径都是正确的。但是显示的处理程序没有逻辑位置...
有人有什么想法吗?
Segment.handleIn
和Segment.handleOut
是相对于锚点的坐标。确保为手柄提供相对坐标,而不是绝对坐标。
一个简单的解决方案是使用 OpenType.js 将字体转换为 SVG 宽度 Path.toSVG(decimalPlaces)
, then import it in paper.js with importSVG(svg[, options])
。