-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nine slice API #47
Nine slice API #47
Conversation
I feel this is a good starting point for a nine slice bitmap implementation. A note on file naming, I think we should stick with |
My thought on supporting dynamic drawing was that we could add The implementation itself would need to do more bit twiddling to get the alignment working. This could be implemented in two ways:
Can do! |
Updated with the requested changes. I also converted a few |
Looks good! Last things:
|
Bit late to the party maybe, but here are my 2 cents:
|
Can’t believe I missed renaming that other file. I’ll get that changed. Good catch. Nim definitely has dead code elimination, so unused procs and structs won’t show up if they aren’t referenced. The documentation question is a good one. There are a few options:
@samdze, do you have a preference? Are you game to setting up a GitHub hosted doc site? If so, I can cut an issue to coordinate. I’ve got a GitHub workflow that can handle auto publishing using Nims doc generator. |
For docs, I preemptively opened #48 so you can see what it would look like. Feel free to close that PR if you would rather take another path. |
Nice work! Thanks! |
This adds an API for rendering a nine slice. The API, in general, looks like this:
A few things worth noting:
How the precalculation works
In terms of the precalculation that is done, imagine you've got a nine slice with the following pixels set:
The precalculator will split the image into 9 parts:
Because the playdate draws images in rows of
uint8
s, the precalculator will fill in the left and middle sections of the rows so that everything is at an even 8 bits. So it becomes:This means that as we're drawing, we don't have to do any bit twiddling to draw the left and middle columns. We can just copy the full
uint8
all at once for the majority of the row.Once we reach the right column, though, we can't do that. We don't know how wide the image is, so we have to do some render-time calculations to make that work.