Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拉斐尔的线径宽度是2px,而不是1px_Javascript_Raphael - Fatal编程技术网

Javascript 拉斐尔的线径宽度是2px,而不是1px

Javascript 拉斐尔的线径宽度是2px,而不是1px,javascript,raphael,Javascript,Raphael,好的,到目前为止,我有以下代码: var fillerLine = { 'color': 'white', 'cursor': 'pointer' } var line1 = paper1.path("M2 2"); line1.attr(f

好的,到目前为止,我有以下代码:

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));
但这条线一点也不尖锐。它看起来像2px宽,而不是像普通线一样的1px宽。如何将其重置为1px并将线条颜色设置为白色

我怎样才能得到1px线路


编辑:在raphaeljs中,Firefoxwidth似乎存在这个问题,如果可以使用renderfix()修复,我会尝试

我必须使用2.5而不是3,然后它就可以工作了

line1.attr({'stroke-width':'1'});

而是将其添加到fillerline中,以实现可重用的方法……

这个问题已经讨论过了:

这个链接告诉你整数坐标有什么问题,为什么+0.5是固定边缘模糊(有漂亮的图片!!):

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

SVG_Area.setAttribute("viewBox", "0.5 0.5 " + width + " " + height); SVG_Area.setAttribute(“视图框”、“0.5 0.5”+宽度+”+高度); 或通过包装:

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)); 函数fiXY(x){return parseInt(x)+0.5;} var rect=document.createElements(“http://www.w3.org/2000/svg“,“rect”); rect.setAttribute(“x”,fiXY(x)); rect.setAttribute(“y”,fiXY(y)); 或通过:

SVG_Area.setAttribute("shape-rendering", "crispEdges"); SVG_Area.setAttribute(“形状渲染”、“边缘”);
对SVG图像中的所有形状都有什么影响…

有人知道我应该把这段代码放在哪里吗,所以它就是工作文件。renderfix()?我在开始和结束时都试过,但没有任何结果。它仍然模糊且不清晰。如果像paper1.renderfix()一样使用它,则renderfix无法工作;我必须使用2.5而不是3,然后它才能工作,但这很奇怪。在单个SVG节点上设置“shape rendering”属性可以解决我的问题,而不会影响其他可以从抗锯齿中获益的元素。