Skip to content
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

Attempt to add support for 9-slice #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JohnEmhoff
Copy link

Hello! I'm trying to add support for nuklear's 9-slice rendering to love-nuklear. If you aren't familiar, it's a way to specify a texture for use as a button / window / whatever in a manner that avoids scaling artifacts at the corners and edges.

I've done a (quick-and-dirty for now) modification of nk_love_style_push_item to additionally accept 9-slice args ({image, quad, top, left, bottom, right}) in addition to its current support for colors and images. Mechanically things are working, but it renders very oddly (see below). There are enough unknowns that I'm having a hard time debugging:

  • The lua API is fairly new to me (but I think I have this right)
  • nuklear itself is new to me and the docs aren't great, although after studying the source and the 9-slice PR in its repo I think I have the arguments correct (see the comment in skin.lua)
  • I could be misusing some of nuklear-love's abstractions

I've modified the "skin" example as a test -- I'm trying to render the normal button using a 9-slice. What I get is below; note the odd tiling effect in the button rendering.

Anywhoo, I'm going to continue to debug but I thought I'd throw this up in case more experienced eyes can see the thing that I'm doing wrong.

Screenshot from 2023-09-05 18-37-02

Renders oddly; clearly there's something I'm missing either in the lua,
love2d, or nuklear API.
@JohnEmhoff
Copy link
Author

Ah, the issue seems to be that when drawing a sub-image love-nuklear does not use the sub-rectangle fields inside nk_image and instead calls getViewport on the source image. That's why it's always drawing the entire texture for each of the patches -- it does not know to draw a sub-sub image. I'm sure there's a simple solution that I'll stumble on eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant