A love lib for generating a temporary sprite sheet.
Use it anywhere you would usually reference an asset. You don't need to wait to have visual assets to start spinning out some code.
- width required
number/tableIf a number: the width of a single frame of the spritesheet. If a table: it should contain key/value pairs for the rest of the parameters. - height required
numberThe height of a single frame of the spritesheet. - columns
numberThe number of horizontal frames the spirtesheet should have. - rows
numberThe number of vertical frames the spritesheet should have. - sprintstring
stringA formatted string with named parameters. See: Named Parameters with Formatting Codes for more information. Provided parameters are:columnThe current horizontal column number of the spritesheet that the image is in.rowThe current vertical row number of the spritesheet that the image is in.widthThe width of the individual frame of the spritesheet.heightThe height of the individual frame of the spritesheet.
- sprintvars
table/stringIf it is a table: named elements that will be merged with the above provided vars. This can be used to insert custom elements into the sprintstring. If it is a string: it will replace the default "placeholder" line in the example string, this can be used to simply insert your info before the frame data. - fontcolor
colortableThe color of the font to use when drawing the text. - fillcolor
colortableThe color to make the placeholder background.
-- drop it in your project
placeholdme = require 'placeholdme'
function love.load()
local imageSource = placeholdme(100,50,3,4)
-- instead of 'image/path/here.png', just put a call to placeholdme
placeholder = love.graphics.newImage(imageSource)
end
function love.draw()
-- draw it like you would anything else
love.graphics.draw(placeholder, 0, 0)
endOutput:
-- drop it in your project
placeholdme = require 'placeholdme'
local parameters = {
width = 100,
height = 200,
columns = 3,
fillcolor = {58, 179, 54, 255}
}
-- set up what we're going to
local values = {
'Enemy\nidle',
'Enemy\nwalk-up',
'Enemy\nattack',
}
for _, pose in pairs(values) do
-- don't provide parameters we're not going to use
-- see: http://www.lua.org/pil/5.3.html
local idata = placeholdme{
width = 100,
height = 200,
columns = 3,
fillcolor = {58, 179, 54, 255},
sprintvars = pose
}
-- save the images to disk to prevent generating them again
idata:encode(pose:gsub("\n", "_")..'.png')
endOutput: imgur link



