malison icon indicating copy to clipboard operation
malison copied to clipboard

Feature: postprocessing the contents of Display

Open filiph opened this issue 6 years ago • 2 comments

I notice that Terminals don't make the Display public (and Display itself doesn't provide a way to read from the current frame). This would be useful for my scenario, where I want to post-process the image on the screen.

Example use cases:

  • I want to draw a box around an enemy. I can just overwrite what's there, but it would look better if I make the colors in the box lighter but keep the contents.
  • I want to create a tutorial "layer" that darkens everything on the screen except for a single area, without changing code of the UI that I'm highlighting.
  • I want to draw a panel over the map, but I want it to be "see through". The background of each pixel of the panel should correspond to the color on the underlying map.
  • I want to add post-processing effects. Scrambles, glitches, blur.

I plan to do this anyway, and I was going to just create a custom CanvasTerminal in my own repo. I wonder a) whether this is something that's already supported somehow and I just don't see it, b) if it makes sense to make a PR to this package instead of making my own thing.

filiph avatar Feb 26 '19 21:02 filiph

There are a couple of ways you can handle this, I think:

  1. Have multiple canvas elements on top of each other with the top ones semi-transparent.

  2. Have malison render to an offscreen canvas, and then draw that onto your own canvas where you do other post-processing.

munificent avatar Mar 01 '19 22:03 munificent

Right.

To be a bit more clear: I meant "ASCII post-processing". For example, a glitch means that, at some point during an animation, a whole one line of the output is offset by 6 characters to the right, wrapping around. A highlight means that I take the current Glyph at some position, and replace it with the same one, only with a little lighter background.

If I understand your suggestions correctly, I think 2) doesn't help, and 1) might be overkill (both in performance and code complexity).

I propose this because it seems like a common use case, but of course I have no idea. My N equals 1. It's trivial for me to make a custom version of one of the provided Terminals that makes _display public, so no big deal.

filiph avatar Mar 03 '19 03:03 filiph