相关疑难解决方法(0)

对于SVG,是否有相当于canvas的toDataURL方法?

我试图加载到画布像素处理我需要一种方法像SVG图像toDataURLgetImageData对SVG

在Chrome/Safari上,我可以尝试通过图像和画布

var img = new Image()
img.onload = function(){
  ctx.drawImage(img,0,0) //this correctly draws the svg image to the canvas! however...
  var dataURL = canvas.toDataURL(); //SECURITY_ERR: DOM Exception 18
  var data = ctx.getImageData(0,0,img.width, img.height).data //also SECURITY_ERR: DOM Exception 18
  }
  img.src = "image.svg" //that is an svg file. (same domain as html file :))
Run Code Online (Sandbox Code Playgroud)

但是我遇到了安全错误.还有其他方法吗?

这是一个问题的现场演示http://clstff.appspot.com/gist/462846(你可以查看源代码)

javascript html5 svg canvas

11
推荐指数
2
解决办法
1万
查看次数

如何获得 SVG 文本的“crispEdges”?

文本以外的 SVG 形状受shape-rendering可以设置为crispEdges值的属性的影响(https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering)。这个值似乎关闭了抗锯齿。

但文本仅受text-rendering. 但是,这不提供crispEdges值(https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-rendering)。为什么?有没有另一种方法来获得非抗锯齿?

svg text antialiasing text-rendering shape-rendering

1
推荐指数
1
解决办法
1529
查看次数