TodePond / Habitat

my javascript helpers
MIT License
45 stars 5 forks source link

Stage layers #64

Closed TodePond closed 1 year ago

TodePond commented 2 years ago

Stage should have the ability to have multiple layers. Currently it's just one 2D context canvas. But it could also have additional layers of the same type. And layers could also be different modes, like HTML, webgl, svg, etc...

Default layers (which is what stage currently is):

const stage = new Stage({layers: ["2d"]})
stage.tick = (context) => {

}

Multiple 2d context layers:

const stage = new Stage({layers: ["2d", "2d"]})
stage.tick = (context1, context2) => {

}

Mixed layers:

const stage = new Stage({layers: ["html", "2d", "webgl", "svg"]})
stage.tick = (contextHtml, context2d, contextWebgl, contextSvg) => {

}

This issue is related to #61 #16

TodePond commented 2 years ago

Or alternatively: could it be possible and simpler to just make multiple stages if you need to do this?? maybe support both?

If you're making multiple layers by making multiple stages, the order of creation would affect the order of layers, which doesn't feel great. And I guess you might want to just have one stage to make sure that the layers are in sync

TodePond commented 1 year ago

Let's group up #87 and #91 in this too

TodePond commented 1 year ago

Actually I'll do those separately.

I've added an html layer now!