https://github.com/codecat/p9
Yet another 9patch library for Love2D.
https://github.com/codecat/p9
Last synced: 5 months ago
JSON representation
Yet another 9patch library for Love2D.
- Host: GitHub
- URL: https://github.com/codecat/p9
- Owner: codecat
- License: mit
- Created: 2024-01-28T21:59:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-28T22:01:33.000Z (over 1 year ago)
- Last Synced: 2024-12-29T18:38:01.396Z (7 months ago)
- Language: Lua
- Size: 61.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.txt
Awesome Lists containing this project
README
# p9
Yet another 9patch library for Love2D. Similar to [patchy](https://github.com/excessive/patchy)
and [slicy](https://github.com/wqferr/slicy), but it's a lot smaller, uses a GLSL shader for
rendering, wraps the texture instead of simply stretching it, and is permissively licensed.
## Usage
```lua
local p9 = require('p9')
local patch = p9.load('frame.9.png')function love.draw()
patch:draw(10, 10, 100, 100)local x, y, w, h = p:getContentWindow()
love.graphics.setScissor(x, y, w, h)
-- Do some drawing within the content region
love.graphics.setScissor()
end
```The `draw` method also returns the same values as `getContentWindow`.
## The format
The `.9.png` format is a regular image file, except the first/last rows/columns are intended as
metadata indicators.