javascript - Paper js 'dot' 路径在 Firefox 中显示,但在 IE 或 Chrome 中不显示

标签 javascript html canvas paperjs

使用论文js sketch中的代码here我只需单击即可看到绘制的点,而无需移动鼠标。您还可以看到该元素实际上已添加到所有 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(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);
}

最佳答案

收到 Jürg Lehni 的回复

It's probably a difference of the underlying rendering system, but an open path with only one segment should simply not be rendered, something that we should handle in the library internally.

A closed path should be rendered if it defines handles, as that can actually be a tiny little loop.

我必须设置特定的行为来处理点路径。就我而言,我使用了圆圈。

关于javascript - Paper js 'dot' 路径在 Firefox 中显示,但在 IE 或 Chrome 中不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33024633/

相关文章:

javascript - 使用 jQuery 更改组中单选按钮的值属性

javascript - 将 jChartFX 与 SharePoint 2013 结合使用时出错

javascript - jQuery:斑马条纹表

jQuery 添加类和动画

java - 如何在 spring mvc 中用 thymeleaf 填充一个简单的表

html - 使用与文本不同的背景颜色绘制 HTML5 Canvas?

java - 如何获得 Canvas 的确切位置(Java)

javascript - 使用 javascript(无库)更新 tbody 的 html : possible?

html - 左栏汉堡包菜单 Bootstrap

javascript - 强制 html canvas 仅在某些绘图的特定区域上绘制