提交 7a612fb7 编写于 作者: X xty

修复canvas编译警告

上级 5e1fb1dc
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<script> <script>
function hidpi(canvas : UniCanvasElement) { function hidpi(canvas : UniCanvasElement) {
const context = canvas.getContext("2d")!; const context = canvas.getContext("2d")!;
const dpr = uni.getWindowInfo().pixelRatio ?? 1; const dpr = uni.getWindowInfo().pixelRatio;
canvas.width = canvas.offsetWidth * dpr; canvas.width = canvas.offsetWidth * dpr;
canvas.height = canvas.offsetHeight * dpr; canvas.height = canvas.offsetHeight * dpr;
context.scale(dpr, dpr); context.scale(dpr, dpr);
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<script> <script>
function hidpi(canvas : UniCanvasElement) { function hidpi(canvas : UniCanvasElement) {
const context = canvas.getContext("2d")!; const context = canvas.getContext("2d")!;
const dpr = uni.getWindowInfo().pixelRatio ?? 1; const dpr = uni.getWindowInfo().pixelRatio;
canvas.width = canvas.offsetWidth * dpr; canvas.width = canvas.offsetWidth * dpr;
canvas.height = canvas.offsetHeight * dpr; canvas.height = canvas.offsetHeight * dpr;
context.scale(dpr, dpr); context.scale(dpr, dpr);
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
const renderingContext = context.getContext('2d')!; const renderingContext = context.getContext('2d')!;
const canvas = renderingContext.canvas; const canvas = renderingContext.canvas;
const dpr = uni.getWindowInfo().pixelRatio ?? 1; const dpr = uni.getWindowInfo().pixelRatio;
canvas.width = canvas.offsetWidth * dpr canvas.width = canvas.offsetWidth * dpr
canvas.height = canvas.offsetHeight * dpr canvas.height = canvas.offsetHeight * dpr
renderingContext.scale(dpr, dpr) renderingContext.scale(dpr, dpr)
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
this.renderingContext = context.getContext('2d')!; this.renderingContext = context.getContext('2d')!;
const canvas = this.renderingContext!.canvas; const canvas = this.renderingContext!.canvas;
const dpr = uni.getWindowInfo().pixelRatio ?? 1; const dpr = uni.getWindowInfo().pixelRatio;
canvas.width = canvas.offsetWidth * dpr canvas.width = canvas.offsetWidth * dpr
canvas.height = canvas.offsetHeight * dpr canvas.height = canvas.offsetHeight * dpr
this.renderingContext!.scale(dpr, dpr) this.renderingContext!.scale(dpr, dpr)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册