Procedural Image Generation In Ga

Datetime:2016-08-23 03:01:32          Topic:          Share

I am attempting to develop a method of procedurally generating images for a game that I am making with Ga. The actual generation is not relevant here; my question is how do I turn an image on an HTML5 canvas into a Ga sprite?

By default, Ga sprites accept a link to the source name, which is normally loaded in by ga.assets.load(), either at the start of the game or when called. However, I see no easy way to instead pass, say, a dataURL or other format easily obtainable from a (hidden) canvas.

Or, alternatively, how can I develop an alternative to ga.sprite that acts exactly the same except for using my created images from a canvas instead of loading a source from disk?

Link to Ga: https://github.com/kittykatattack/ga

Ga.Sprite: https://github.com/kittykatattack/ga/blob/master/ga.js#L1461

Ga.Assets: https://github.com/kittykatattack/ga/blob/master/ga.js#L2065