Javascript 纸张js';dot';路径显示在firefox中,但不显示在IE或Chrome中
使用纸上js草图中的代码,我可以看到只需单击而不移动鼠标即可绘制的点。您还可以看到该元素实际上已添加到所有3个浏览器中。然而,Chrome和IE没有显示这种元素,我一辈子都不明白为什么Javascript 纸张js';dot';路径显示在firefox中,但不显示在IE或Chrome中,javascript,html,canvas,paperjs,Javascript,Html,Canvas,Paperjs,使用纸上js草图中的代码,我可以看到只需单击而不移动鼠标即可绘制的点。您还可以看到该元素实际上已添加到所有3个浏览器中。然而,Chrome和IE没有显示这种元素,我一辈子都不明白为什么 // The minimum distance the mouse has to drag // before firing the next onMouseDrag event: tool.minDistance = 1; tool.maxDistance = 1; function onMouseDown(
// The minimum distance the mouse has to drag
// before firing the next onMouseDrag event:
tool.minDistance = 1;
tool.maxDistance = 1;
function onMouseDown(e) {
// Create a new path and give it a stroke color:
path = new Path();
path.strokeColor = 'black';
path.strokeWidth = 2;
// Add a segment to the path where
// you clicked:
path.add(e.point);
}
function onMouseDrag(e) {
var top = e.middlePoint;
var bottom = e.middlePoint;
path.add(top);
path.insert(0, bottom);
}
function onMouseUp(e) {
var pt = e.point;
path.add(pt);
path.closed = true;
console.log(path);
}
得到了尤尔格·莱尼的回复 这可能是底层渲染系统的不同,但是 只有一段的开放路径不应渲染, 我们应该在图书馆内部处理的事情 如果闭合路径定义了句柄,则应该呈现该路径,这是可以做到的 实际上是一个很小的环
我必须设置特定的行为来处理点路径。在我的例子中,我使用了圆圈。我就是这样解决的:
function onMouseUp(e) {
var pt = e.point;
if (path.segments.length < 2) {
// draw a dot
pt.y ++;
}
path.add(pt);
path.closed = true;
console.log(path);
}
mouseup(e)上的函数{
var pt=e.point;
if(path.segments.length<2){
//画一个点
pt.y++;
}
路径添加(pt);
path.closed=true;
console.log(路径);
}