【发布时间】:2018-11-19 09:54:19
【问题描述】:
我有多个要渲染的 SVG 形状。
我目前正在为每个 svg 分别创建一个 Image 对象,这会导致许多不必要的 HTTP 请求。
const imageEl = new Image();
imageEl.src = image.src;
// And then
ctx.drawImage(this.image, this.x, this.y, this.width, this.height);
我想使用一个包含我所有 SVG 的 sprite 文件并将它们绘制到画布上,就像在 HTML 中使用 <use xlink:href="SOME_URL"></use> 一样
我该怎么做?
【问题讨论】:
标签: javascript svg canvas