Skip to content

Overlays: elegant way to add custom graphics #387

@Sporarum

Description

@Sporarum

A YouTube comment on "spacial programming without escape" was suggesting adding a sprite layer on top of the canvas, for example to allow showing the little trains moving around.
This is a proposal for a feature which would do just that, while staying in the philosophy of CellPond.

We already have a system which allows us to replace cells (and even patterns) with sprites:
The update rules!

The issue is that it is run destructively and recursively: our state will get replaced by sprites, and then the rules will apply to the sprites and not the state, ... awkward 😐

To solve this, we split the canvas in two:

  • the state canvas, where regular (state) rules are executed
  • the overlay canvas, the output of the overlay rules on the state canvas

Oh, and we also split the rules in two:

  • the state rules, what we've had so far, which mutate the state canvas
  • the overlay rules, which take a pattern on the state canvas, and map it to a pattern on the overlay canvas. In other words: draw sprites

More precisely, after every frame, one by one, each overlay rule is applied once to every cell of the state canvas, producing the overlay canvas. (If no overlay rule produced output for a cell, the corresponding cell in the state canvas is used. => no overlay rules means current behavior)

This of course absolutely kills the framerate...

But ! Since the overlay rules are local and deterministic (🤢), we can instead reuse the previous overlay canvas and only recalculate areas where the state canvas changed

By reusing the existing rule syntax, this feature would be very powerful, while having a very small UI (and hopefully development) overhead

(No generative AI was used for any part of this proposal)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions