【发布时间】:2020-10-12 20:08:50
【问题描述】:
我创建了一个小画布 js 脚本并在形状上绘制轮廓这是脚本
context.beginPath();
context.moveTo(coordinates[0].x, coordinates[0].y);
for (let index = 1; index < coordinates.length; index++) {
context.lineTo(coordinates[index].x, coordinates[index].y);
}
context.lineWidth = 2;
context.strokeStyle = "red";
context.fillStyle = "rgba(255, 0, 0, 0.3)";
context.fill()
context.closePath();
context.stroke();
但我无法获得其形状的宽度和高度,实际上我想显示和线条作为工具提示供用户参考。
我在这里附上图片,您可以在 Dice 顶部看到黑线(我在 Photoshop 中为您做参考)。我想展示那条线。 我是菜鸟,如果有人可以帮助我提供很棒的示例代码。
【问题讨论】:
标签: javascript html5-canvas fabricjs