NOTE: This is an API-breaking update.
-
Rewrote the library to use the
__index
metamethod with a class table. See upgrade guide for a list of changed functions. -
Slice defs now support columns and rows with zero width and/or height, thus allowing for configurations like 3x1 bars.
-
Added
Slice:setTileEnabled()
to allow toggling individual slice tiles. -
Removed the
hollow
argument in drawing functions. (Made redundant bySlice:setTileEnabled()
.) -
Renamed
quadSlice.new9Slice()
toquadSlice.newSlice()
. -
Added
quadSlice.draw_functions
, a table of alternative draw functions which omit certain tiles. -
Slice tables now keep track of mirroring state in the fields
slice.mirror_h
andslice.mirror_v
. They should not be modified directly, but they are safe to read.
-
Change any instances of
quadSlice.new9Slice()
toquadSlice.newSlice()
. -
Calls to these functions need to be updated. A [!] indicates that the arguments list has changed beyond just using implicit
self
.-
quadSlice.getDrawParams()
: changed toSlice:getDrawParams()
-
quadSlice.draw()
: changed toSlice:draw()
[!] -
quadSlice.drawFromParams()
: changed toSlice:drawFromParams()
[!] -
quadSlice.batchAdd()
: changed toSlice:batchAdd()
[!] -
quadSlice.batchAddFromParams()
: changed toSlice:batchAddFromParams()
[!] -
quadSlice.batchSet()
: changed toSlice:batchSet()
[!] -
quadSlice.batchSetFromParams()
: changed toSlice:batchSetFromParams()
[!] -
quadSlice.getTextureUV()
: changed toSlice:getTextureUV()
-
quadSlice.getStretchedVertices()
: changed toSlice:getStretchedVertices()
-
quadSlice.setQuadMirroring()
: changed toSlice:setMirroring()
-
-
Any usage of the
hollow
argument needs to be rewritten, either by usingSlice:setTileEnabled(5, false)
or overwriting the slice'sdrawFromParams
field withquadSlice.draw_functions.hollow
.
- Fixed incorrect default quad viewport assignments in
quadSlice.setQuadMirroring()
.
NOTE: This is an API-breaking update.
- Functions no longer bail out early if
w
orh
are <= 0. Instead, they enforce a minimum value of 0. You can now count on the functions which return values to always return something, even if the returned values would result in nothing visible being drawn.
Affected functions:
-
quadSlice.getDrawParams
(returns a slew of values) -
quadSlice.draw
-
quadSlice.batchAdd
(returns the index of the last sprite added to the batch) -
quadSlice.batchSet
- Any code that takes the return values of
quadSlice.getDrawParams
orquadSlice.batchAdd
no longer has to guard against receivingnil
. To simulate the old behavior, you can wrap the function call in anif
statement that checks the width and height you would be passing in:
local w1,h1, w2,h2, w3,h3, sw1,sh1, sw2,sh2, sw3,sh3
if my_width > 0 and my_height > 0 then
w1,h1, w2,h2, w3,h3, sw1,sh1, sw2,sh2, sw3,sh3 = quadSlice.getDrawParams(my_slice, my_width, my_height)
end
NOTE: This is an API-breaking update.
-
Reorganized the library to allow sharing 9slices among multiple compatible images. The use case is to help with UI skinning.
-
9slice tables no longer contain an
image
field. Instead, they store a reference width and height (fieldsiw
andih
). -
Draw functions are modified to take a separate
image
reference.
-
-
Removed
quadSlice.new9SliceMirrorH
,quadSlice.new9SliceMirrorV
, andquadSlice.new9SliceMirrorHV
. Replacing them isquadSlice.setQuadMirroring
, which can be called on any existing 9slice table, and which is reversible. -
Added assertions for object creation and mirroring. Assertions are included for draw functions, though they are commented out by default due to overhead concerns. No assertions are provided for the mesh helper functions.
-
Replace instances of
quadSlice.new9SliceMirrorH
,quadSlice.new9SliceMirrorV
, andquadSlice.new9SliceMirrorHV
withquadSlice.new9Slice
followed byquadSlice.setQuadMirroring
. -
Update arguments used in
quadSlice.new9Slice
(the first arg (image
) was removed. Now it takesiw
andih
as the last arguments, for the image's width and height, respectively). -
quadSlice.draw
: Now takes an additionalimage
variable as its first argument. -
quadSlice.drawFromParams
: Now takes animage
variable as its first argument, and the sequence of quads from a slice instead of the slice table itself. Thehollow
argument has been moved so that the results ofquadSlice.getDrawParams
can be included directly into the arguments list (in Lua, multi return values in an args list are cut off by any subsequent arguments). -
quadSlice.batchAddFromParams
: Now takes the sequence of quads from a slice instead of the slice table itself. Thehollow
argument has been moved. -
quadSlice.batchSetFromParams
: Now takes the sequence of quads from a slice instead of the slice table itself. Thehollow
argument has been moved.
-
Added mesh helpers:
quadSlice.getTextureUV()
andquadSlice.getStretchedVertices()
. Addedtest_mesh_render.lua
to test these new functions. There are so many ways to set up and draw a mesh that attempting to handle it in-library would just get in the way, so that part is left to the library user. -
Removed section of README with (probably overblown) concerns about potential seams between tiles. I personally haven't encountered seams in my own testing so far, so long as the drawing coordinates and dimensions are floored to integers. I tested drawing a single-pixel texture with nearest-neighbor filtering, at a slowly-increasing sub-pixel position, and noted that it is rounded at the halfway point between integers. I think I had this conflated with a separate issue that I experienced with SpriteBatched tilemaps. Here is the passage:
* The stretchy tiles in the mosaic are scaled with the `sx` and `sy` arguments in `love.graphics.draw`.
I haven't encountered any visible seams between tiles in my testing, but I also haven't ruled out the
possibility. (Todo: somehow test every possible size and floored scale value, up to a certain threshold,
I guess.) If you do run into seams, verify that you are drawing at a per-pixel or per-dpi-scaled-pixel
level, that you are flooring the dimensions to the pixel grid, and try making the center tiles power-of-
two sized, as floating point seems to be pretty good at storing n/po2 fractions. Linear filtering may
also help to mask the issue. Worst case: you can make the center tile 1x1 pixels in size, so that `sx`
and `sy` become `max(0, w - (w1+w3))` and `max(0, h - (h1+h3))` respectively. Anyways, I'll be back once
I've done some more testing on this.
- Started changelog. (Previous version was a beta.)