Code: Select all
window = NineSlice.generateFromRect(gTexture, 0,0, 196, 196)
window:set(0, 0, width, height, useMinimumWidth, useMinimumHeight)
function love.draw()
window:render()
end
If you prefer, you can pass the 9 quads directly in the constructor, it will allow any size:
Code: Select all
NineSlice(gTextures['ui'],
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()),
love.graphics.newQuad(x, y, w, h, gTextures['ui']:getDimensions()))
Code: Select all
NineSlice.generateFromTiles(texture, startX, startY, tileWidth, tileHeight, offset_Per_Tile_X, offset_Per_Tile_Y,)
Using it is very similar, the only difference is that the constructor receives 3 quads instead of 9, and it receives one additional parameter for knowing if it is the horizontal or the vertical type:
Code: Select all
ThreeSlice.generateFromTiles(texture, startX, startY, tileWidth, tileHeight, offset_Per_Tile_X, offset_Per_Tile_Y, isHorizontal)
Code: Select all
ThreeSlice.generateFromRect(texture, x, y, w, h)
Code: Select all
ThreeSlice:set(x,y, width, height, useMinimum)
Download it at: https://github.com/MrcSnm/Love2D-Nine-and-Three-Slices
Here is the comparison between original image and 9 and 3-Slices