mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Precalculate side points again for better performance.
This commit is contained in:
parent
fb005ee63a
commit
76c0f7dd12
1 changed files with 6 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
|||
this.numSegment = Math.floor(r / 3 + 2);
|
||||
this.boundOffset = [];
|
||||
this.boundOffsetBuff = [];
|
||||
this.sidePoints = [];
|
||||
this.path = new Path({
|
||||
fillColor: {
|
||||
hue: Math.random() * 360,
|
||||
|
@ -29,6 +30,10 @@
|
|||
this.boundOffset.push(this.radius);
|
||||
this.boundOffsetBuff.push(this.radius);
|
||||
this.path.add(new Point());
|
||||
this.sidePoints.push(new Point({
|
||||
angle: 360 / this.numSegment * i,
|
||||
length: 1
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,10 +108,7 @@
|
|||
}
|
||||
|
||||
Ball.prototype.getSidePoint = function(index) {
|
||||
return this.point + {
|
||||
angle: 360 / this.numSegment * index,
|
||||
length: this.boundOffset[index]
|
||||
};
|
||||
return this.point + this.sidePoints[index] * this.boundOffset[index];
|
||||
}
|
||||
|
||||
Ball.prototype.updateBounds = function() {
|
||||
|
|
Loading…
Reference in a new issue