Zoomable and pannable starfield
JavaScript Vim script
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib import screenfull Sep 28, 2014
.vimrc vimrc Oct 11, 2014
LICENSE A LICENSE Sep 28, 2014
README.md fix readme list Oct 21, 2014
Star.js new file for Star class Oct 11, 2014
apple-touch-icon.png add icon Oct 5, 2014
fullscreen.js vimrc Oct 11, 2014
hashFnv32a.js new file for hashFnv32a Oct 11, 2014
index.html new file for hashFnv32a Oct 11, 2014
render.js allow brightness 1.0 Oct 13, 2014
rrcache.js Revert "remove cache" Sep 27, 2014
starfield.js new file for hashFnv32a Oct 11, 2014

README.md

To use this starfield generator in your own app, use starfield.js and its dependencies Star.js, hashFnv32a.js, and rrcache.js. starfield.js provides a function called getStars, which takes the following parameters:

  1. worldOffsetX, the x position of the upper-left corner of the current viewport in the gameworld's coordinates.
  2. worldOffsetY, the y position of the same.
  3. worldWidth, the width of the current viewport in the gameworld's coordinates.
  4. worldHeight, the height.

and returns an array of Star objects, which specify the positions of the stars in the gameworld's coordinates as well as their brightnesses, which range from 0 to 1.

The remaining files in the project handle rendering to the canvas, browser events, and fullscreen. You can leave them out if your project already handles those tasks.

Here's a write-up about how the starfield generator works:

http://mshang.ca/2014/10/20/starfield.html