SYSL-Pixels is a pixel-art focused screen scaling module for Love2d.
SYSL-Pixel will modify the following global Love2D Settings if apply_global_scaling_changes
is enabled.
love.graphics.setDefaultFilter("nearest", "nearest", 1)
love.graphics.setLineStyle("rough")
This will force all graphics added after SYSL-Pixel (Pixel) is loaded to use nearest scaling, and all shapes to use the rough line style.
- allow_window_resize
- Default: false
- Allows the user to resize the window from the system window manager. Disabled by default due to issues with some Linux window managers. Reccomened to test with people before using.
- apply_global_scaling_changes
- Default: true
- See the Important Information above.
- pixel_perfect_fullscreen
- Default: false
- Forces scaling, even when in full-screen view to be interger scaled. Defaults to off to avoid black borders all around the game content instead of just to the sides or above/below.
- m.current_cursor
- Default: 1
- The graphical cursor to use, if you are using the operation system (OS) cursor, set it to 0.
- m.show_system_cursor_startup
- Default: false
- Show or Hide the OS Cursor on game load.
Path to Image (String) | -X Offset (Int) | -Y Offset (Int) |
---|---|---|
Example | From | Module |
'assets/cursor1.png' | 0 | 0 |
'assets/cursor2.png' | -8 | -8 |
'assets/cursor3.png' | -16 | -6 |
conf.lua requirements
function love.conf(t)
--Snip
t.window.width = 320 -- Base Width that we scale up.
t.window.height = 180 -- Base Height that we scale up.
t.window.resizable = false -- Controled though allow_window_resize, set false in conf.
t.window.minwidth = 320 -- Should match Width
t.window.minheight = 180 -- Should match Height
--Snip
end
Loading the Module
-- Assumes you store your modules under a folder called lib, update path as required.
gscreen = require('lib.sysl.pixel')
gscreen.load(4) -- Draw at 4x Size.
In love.draw()
function love.draw()
gscreen.start()
-- EVERYTHING DRAWN BELOW IS SCALED.
love.graphics.rectangle("fill", 1,1,1,1) -- Things drawn will scale.
-- EVERYTHING DRAWN ABOVE IS SCALED.
gscreen.stop()
-- Things drawn here will *not* scale.
end
In love.update()
function love.update(dt)
-- Update Pixel
gscreen.update(dt)
end
Set the game scale to the window.width/window.height * your scale. Used to resize the window.
Toggles between full-screen and windowed mode. When returning from full-screen, it will return to the largest possible full-screen window.
Toggles the OS Cursor on and off.
True/False, enable/disable the system cursor.
Set the graphical cursor to one of your cursors defined in the cursor table.
Returns the number of cursors in the cursor table.
Check to see if the pixel mouse is in an area. Default mouse area is 1x1, see module if you need to make changes.
Push a shader to Pixel's shader stack to apply to the screen.
Remove the last shader added to the shader stack.
Clear all shaders applied to the screen.
Count the number of shaders applied to the screen.
Do this function after shaders are applied. Useful for drawing a frame, or other information after the shader.
Clear the function that was set by you in the function above.
Capture the current screen, store it as a image for use later. Does not last past the game closing
Erase all captures.
Remove a capture that you took.
Check if a capture exists.
Draw a capture, checks to see if it exists first. Follows the format of love.graphics.draw() for arguments.
When attaching the camera, you'll have to pass along the scale information.
camera:attach(0, 0, love.graphics.getWidth() / gscreen.scale, love.graphics.getHeight() / gscreen.scale, "noclip")
gscreen.stop(hx, hy, hr, hsx, hsy)
allows you to modify the canvas and adjust the scale. The arguements are as follows:
- X Postion
- Y Postion
- Rotation
- Scale X
- Scale Y