Popularity
6.6
Declining
Activity
0.0
Stable
24
3
0

Monthly Downloads: 11
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Web    
Latest version: v0.0.1

sdl2-sprite alternatives and similar packages

Based on the "Web" category.
Alternatively, view sdl2-sprite alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of sdl2-sprite or a related project?

Add another 'Web' Package

README

sdl2-sprite

A Haskell library for rendering sprites and a commandline tool for previewing them

Commandline use

Create a horizontal sprite like this:

[](img/blue-fish-sprite.png)

The size of the intended result image is 220x130, so provide that:

sdl2-sprite blue-fish.png 220x130 --fps 15

This will open a window animating that sprite:

[](img/blue-fish-12fps.gif)

The animation repeats indefinitely at the desired framerate.

Using Haskell API

Use load to load in a sprite for a Renderer:

load :: MonadIO m => Renderer -> FilePath -> V2 CInt -> m Sprite

To render the sprite at a given position use render:

render :: MonadIO m => Sprite -> V2 CInt -> m ()

To advance the sprite's frame to the next frame (or loop), use animate:

animate :: Sprite -> Sprite

This is a pure function, so you can use it in a loop. See the source in app/Main.hs of this repository for an example.

How to make sprites in Inkscape

Choose the size of your intended result e.g. 220x130 and then setup the grid in Inkscape to show that size (see the Spacing X/Spacing Y fields):

[](img/inkscape-doc-properties.png)

It'll look like this, which is handy:

[](img/inkscape-grid.png)

When you want to make a new frame, use Ctrl-D to duplicate the selection and use the Transform tool to move it exactly 220 pixels to the right and hit Apply.

[](img/inkscape-transform.png)

Make sure that your document dimensions are your width x your frame count.

Finally, export your image with the right "Image size" - make sure the size is 130 so that the width scales right:

[](img/inkscape-export.png)

Now you're good to go! Hit Export.