Closed TodePond closed 2 years ago
A little update: I'm prototyping a rewrite for this in my advent of code repo. eg: https://github.com/l2wilson94/AdventOfTode/blob/main/2021/day03a/show.js
I've called it "show" instead of "stage" as a working title just so it doesn't clash names. I'll change it back to "stage" afterwards probably.
https://github.com/l2wilson94/AdventOfTode/blob/main/2021/day06b/show.js
So far so good. Maybe show
is a better name than stage
? You start it by doing Show.start()
. The problem with show
is that it's not clear if show
is a verb or noun. So maybe not actually.
It creates a fullscreen canvas that has its own tick function, and automatically resizes and stuff.
You can specify various options.
const show = Show.start({interval: 1000 / 60, overload: 2, scale: 0.95, paused: false})
const {canvas, context} = show
show.tick = () => {
// your update and draw code goes here
}
overload: runs more than one tick per interval. scale: multiplies the size of the canvas. paused: whether the stage starts paused or not (toggle with the spacebar) interval: time between ticks
I've continued to work on this in my Genuary repo: https://github.com/l2wilson94/Genuary
I have now brought over the show library to MagicPond, and I'm continuing to work on it there. I've switched from setInterval
back to requestAnimationFrame
as chrome seems to be working better with it again (on my devices at least).
I've continued working on the rehaul in incubation! Here it is currently: https://github.com/TodePond/NewPond/blob/main/GameOfLiving/show.js
It's still called show
instead of stage
just so the name doesn't clash while I'm working on it. But I will change it to stage
when it moves into the habitat library!
This is how you use it:
const show = Show.start()
show.update = () => {
// ...
}
Previously, you had to make sure you ran it after the page fully loaded. But you don't anymore :) It will now automatically wait for the page to load and get started when it's ready now.
I'm writing up some draft documentation for it: https://todepond.gitbook.io/habitat/libraries/show
Hurry up and merge this into Habitat!! Latest version? https://github.com/TodePond/PaintPond/blob/main/show.js
Finally done!
Stage does too much in some ways. eg: I don't want it to have its own tick/draw/update functions! However, it does too little in other ways. eg: It doesn't auto-resize, and it doesn't have background colour, or overflow settings, or margin. It should be rewritten so that it focuses more on its HTML and less on its javascript.