Skip to content

Commit c80e7c0

Browse files
committed
update: renderjs android 5
1 parent 3ae7d07 commit c80e7c0

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

pages/component/canvas/canvas.vue

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
</template>
1717

1818
<script module="animate" lang="renderjs">
19-
function Ball({
20-
x,
21-
y,
22-
vx,
23-
vy,
24-
canvasWidth,
25-
canvasHeight,
26-
ctx
27-
}) {
19+
function Ball(options) {
20+
var x = options.x
21+
var y = options.y
22+
var vx = options.vx
23+
var vy = options.vy
24+
var canvasWidth = options.canvasWidth
25+
var canvasHeight = options.canvasHeight
26+
var ctx = options.ctx
2827
this.canvasWidth = canvasWidth
2928
this.canvasHeight = canvasHeight
3029
this.ctx = ctx
@@ -76,33 +75,33 @@
7675
7776
export default {
7877
methods: {
79-
start(newVal, oldVal, owner, ins) {
80-
let canvasWidth = ins.getDataset().width,
78+
start: function(newVal, oldVal, owner, ins) {
79+
var canvasWidth = ins.getDataset().width,
8180
canvasHeight = ins.getDataset().height,
8281
canvasEle = document.querySelectorAll('.canvas>canvas')[0],
8382
ctx = canvasEle.getContext('2d'),
8483
speed = 3,
8584
ballList = [],
8685
layer = 3,
8786
ballInlayer = 20
88-
for (let i = 0; i < layer; i++) {
89-
let radius = getDistance(canvasWidth / 2, canvasHeight / 2) / layer * i
90-
for (let j = 0; j < ballInlayer; j++) {
91-
let deg = j * 2 * Math.PI / ballInlayer,
87+
for (var i = 0; i < layer; i++) {
88+
var radius = getDistance(canvasWidth / 2, canvasHeight / 2) / layer * i
89+
for (var j = 0; j < ballInlayer; j++) {
90+
var deg = j * 2 * Math.PI / ballInlayer,
9291
sin = Math.sin(deg),
9392
cos = Math.cos(deg),
9493
x = radius * cos + canvasWidth / 2,
9594
y = radius * sin + canvasHeight / 2,
9695
vx = speed * cos,
9796
vy = speed * sin
9897
ballList.push(new Ball({
99-
x,
100-
y,
101-
vx,
102-
vy,
103-
canvasWidth,
104-
canvasHeight,
105-
ctx,
98+
x: x,
99+
y: y,
100+
vx: vx,
101+
vy: vy,
102+
canvasWidth: canvasWidth,
103+
canvasHeight: canvasHeight,
104+
ctx: ctx,
106105
radius: 5
107106
}))
108107
}

0 commit comments

Comments
 (0)