Skip to content

Instantly share code, notes, and snippets.

@lispnik
Created April 13, 2016 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lispnik/157b734cb2c51a9659948b16c2eb6d16 to your computer and use it in GitHub Desktop.
Save lispnik/157b734cb2c51a9659948b16c2eb6d16 to your computer and use it in GitHub Desktop.
(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