GifCat -- Write GIFs in LOVE.

Showcase your libraries, tools and other projects that help your fellow love users.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

GifCat -- Write GIFs in LOVE.

Post by WetDesertRock »

Hello all!

I have finally gotten around to releasing my GIF writing lib for LOVE 0.10.x, which I hope should be pretty easy to drop into your projects. One advantage this project has is that it is threaded (as much as possible), so it can save your gifs while you play with a minimal performance hit (even less if you give it a canvas rather than a screenshot).
1466962294.gif
1466962294.gif (413.36 KiB) Viewed 11098 times
Here is some code with all of the important bits cut out so you can see the basic API:

Code: Select all

-- In love.load()
gifcat.init()

-- In love.update()
gifcat.update(dt)

-- In love.quit()
gifcat.close()

-- Start recording:
curgif = gifcat.newGif(os.time()..".gif",100,100)

-- Write frame:
curgif:frame(love.graphics.newScreenshot())

-- Stop recording:
curgif:close()
https://github.com/WetDesertRock/GifCat
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: GifCat -- Write GIFs in LOVE.

Post by zorg »

Neat lib!

love.graphics.newScreenshot will impede performance no matter what, if called every frame; then again, this is good for "non-realtime" gif-renders, if one serializes all inputs and the game is deterministic; they can render replays to gifs to watch. (quality/filesize ratio might not be the best for that though) :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Trebgarta
Prole
Posts: 33
Joined: Mon May 23, 2016 5:21 pm

Re: GifCat -- Write GIFs in LOVE.

Post by Trebgarta »

What about rendering to a canvas, and using that in both the screen and gifcat?
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: GifCat -- Write GIFs in LOVE.

Post by zorg »

Trebgarta wrote:What about rendering to a canvas, and using that in both the screen and gifcat?
That may work better, didn't test it myself though, so can't say for certain.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock »

Trebgarta wrote:What about rendering to a canvas, and using that in both the screen and gifcat?
Yes, it will. :frame will work with ImageData, Image, or Canvas. So honestly .newScreenshot is probably the slowest (but easiest to demonstrate).
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: GifCat -- Write GIFs in LOVE.

Post by rmcode »

I wanted to implement the library into LoGiVi, but no matter what I do the .so file can't be found:

Code: Select all

lib/gifcat/gifcat.lua:188: module 'gifcatlib' not found:
	no field package.preload['gifcatlib']
	no 'gifcatlib' in LOVE game directories.
	no file 'gifcatlib.so' in LOVE paths.
	no file './gifcatlib.lua'
	no file '/usr/local/share/luajit-2.0.3/gifcatlib.lua'
	no file '/usr/local/share/lua/5.1/gifcatlib.lua'
	no file '/usr/local/share/lua/5.1/gifcatlib/init.lua'
	no file './gifcatlib.so'
	no file '/usr/local/lib/lua/5.1/gifcatlib.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
I tried:

Code: Select all

local GIFLIB = "lib.gifcat.gifcatlib"
local GIFLIB = "lib/gifcat/gifcatlib"
local GIFLIB = "lib.gifcat"
local GIFLIB = "lib/gifcat"
... and a few more
I also moved both files to the same folder as my main, but even there it doesn't seem to find them :S

I just pushed the feature branch to the repo, in case you want to have a direct look at how things are organized.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock »

rmcode: I just pushed a fix. Please try it out, note that your GIFLIB should now look like: "lib/gifcat/gifcatlib.so"
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: GifCat -- Write GIFs in LOVE.

Post by rmcode »

Cool! It works now :)

Is there a way to specify the delay between frames?
Image
I tried it with frame:setFPS but that didn't seem to have the desired effect.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: GifCat -- Write GIFs in LOVE.

Post by WetDesertRock »

Without seeing your code I'll tell you this. It defaults it FPS to the current FPS when you are making a gif. However that FPS will most likely go down due to making a new gif. So I would suggest trying to pass a dt argument to the :frame function. Setting the FPS just interprets how fast the frames you are sending it are. So saying you are giving it 60 fps where in reality you are giving it 30 will result in a gif 2x as fast. The dt argument in :frame will make it a variable framerate, thus reacting to how fast the game is actually going.
User avatar
PixelPiledriver
Prole
Posts: 6
Joined: Mon Apr 07, 2014 7:25 pm
Contact:

Re: GifCat -- Write GIFs in LOVE.

Post by PixelPiledriver »

Yo, this looks awesome.
Would love to use it but I'm having some trouble.
Can't seem to build the library.
After a lot of different tries this is what I get.

Image

Not sure what to do.
Can you help me? :death:
Post Reply

Who is online

Users browsing this forum: No registered users and 50 guests