Fabric.js - Bad image quality

前端 未结 1 1089
广开言路
广开言路 2021-01-26 05:58

This is an svg image loaded onto the canvas. As you can tell, it looks very much like a raster image. To give a little more context, the light blue box is 1000px by 400px.

<
相关标签:
1条回答
  • 2021-01-26 06:19

    So the problem is that fabric.js checks the tag for a width and height to initialize the new fabric canvas to, and if you don't include it in the tag, it won't render the canvas properly. To fix it, you can use

    canvas.setHeight(document.getElementById("your_canvas_id").style.height);
    canvas.requestRenderAll();
    

    and likewise for the width.

    Fabric.js changes my canvas size to 300x150 after initialization is another resource for this question.

    0 讨论(0)
提交回复
热议问题