0

Is it possible to do something like this

var image = new Image();
image.src = 'img.svg';
context.drawImage(image, x, y); // context is an instance of CanvasRenderingContext2D

with a SVG image? Actually this code works, but I think the image is converted to .jpg or similar, because if I try to zoom the browser page the image becomes coarse.

Clarification : The image should be re-drawn many times in the canvas context (i.e. for movements), so suggestions like "use this library" should consider this fact.

EDIT

From previous discussions, the issue seems to be due to canvas properties (canvas is not browser-zoomable) and not due to incorrect loading. Can I get and modify (eventually) this property of canvas to realize my purpose? I have to draw necessarily on canvas, no other options unfortunately.

Fabrizio Morello
  • 335
  • 1
  • 5
  • 18

1 Answers1

0

Translate rendered svg according to the wanted zoom level.

How to detect page zoom level in all modern browsers?

explains browser-zoom level detection. And you can use fabricjs for canvas manipulation (http://fabricjs.com/).

Community
  • 1
  • 1
Ali Naci Erdem
  • 435
  • 2
  • 12