Skip to content

Commit

Permalink
Merge pull request #20 from v-kiniv/fix-hidpi-canvas
Browse files Browse the repository at this point in the history
fix(View): Make canvas DPI aware
  • Loading branch information
jourdain authored Jul 21, 2021
2 parents 010dd4e + c01b6d9 commit 0ae7ecb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ export default class View extends Component {
onResize() {
const container = this.containerRef.current;
if (container) {
const devicePixelRatio = window.devicePixelRatio || 1;
const { width, height } = container.getBoundingClientRect();
this.openglRenderWindow.setSize(
Math.max(width, 10),
Math.max(height, 10)
);
const w = Math.floor(width * devicePixelRatio);
const h = Math.floor(height * devicePixelRatio);
this.openglRenderWindow.setSize(Math.max(w, 10), Math.max(h, 10));
this.renderWindow.render();
}
}
Expand Down

0 comments on commit 0ae7ecb

Please sign in to comment.