Giter Club home page Giter Club logo

Comments (8)

TodePond avatar TodePond commented on August 15, 2024

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.

from habitat.

TodePond avatar TodePond commented on August 15, 2024

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

from habitat.

TodePond avatar TodePond commented on August 15, 2024

I've continued to work on this in my Genuary repo: https://github.com/l2wilson94/Genuary

from habitat.

TodePond avatar TodePond commented on August 15, 2024

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).

https://github.com/TodePond/Genuary

from habitat.

TodePond avatar TodePond commented on August 15, 2024

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.

from habitat.

TodePond avatar TodePond commented on August 15, 2024

I'm writing up some draft documentation for it: https://todepond.gitbook.io/habitat/libraries/show

from habitat.

TodePond avatar TodePond commented on August 15, 2024

Hurry up and merge this into Habitat!! Latest version? https://github.com/TodePond/PaintPond/blob/main/show.js

from habitat.

TodePond avatar TodePond commented on August 15, 2024

Finally done!

from habitat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.