Search code examples
canvaskonvajsreact-konva

react-konva: disable canvas element devicePixelRatio scale


I'm using react-konva

when I render a <Stage /> with width:750, it will render a <canvas /> element with width 750 * devicePixelRatio

<Stage width={750} />

will render (in iPhone 7)

<canvas width="1500" />

How do I disable this behavior ?


Solution

  • import Konva from 'konva';
    
    Konva.pixelRatio = 1;
    

    But in the case image on HDPI display (such as retina) will look blurred.