mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Clean up Path.RegularPolygon constructor.
This commit is contained in:
parent
eebe7e2731
commit
9496ac70bd
1 changed files with 2 additions and 1 deletions
|
@ -109,8 +109,9 @@ Path.inject({ statics: new function() {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
var three = !(numSides % 3);
|
var three = !(numSides % 3);
|
||||||
var vector = new Point(0, three ? -radius : radius);
|
var vector = new Point(0, three ? -radius : radius);
|
||||||
|
var offset = three ? -1 : 0.5;
|
||||||
for(var i = 0; i < numSides; i++) {
|
for(var i = 0; i < numSides; i++) {
|
||||||
var angle = (360 / numSides) * (i + (three ? -1 : 0.5));
|
var angle = (360 / numSides) * (i + offset);
|
||||||
path.add(center.add(vector.rotate(angle)));
|
path.add(center.add(vector.rotate(angle)));
|
||||||
}
|
}
|
||||||
path.closed = true;
|
path.closed = true;
|
||||||
|
|
Loading…
Reference in a new issue