javascript - Raphael 中线条路径的宽度是 2px 而不是 1px

标签 javascript raphael

好的,到目前为止我有这段代码:

var fillerLine = {
                            'color': 'white',
                            'cursor': 'pointer'
                        }

                        var line1 = paper1.path("M2 2");
                        line1.attr(fillerLine);
                        var anim = Raphael.animation({path: "M2 2L100 2"}, 500);
                        line1.animate(anim.delay(3000));

但是 line1 一点也不尖锐。它看起来像 2px 宽而不是 1px 作为正常线。如何将其重置为 1px 并将线条的颜色设置为白色?

如何得到 1px 的线?

编辑:似乎是 Firefox 的这个问题 Line width in raphaeljs width-in-raphaeljs 我会尝试使用 renderfix() 修复它;

最佳答案

这个问题已经讨论过了:

此链接带您指出整数坐标出了什么问题,以及为什么 +0.5 是固定边缘模糊(有漂亮的图片!!):

您可以通过以下方式避免 +0.5:

SVG_Area.setAttribute("viewBox", "0.5 0.5 " + width + " " + height);

或包装器:

function fiXY(x) { return parseInt(x) + 0.5; }

var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rect.setAttribute("x", fiXY(x));
rect.setAttribute("y", fiXY(y));

或通过:

SVG_Area.setAttribute("shape-rendering", "crispEdges");

对 SVG 图像中所有形状的影响....

关于javascript - Raphael 中线条路径的宽度是 2px 而不是 1px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11629666/

相关文章:

javascript - javascript new Date() 构造函数对相同不同格式字符串的不明确行为

javascript - 为什么我不能将其他 css 元素应用到我的自定义 css 类?

javascript - 使用 View 框时在 Raphael.js 中拖放一组路径

javascript - Raphael ID 在 iPad 上与在浏览器上不同

javascript - 使用 Raphael JS 拖放 SVG

javascript - 隐藏中心的同时保留开始和结束的子字符串函数

c# - 如何在我的 MVC 应用程序中打开文本文件?

javascript - 如何在另一个函数中调用reduce函数

javascript - 拉斐尔的拖放和翻译问题

javascript - 向 Raphaël.js 图像元素添加淡入效果的问题