Move sprite function to sprite.js

Talked about in #695