Use Case
I've been working on a game that currently uses the drawing APIs to procedurally generate most elements, UI components, etc. I have two related use cases in mind:
- To improve performance, I'd like to transition some of those animated UI elements to
imagetable
s which include a cell per frame. - To add more atmosphere, I'd like to craft a background image to render behind my game elements by starting from a screenshot of the generated level, while also "baking in" some of the procedurally drawn elements which don't move.
The built-in screenshot and record buttons in the simulator already provide some pretty great utility for extracting the image data to help support those use cases. Here are a few requests for ways to make it even better:
- Pure color option. The as-seen-on-device grayscale images are great by default, but it would be convenient to have the option to output both images and videos with true black/white pixels for reuse as game assets. I realize the thresholding makes this not strictly necessary, but it would add some consistency when editing assets.
- Transparency. I'd love to be able to capture both screenshots and videos with transparency preserved. That is, the output image would be transparent anywhere I haven't explicitly drawn white or black pixels into the screen buffer. That would be especially handy for those animated UI elements, which otherwise need to be adjusted frame by frame.
- Cropping. The various animated UI elements aren't full screen, of course. It would be convenient to configure a crop for them in advance.
An image editor can reasonably do items 1 and 3, although native support would be slick. Item 2 requires a fair amount of frame-by frame pixel labor to accomplish. Are there already facilities I'm missing that afford these capabilities?
A few ideas
These ideas could make sense either at the screen level, or at the sprite level. These might be terrible ideas or totally impractical, but a few possible approaches I can think of include:
- A top-level preference in the simulator for the capture mode, which toggles between the default and a mode which preserves transparency and uses pure color.
- A facility similar in appearance to collision rect highlighting which allows dragging to select a crop region for any subsequent captures.
- New simulator-only APIs for
playdate.graphics.sprite
which enable capturing its drawn content, which could be called fromupdate
ordraw
, e.g.sprite:captureImage(filename)
sprite:startCaptureRecording(filename)
sprite:stopCaptureRecording()
- New simulator-only APIs for
playdate.graphics.image
to save their content to disk, e.g.-
image:save(filename)
(akin tosound.sample:save(filename)
)
-
- Or perhaps even a way to dynamically pre-render into an imagetable?
imagetable:setImage
gets part of the way there already. Maybe all that's needed is a way to then export that, e.g.imagetable:saveAsSequence(filenameSansTableSuffix)
imagetable:saveAsMatrix(filenameSansTableSuffix, [cellsWide])