Nineslice unexpected result

Hi guys,

I'm trying to use Nineslice to create a very simple sizable window.
I defined this image as the Nineslice. The red center is the part defined as the center slice in the code.

dialogue-window-slice

Here's the code where I define the Nineslice and draw the window:

local DialogueWindowSlice = gfx.nineSlice.new('assets/dialogue-window-slice.png', 4, 4, 3, 3)
DialogueWindowSlice:drawInRect((10), (10), 250, 42) -- Draws window

here's what I get:

I was expecting to get this:

I don't understand the one pixel space between the bottom center slices.

So trying to debug I defined the center slice as one pixel less wide, like this:
local DialogueWindowSlice = gfx.nineSlice.new('assets/dialogue-window-slice.png', 4, 4, 2, 3)

This gives me the result I want. I should be happy about it but I don't understand the logic of it.
Can someone exlain?
Thanks

Stephan

Could it be something to do with the fact your image is taller than it is wide?

You could debug directly in CoreLibs/nineslice

Thanks, Matt. Boy I'm an idiot...Coordinates of the inner slice start at 0,0, not 1,1... :man_facepalming:t2:
So with correct coordinates, it works :slight_smile:

1 Like