SVG网格渲染Chrome,Firefox,IE -错误的线对齐-模糊的线
SVG Grid Rendering Chrome,Firefox,IE - Wrong Line Alignment - Blurred Lines
为了创建SVG,我在SVG中绘制了几条线。问题是它在Chrome和Firefox中看起来不一样。
Chrome:最后一条线未绘制Firefox:第一行未绘制
顺便说一句:ie版本看起来模糊,但这不是主要问题。
那么现在是谁呢?
我做错了什么。
给你一些背景信息:我通常动态地从JavaScript绘制这个网格。我是否必须编写丑陋的hack来处理这些不同的SVG浏览器呈现行为?(我不想使用任何库,但普通的JavScript)
请参阅此codependency。输入输出:http://codepen.io/mjost/full/kuaFH
下面是代码:<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" id="phoenix10_5" viewBox="0 0 960 768">
<defs>
<style type="text/css">
<![CDATA[
svg
{
shape-rendering: crispEdges;
stroke-linecap: butt;
}
text
{
alignment-baseline: auto;
}
]]>
</style>
</defs>
<rect x="0" y="0" width="960" height="768" rx="0" ry="0" fill="rgb(255, 255, 255)"/>
<g>
<rect x="69" y="44" width="746" height="187" rx="0" ry="0" fill="rgb(255, 255, 255)"/>
<g>
<svg x="69" y="44" width="746" height="187" viewBox="0 0 746 187">
<rect x="0" y="0" width="746" height="187" style="fill: #FFFFFF"/>
<g>
<line stroke="#000000" stroke-width="1" x1="0" y1="0" x2="746" y2="0"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="18" x2="746" y2="18"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="37" x2="746" y2="37"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="56" x2="746" y2="56"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="74" x2="746" y2="74"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="93" x2="746" y2="93"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="112" x2="746" y2="112"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="130" x2="746" y2="130"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="149" x2="746" y2="149"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="168" x2="746" y2="168"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="187" x2="746" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="0" y1="0" x2="0" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="74" y1="0" x2="74" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="149" y1="0" x2="149" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="223" y1="0" x2="223" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="298" y1="0" x2="298" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="373" y1="0" x2="373" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="447" y1="0" x2="447" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="522" y1="0" x2="522" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="596" y1="0" x2="596" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="671" y1="0" x2="671" y2="187"/>
<line stroke="#000000" stroke-width="1" x1="746" y1="0" x2="746" y2="187"/>
</g>
</svg>
</g>
</g>
</svg>
你的viewBox是"0 0 960 768"所以这就是你能看到的。当你画
<line stroke="#000000" stroke-width="1" x1="0" y1="0" x2="746" y2="0"/>
你说你想要一个从y=-0.5到y=0.5的1像素宽的描边,因为每边有1/2的描边。然而,由于viewBox,从-0.5到0的所有笔画都被剪切了,所以你要求看到一个清晰的边缘笔画1/2像素宽,这对于UA来说是不可能的。有时UA会在viewBox内显示它,你会看到它,有时它会在viewBox外绘制它,然后你就看不到了。
如果你想使用crispEdges笔画,最好以0.5个单位绘制,例如
<line stroke="#000000" stroke-width="1" x1="0.5" y1="0.5" x2="746" y2="0.5"/>
这里有更详细的解释
相关文章:
- 模糊事件的Javascript测试
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- 当移除子元素时,我得到一个错误;模糊”;事件
- 聚焦和模糊错误元素触发的事件
- 未捕获的引用错误: ..在模糊
- 模糊显示文本框的错误消息
- 错误:无法读取属性'模糊'的未定义
- 模糊事件不起作用会产生错误
- Asp. js中的模糊错误.Net 2.0 With Javascript
- JQuery -元素不可聚焦的错误/如何强制模糊
- SVG网格渲染Chrome,Firefox,IE -错误的线对齐-模糊的线
- 在SVG上点击IE/Edge导致错误-类型错误:对象没有't支持属性或方法'模糊'
- 使用ng模糊的输入验证(如果输入错误,请更改背景颜色)