main = {
const margin = 2;
const stars = [];
const numberOfStars = 200;
const leftBound = -two.width / 2 + margin;
const rightBound = two.width / 2 - margin;
const topBound = -two.height / 2 + margin;
const bottomBound = two.height / 2 - margin;
for (let i = 0; i < numberOfStars; i++) {
stars.push(
two.makeCircle(
getRandomArbitrary(leftBound, rightBound),
getRandomArbitrary(topBound, bottomBound),
getRandomArbitrary(1.5, 3.3)
)
);
}
stars.forEach(star => {
star.fill = "ivory";
star.stroke = "slateblue";
star.linewidth = 2;
star.speed = getRandomArbitrary(0.5, 3.3);
});
const group = two.makeGroup(...stars);
group.translation.set(two.width / 2, two.height / 2);
two.bind("update", frameCount => {
stars.forEach(star => {
star.translation.x -= star.speed;
// Wrap around right
if (star.translation.x > rightBound)
star.translation.x = leftBound;
// Wrap around left
if (star.translation.x < leftBound)
star.translation.x = rightBound;
});
})
.play();
return "done..."
}