Fix star rendering

This commit is contained in:
Starbeamrainbowlabs 2017-01-02 15:22:56 +00:00
parent e804d9cd02
commit b5b0de4fba
2 changed files with 7 additions and 6 deletions

11
Star.js
View File

@ -9,10 +9,11 @@ class Star
this.canvas = inCanvas; this.canvas = inCanvas;
this.position = inPosition; this.position = inPosition;
this.points = 5; this.rotation = 0;
this.pointCount = 5;
this.size = inSize; this.size = inSize;
this.innerRingSize = this.size * 0.6; this.innerRingSize = this.size * 0.5;
this.colour = "white"; this.colour = "white";
@ -27,7 +28,7 @@ class Star
*/ */
get pointStep() get pointStep()
{ {
return (Math.PI * 2) / (this.points * 2); return (Math.PI * 2) / (this.pointCount * 2);
} }
recalculatePoints() recalculatePoints()
@ -37,8 +38,8 @@ class Star
{ {
let currentSize = i % 2 == 0 ? this.size : this.innerRingSize; let currentSize = i % 2 == 0 ? this.size : this.innerRingSize;
this.points.push(new Vector( this.points.push(new Vector(
currentSize * Math.cos(Math.PI * 2 * (n / this.points * 2) + this.rotation - Math.PI / 2), currentSize * Math.cos(Math.PI * 2 * (n / (Math.PI * 2)) + this.rotation - Math.PI / 2),
currentSize * Math.sin(Math.PI * 2 * (n / this.points * 2) + this.rotation - Math.PI / 2) currentSize * Math.sin(Math.PI * 2 * (n / (Math.PI * 2)) + this.rotation - Math.PI / 2)
)); ));
} }
} }

View File

@ -33,7 +33,7 @@ class StarlightRenderer
random(0, this.canvas.width), random(0, this.canvas.width),
random(0, this.canvas.height) random(0, this.canvas.height)
), ),
random(0, 10) random(2, 10)
)); ));
} }
} }