Skip to content

Instantly share code, notes, and snippets.

@lispnik

lispnik/animate.lisp

Created Apr 13, 2016
Embed
What would you like to do?
(ql:quickload "sdl2")
(ql:quickload "sdl2-image")
(defun run ()
(sdl2:with-init (:everything)
(sdl2:with-window (win :flags '(:shown))
(sdl2:with-renderer (renderer win :flags '(:renderer-accelerated))
(let* ((surface-frames 23)
(surface (sdl2-image:load-image "out.png"))
(texture (sdl2:create-texture-from-surface renderer surface))
(frame-width (/ (sdl2:texture-width texture) surface-frames))
(frame-height (sdl2:texture-height texture))
(frame 0))
(sdl2:with-event-loop (:method :poll)
(:keyup
(:keysym keysym)
(when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape)
(sdl2:push-event :quit)))
(:idle
()
(let ((source-rect (sdl2:make-rect (* frame frame-width) 0 frame-width frame-height)))
(sdl2:render-copy renderer texture :source-rect source-rect)
(setf frame (mod (1+ frame) surface-frames))
(sdl2:delay 30))
(sdl2:render-present renderer))
(:quit () t)))))))
convert -layers dispose ../Downloads/giphy.gif giphy.gif
montage giphy.gif -tile x1 -geometry '1x1+0+0<' out.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment