From 50a282012b33d59fa65ba6611cf1ebbc0bb6e045 Mon Sep 17 00:00:00 2001 From: xty Date: Wed, 19 Jun 2024 13:05:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcanvas=20iOS=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/canvas/canvas.uvue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/component/canvas/canvas.uvue b/pages/component/canvas/canvas.uvue index 5ee9db4c..08700a02 100644 --- a/pages/component/canvas/canvas.uvue +++ b/pages/component/canvas/canvas.uvue @@ -85,23 +85,23 @@ let canvasWidth = this.ctx.canvas.width, canvasHeight = this.ctx.canvas.height for (let i = 0; i < this.layer; i++) { - let radius = getDistance(canvasWidth / 2, canvasHeight / 2) / layer * i + let radius = this.getDistance(canvasWidth / 2, canvasHeight / 2) / this.layer * i for (let j = 0; j < this.ballInlayer; j++) { - let deg = j * 2 * Math.PI / ballInlayer, + let deg = j * 2 * Math.PI / this.ballInlayer, sin = Math.sin(deg), cos = Math.cos(deg), x = radius * cos + canvasWidth / 2, y = radius * sin + canvasHeight / 2, vx = this.speed * cos, vy = this.speed * sin - ballList.push(new Ball(x, y, vx, vy, ctx, devicePixelRatio)) + this.ballList.push(new Ball(x, y, vx, vy, this.ctx, devicePixelRatio)) } } } private animate(ballList: Array) { this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height ) - ballList.forEach(function(item) { + this.ballList.forEach(function(item) { item.move() item.draw() }) @@ -111,8 +111,8 @@ start(){ //Todo.. requestAnimationFrame clearInterval(this.interval) - interval = setInterval(function() { - animate(ballList) + this.interval = setInterval(()=> { + this.animate(this.ballList) }, 17) } stop(){ -- GitLab