Skip to content

Commit b5a1c79

Browse files
committed
improvig sharpness
1 parent b1ac369 commit b5a1c79

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
margin: 0px;
1616
overflow: hidden;
1717
}
18-
canvas {
19-
width: 100vw;
20-
height: 100vh;
18+
canvas {
2119
border: 0px;
2220
position: absolute;
2321
top:0px;

src/Editor.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,16 @@ export class Editor {
9696
this._ctx = canvas.getContext('2d')!; //TODO:handle error
9797
this._ctx.font = Theme.config.fontSize+'px '+Theme.config.fontFamily;
9898

99-
this.canvasAspect = this.canvas.width / this.canvas.height;
99+
const dpr = window.devicePixelRatio || 1;
100+
101+
this.canvas.width = window.innerWidth * dpr;
102+
this.canvas.height = window.innerHeight * dpr;
103+
104+
// Set CSS size (for display)
105+
this.canvas.style.width = `${window.innerWidth}px`;
106+
this.canvas.style.height = `${window.innerHeight}px`;
107+
108+
this.canvasAspect = this.canvas.height / this.canvas.width;
100109
this.reset();
101110

102111
window.addEventListener("resize", this.onResize.bind(this));

0 commit comments

Comments
 (0)