Really only the fact that it doesn't allocate, so it could be written as a global variable/constant and used with the same API as Image
they both inherit from a Drawable
protocol.
/// A namespace for built in images.
public enum Images {
public enum Interface {
/// The pico-8 style cursor embedded for debugging purposes.
public static let cursor: Image = [
[.clear, .black, .clear, .clear, .clear, .clear],
[.black, .white, .black, .clear, .clear, .clear],
[.black, .white, .white, .black, .clear, .clear],
[.black, .white, .white, .white, .black, .clear],
[.black, .white, .white, .white, .white, .black],
[.black, .white, .white, .black, .black, .clear],
[.clear, .black, .black, .white, .black, .clear]
]
}
}
I have some simple images inlined in code so I can use them for debugging, in this case I wanted to test drawing a cursor to the screen in wasm before implementing a system to embed actual image files in the wasm binary. This could be an InlineImage
instead.
Or since this works in Embedded Swift, maybe it would be useful there. I can think of some games I could implement to run in wasm with an InlineImage
as a fixed size drawing target that wouldn't require linking in the memory allocator, making the binary even smaller
Like this embedded swift pong, the size of the "screen" is known at compile time