如何解决如何在使用Point绘制的路径上绘制以下图案
使用矩形进行连接很容易,因为我们使用点来绘制路径并将strokeWidth设置为矩形。 有人可以帮我们在路径上绘制以下3种图案(与strokeWidth连接仅2个点)
解决方法
Paper.js没有内置的方法,但是您可以使用矩形作为剪贴蒙版来解决此问题。
这里是sketch,展示了一个简化的解决方案,您应该能够适应您的特定用例。
const rectangle = new Path.Rectangle({
from: view.center - [300,50],to: view.center + [300,fillColor: 'orange'
});
const spaceBetweenLines = 10;
const height = rectangle.bounds.height;
const totalWidth = rectangle.bounds.width + height;
const steps = Math.ceil(totalWidth / spaceBetweenLines);
const linesGroup = new Group();
for (let i = 0; i < steps; i++) {
const x = i * spaceBetweenLines;
const line = new Path.Line({
from: [x,0],to: [x + height,height],strokeColor: 'black',strokeWidth: 2
});
linesGroup.addChild(line);
}
linesGroup.position = rectangle.position;
const clipGroup = new Group({
children: [rectangle.clone(),rectangle,linesGroup],clipped: true
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。