Skip to content

Commit 0ae7ecb

Browse files
authored
Merge pull request #20 from v-kiniv/fix-hidpi-canvas
fix(View): Make canvas DPI aware
2 parents 010dd4e + c01b6d9 commit 0ae7ecb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/View.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ export default class View extends Component {
323323
onResize() {
324324
const container = this.containerRef.current;
325325
if (container) {
326+
const devicePixelRatio = window.devicePixelRatio || 1;
326327
const { width, height } = container.getBoundingClientRect();
327-
this.openglRenderWindow.setSize(
328-
Math.max(width, 10),
329-
Math.max(height, 10)
330-
);
328+
const w = Math.floor(width * devicePixelRatio);
329+
const h = Math.floor(height * devicePixelRatio);
330+
this.openglRenderWindow.setSize(Math.max(w, 10), Math.max(h, 10));
331331
this.renderWindow.render();
332332
}
333333
}

0 commit comments

Comments
 (0)