• 大小: 103KB
    文件类型: .js
    金币: 2
    下载: 1 次
    发布日期: 2021-05-13
  • 语言: Html/CSS
  • 标签: canvg  

资源简介

首先需要获取svg标签以及内容: var svgHtml = svgContainer.innerHTML(); 将svg转成canvas需要用到google的一个插件canvg 接下来就是调用该插件的canvg(canvasId,svgHtml)方法来转成canvas,这个方法第一个参数就是canvas标签的id,第二个自然就是svg标签内容了,就这样,svg转成了canvas 然后就是将canvas转成图片了,这个更加简单了 var imgSrc = document.getElementById(canvasId).toDataUrl("image/png");//这其实是将canvas转成了图片, Use method as shown in the: http://blog.sina.com.cn/s/blog_025270e90101p6vs.html you need to first obtain SVG tag and content: var svgHtml = svgContainer. InnerHTML (); The SVG into canvas need to use the Google a canvg followed by calling the plugin canvg (canvasId svgHtml) method to convert to canvas, this method first parameter is the id tag, the second nature is SVG tag content, and thus, SVG is converted to the canvas and then the canvas into images, the more simple the var imgSrc = document. The getElementById (canvasId). ToDataUrl (& quot; image/png") ; / / this is the canvas into the image,.

资源截图

代码片段和文件信息

评论

共有 条评论

相关资源