Skip to content

Commit

Permalink
Fix a canvas ratio on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilf committed May 14, 2019
1 parent 2501d69 commit 52d7a23
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/components/renderers/WorldCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ export default {
mounted() {
this.canvas = this.$refs.canvas
this.ctx = this.canvas.getContext('2d')
// https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
this.ratio = window.devicePixelRatio || 1
this.ctx.scale(this.ratio, this.ratio)
this.setLoading({ renderer: false })
this.draw()
},
computed: {
...mapState(['grid', 'config']),
canvasWidth() {
return this.grid[0] && this.grid[0].length * this.config.cellSize * (this.ratio || 1)
return this.grid[0] && this.grid[0].length * this.config.cellSize
},
canvasHeight() { return this.grid.length * this.config.cellSize * (this.ratio || 1) },
canvasHeight() { return this.grid.length * this.config.cellSize },
},
watch: {
Expand Down

0 comments on commit 52d7a23

Please sign in to comment.