Page 1 of 1

easy way to render pixelart with PIX.lua

Posted: Thu Aug 29, 2019 2:08 pm
by jeana
this is a library for full window pixel art style games
PIX.lua has 3 modes to display the screen and includes some convenient helper functions.

you set the minimum width and height the screen pixels should be and PIX.lua will create the most optimal screen size

library is available on GitHub: https://github.com/jeanahelver/PIX.lua

modes:
  • "floor", tries most optimal amount of pixels for the aspect ratio, pixels will all be equal size
  • "stretch", stretches the pixels to fill the screen, pixels could be different size
  • number, fixed amount the pixels will scale
helper functions:
  • PIX.newImage( fileName )
  • PIX.mouse.getPosition()
  • PIX.mouse.getX()
  • PIX.mouse.getX()
useful variables are PIX.width and PIX.height they will give you the current screen size

see sample main.lua for implementation details
PIX.love
(2.49 KiB) Downloaded 405 times

Re: easy way to render pixelart with PIX.lua

Posted: Fri Aug 30, 2019 8:07 pm
by D0NM
Yo! Cool library.
I was going to use many ifthenS for the same result.

update: I've checked your sources. Well, it is not our case.
I use "push" library and it has all the stretching modes, including the pixel-perfect one.

Re: easy way to render pixelart with PIX.lua

Posted: Sat Aug 31, 2019 10:46 am
by jeana
what do you mean, not your case?

Re: easy way to render pixelart with PIX.lua

Posted: Sat Aug 31, 2019 11:12 am
by jeana
the push library you linked to seems weird.
PIX supports windowed, resized window and full screen as love.resize triggers for those switches.
PIX always uses a canvas and can be layered however you want mixed with none pixelart graphics.
PIX has 2 pixelperfect modes indexed and "floor" and can be swapped at runtime if needed for user preferences
highdpi also works on PIX

in addition PIX has helper functions to restore love2D functionality like mouse support and newImage to have crisp pixel graphics. PIX should also support mobile already.

PIX solution to overscan is to have extra pixel to not create a border, if you want a border consider using maid64 wich this library is inspired by

Re: easy way to render pixelart with PIX.lua

Posted: Mon Sep 28, 2020 8:35 pm
by solaris
I know you're probably not checking this account anymore, but I'm trying to use your library and I'm having a bit of an issue. For a tutorial I'm following, you center the player character by dividing the height and width of the window by 2 and using that as your draw coordinates. I tried to use the PIX.width and PIX.height attributes you mentioned in this post, but I get the error "attempt to perform arithmetic on field 'width' (a nil value)". It obviously shouldn't be a nil value, but I don't know what's going wrong. Please advise.

Re: easy way to render pixelart with PIX.lua

Posted: Tue Sep 29, 2020 8:03 pm
by pgimeno
solaris wrote: Mon Sep 28, 2020 8:35 pm I know you're probably not checking this account anymore, but I'm trying to use your library and I'm having a bit of an issue. For a tutorial I'm following, you center the player character by dividing the height and width of the window by 2 and using that as your draw coordinates. I tried to use the PIX.width and PIX.height attributes you mentioned in this post, but I get the error "attempt to perform arithmetic on field 'width' (a nil value)". It obviously shouldn't be a nil value, but I don't know what's going wrong. Please advise.
I'm not the original author, but after a quick look at the source, I noticed that PIX is returned by the module, and not defined as a global, which made me wonder how you are requiring the library. You should be using it like this:

Code: Select all

local PIX = require 'PIX'
and not like this:

Code: Select all

require 'PIX'