A Free 8-Bit Sprite Generator. Create 256 variants from a single template .PNG

Overview

Triangles

BitSprite

A Free 8-Bit Sprite Generator.

What?

BitSprite is a program that creates variants of an image across total sprite sheet of the resultant images. By taking the index of the variant as it lays on the sprite sheet, Bitsprite uses that index number to activate or deactivate certain designated pixels based on its representation as a binary number. After downloading the package, or the .exe, the user can use the command prompt to run the program, using flags to control the results. The user has several options to designate colors, as well as 'unfold' the template to create symmetrical images.

Install

Download the package and place it in an easy to reach place. You will need to run all commands from inside the Bitsprite directory.

Flowers?

Using BitSprite

Creating a Template

To create a template, open your favorite image editor.  In this example, we'll just use the venerable Microsoft Paint, but any editor should be fine, so long as you encode the template as a png.  Templates have a special color coding to determine how the pixels are read and later written.

Pixel Legend

Pixel Template Color
Bit Black (RGB 0,0,0)
Accent Green (RGB 0,255,0)
Fill Blue (RGB 0,0,255)
Outline Red (RGB 255,0,0)
Background White (RGB 255,255,255)

Any deviation from these specific colors on a template will result in the offending color being treated as background. So if your output is entirely transparent, check that your pixels are correctly colored on the template.

'Bit' pixels are how our generator creates the variety between images, as these pixels switch between being active and displaying a set color, or inactive and becoming an outline pixel. While BitSprite expects 8 bit pixels in a template, you can do less, which results in fewer unique combinations on the final sprite sheet. You can also include more than 8 bit pixels in a template, in which case, the bit pattern will repeat, with 9th pixel getting the value of the first assigned pixel, and so on until it repeats again.

Accent and fill pixels are static, allowing the user to set pixels that are always active.  

Outline pixels are generated any time an active (colored) pixel is bordered by a background pixel, and by default are colored black. They can also function as another static pixel if explicitly included in the template, though they will not generate borders around themselves like bit/accent/fill pixels do.

Background pixels are default transparent.  

Back To The Template

Let's look at what a compliant template may look like:

MS Paint Window with an open template file

This example shows a template image at 800% zoom, with each square of color representing one pixel. Notice that there are 5 colors used in the 'face' image, all of which correspond to our control scheme. 

If we run 

    BitSprite.exe -template=face

we can check the GenerationDirectory and find FaceSpriteSheet.png:

greyscale face sprite sheet

It's a little small.  The transparent background also does no favors for visibility with this basic gray scale. Instead let's return a large image with a better background.We'll set the background to magenta and we'll scale the image by 4, so that our original pixel is written as 4 pixels in a square.

    BitSprite.exe -template=face -background=#ff00ff -upscale=4

FaceSpriteSheet.png should now look like this:

greyscale face sprite sheet with magenta background, 4 times scale

We can now see that our bit pixels are counting up in binary based on their position when read.  Our fill and accent pixels remain the same through each iteration, with distinct colors.  The activated bit pixels also influence the drawing of our outlines, though the red 'smile' from our template stays static.  

Now this is all well and good, but why did you use half a face?

Well, a nifty feature of BitSprite is the ability to reflect our templates while writing the new images.

if we decide to run:

    BitSprite.exe -template=face -background=#ff00ff -upscale=4 -fold=odd

greyscale face sprite sheet with magenta background, 4 times scale unfolded

Now we have a symmetrical image, and also one that allows your imagination to wander a little bit. Is it the many hairstyles of Tommy Pickles? Maybe it is a happy slime, expanding and contracting across the sprite sheet? You decide!

We can also reflect our images across the bottom of the image as well. Let's check out the triangle template provided:

    Bitsprite.exe -template=triangle -upscale=4

greyscale triangle sprite sheet, 4 times scale

Now if we want to fold it vertically:

    BitSprite.exe -template=triangle -upscale=4 -vertfold=odd

greyscale triangle sprite sheet, 4 times scale unfolded vertically

Notice the vertfold uses the same inputs as fold, and even better, we can combine the two:

    BitSprite.exe -template=triangle -upscale=4 -vertfold=even -fold=even

greyscale triangle sprite sheet, 4 times scale unfolded vertically and horizontally

It's still a little bland

Fine, BitSprite also supports some cool ways to control colors.

    BitSprite.exe -template=face -upscale=4 -fold=odd -color=#9a3300 -accent=#3d671d -fill=#F1C27D

colored in face sprite sheet 4 times scale, unfolded

With color, we create a passable face.  But we're not done yet, we can also do a blend of tones across the entire sheet, for any of those values.

    BitSprite.exe -template=face -upscale=4 -fold=odd -color=#9a3300:#4f1a00 -accent=#3d671d:#497665 -fill=#F1C27D:#503335

blended tones face sprite sheet 4 times scale, unfolded

Now we can represent our little buddy across a variety of tones.  Finally, as an Easter Egg, we have the original rainbow gradient I used when I first developed the program. While it lacks granular control, I think it looks neat.

    BitSprite.exe -template=face -upscale=4 -fold=odd -legacy=true

Legacy gradient face sprite sheet 4 times scale, unfolded

It's a candy colored nightmare to be sure, but it can be useful when you're unsure what color you might want to base your sprites on. This is created by running across two gradients at .5 lumia on the YCbCr color scheme, which stands in for our activated bit pixels, while fills and accents are lighter and darker lumias of the same gradient.

Robot heads

Flag Commands

After creating the .PNG template and placing it in the Templates folder, the user can then use the command prompt, to create a sprite sheet, based on the following flags:

-template (required)    Expected Values: Any string that doesn't anger your OS.

Template looks in the templates folder for a file named after the provided string, and if successful opens up the template .PNG for parsing.

-fold   Expected Values: odd = odd, o; even = even, e. (Not case sensitive) 

Fold controls whether the template should be reflected across the rightmost bounds.  User has the option to choose to fold even, and write the last column twice or fold odd and have the last column of the template only represented once in the output.  

-vertfold   Expected Values: odd = odd, o; even = even, e. (Not case sensitive)

Vertfold controls whether the template should be reflected across the bottom bounds.  User has the option to choose to fold even, and write the last row twice or fold odd and have the last row of the template only represented once in the output.  

-color   Expected Values: Hex or Hex:Hex (#FFFFFF or #FFFFFF:#000000).

Color designates the color of activated bit pixels, can be expressed as both a single Hex value or two Hex values with a ':' in between.Passing two Hex values will result in 'blended' shades between the designated colors across the images of the sprite sheet. 

-accent   Expected Values: Hex or Hex:Hex (#FFFFFF or #FFFFFF:#000000).

Accent designates the color of accent pixels, can be expressed as both a single Hex value or two Hex values with a ':' in between.Passing two Hex values will result in 'blended' shades between the designated colors across the images of the sprite sheet. 

-fill    Expected Values: Hex or Hex:Hex (#FFFFFF or #FFFFFF:#000000).

Fill designates the color of fill pixels, can be expressed as both a single Hex value or two Hex values with a ':' in between. Passing two Hex values will result in 'blended' shades between the designated colors across the images of the sprite sheet. 

-background    Expected Values: Hex or Hex:Hex (IE #FFFFFF, #FFFFFF:#000000).

Background designates the color of background pixels, can be expressed as both a single Hex value or two Hex values with a ':' in between. Passing two Hex values will result in 'blended' shades between the designated colors across the images of the sprite sheet. 

-outcolor    Expected Values: Hex or Hex:Hex (IE #FFFFFF,#FFFFFF:#000000).

Outcolor designates the color of outlines and deactivated bit pixels, can be expressed as both a single Hex value or two Hex values with a ':' in between. Passing two Hex values will result in 'blended' shades between the designated colors across the images of the sprite sheet. 

-outline    Expected Values: True = true, t; false = false, f. (Not case sensitive, accepts all Golang Bool values.)

Outline can be used to toggle whether BitSprite draws outlines around bit, accent and fill pixels.  Does not effect explicitly designated outline pixels.

-upscale    Expected Values:  Positive integer (integers < 1 will automatically be set at 1).

Upscale controls the scale of the output images.  Keep in mind that 1 pixel -> 4 -> 9 as you scale in this program.

-sheetwidth    Expected Values: Positive factor integer of 256.

Sheetwidth controls the number of columns in an output Sprite Sheet.  Must be a factor of 256, otherwise will default to 16 columns.  

-outname    Expected Values: Any string that doesn't anger your OS.

Outname controls the naming of the output directory and sprite sheet 

-individuals    Expected Values: True = true, t; false = false, f. (Not case sensitive, accepts all Golang Bool values.

Indivduals controls whether BitSprite creates a directory with individual .png files of all the images that constitute the spritesheet. Defaults to false.

-legacy    Expected Values: True = true, t; false = false, f. (Not case sensitive, accepts all Golang Bool values.)

Legacy uses the original YCbCr gradient for coloring sprites. 

Dog with hat

Why?

BitSprite is a quick and dirty approach to 'art', which allows the user to generate large amounts of assets in a short time. These assets are then stored for easy usage as both a sprite sheet and individual images.  In the spirit of garage bands that overcame lack of talent with a surplus of noise, so too does BitSprite argue that quantity has a quality all its own.  Beyond the fact that it has potential for small sprites, icons, etc. there are also more interesting ways you can composite multiple sprites together to create even more complex and interesting shapes.

FAQs

All my pixels are coming out black, why do?

This is usually a problem with passing bad color values to any of the color flags. Please ensure it is a valid Hex Code and begins with #.

When I produce a new sprite sheet, it's the wrong shape/completely transparent!

This problem usually indicates that you are not using the correct colors in the template file. Ensure that they are as indicated in the pixel legend at the beginning of the readme.

Further Reading

http://web.archive.org/web/20080228054405/http://www.davebollinger.com/works/pixelrobots/

This project is inspired by this blog post, which I think is a very interesting dive into generated art and some nifty things you can do with it.

Todos

Beyond further futzing with colors and how to define them, I think I've cleared the low hanging fruit.  That being said, please feel free to add issues or pull requests,I would love to get input on how to make even more interesting generative art or less cluttered Go code.  

You might also like...
Turn a grid of frames (stored in a single image) into a video file
Turn a grid of frames (stored in a single image) into a video file

reel2vid Convert a video that is encoded into one large image as many images sid

Super fast static photo and video gallery generator (written in Go and HTML/CSS/native JS)

fastgallery Fast static photo and video gallery generator Super fast (written in Go and C, concurrent, uses fastest image/video libraries, 4-8 times f

OpenGL binding generator for Go

GoGL GoGL is an OpenGL binding generator for Go. No external dependencies like GLEW are needed. Install the OpenGL bindings For example, OpenGL 2.1 bi

An avatar generator for Go.

Cameron An avatar generator for Go. Oh, by the way, the name of this project came from the Avatar's director James Cameron. Features Identicon Install

:triangular_ruler: Create beautiful generative image patterns from a string in golang.
:triangular_ruler: Create beautiful generative image patterns from a string in golang.

geopattern Create beautiful generative image patterns from a string in golang. Go port of Jason Long's awesome GeoPattern library. Read geopattern's d

Create a cool glass-like pattern using Voronoi cells
Create a cool glass-like pattern using Voronoi cells

voronoi-glass Have you ever looked through a shower door made of intentionally uneven glass? Everything looks distorted, but maybe also beautiful. Now

simple but poweful mosaic picture generator
simple but poweful mosaic picture generator

MOSAIC MAN simple but poweful mosaic picture generator it's completely free with a highly customizable mosaic server RESULT Ex1 RESULT Ex2 OPTIONS til

Easily customizable Social image (or Open graph image) generator

fancycard Easily customizable Social image (or Open graph image) generator Built with Go, Gin, GoQuery and Chromedp Build & Run Simply, Clone this rep

A festive Christmas tree GIF generator implemented using only Golang standard library code
A festive Christmas tree GIF generator implemented using only Golang standard library code

Christmas Tree GIF Generator A festive Christmas tree GIF generator implemented

Comments
  • Delimiters is buggy

    Delimiters is buggy

    Implementation does not work for vert folds. Colors are also incorrect. Should only affect templates with delimiters, will fix soon. Use 1.1 release just to be sure.

    opened by PhiloTFarnsworth 1
  • possible to do a version for nft collections of 10k generation?

    possible to do a version for nft collections of 10k generation?

    possible to do a version for nft collections of 10k generation?

    need a few things

    1. 64x64 pixels
    2. a few traits in folders (png / bitmap) such as eyes, mouth, head dressing, necklace, earrings, male/ woman etc that's all?

    also should be like cryptopunk's face showing side ways? possible to do this?

    can we do this together? will share the royalties with you for the nft collection

    opened by hiqsociety 1
Releases(1.3.0)
  • 1.3.0(May 20, 2021)

    Another week, another release. In case you didn't already have enough reasons to use BitSprite, I have added a 'delimiter' pixel, which can allow users to preview randomized composites of several sprites stacked on top of each other. Check out the Readme for a short tutorial on compositing templates to use in BitSprite!

    Changelog: -Delimiter Pixels! -Flower Versioning! -Got rid of not one, but two instances where I divided a number by two immediately after multiplying it by two.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(May 8, 2021)

    This release includes new options for folding images across the bottom, as well as in tandem with the current fold options. Want tiles? It's easier than even now with BitSprite. Individual sprite generation is no longer default behavior, users set '-individuals' to True for the old implementation, but for anyone who just needs a sprite sheet, the default behavior of BitSprite should get a small speed boost.

    -Changelog -Added '-vertfold' flag, which allows users to fold across the bottom of their images. -Added '-individuals' flag, which makes individual sprite generation optional. -More tests, more readme, much wow.

    Source code(tar.gz)
    Source code(zip)
  • V1.0.0(Apr 26, 2021)

Owner
Michael Gardner
I never know what to write in these. Comments, questions and solicitations at [email protected]
Michael Gardner
Paprika is a toolbox for creating short clips from multiple png files.

Paprika Paprika is a toolbox for creating short clips from multiple png files. Requirements This program is mainly a wrapper around ffmpeg. As such, y

_Alvoras 8 Feb 16, 2022
Image size analyzer for jpg/png/gif/webp

imgsz Image size analyzer for jpg/png/gif/webp Usage // DecodeSize decodes the dimensions of an image that has // been encoded in a registered format.

源文雨 0 Jan 8, 2022
Very simple SVG to PNG converter library using the Inkscape.

svg2png Description Very simple SVG to PNG converter library using the Inkscape.

null 0 Jan 11, 2022
Snippit - Creates syntax-highlighted code snippets in png or svg format

snippit creates syntax-highlighted code snippets in png or svg format. Installat

Julius Hinze 8 Oct 10, 2022
Go-Generative-Art-A - Generate PNG art from source images! GOLang Generative Art

GO Lang Generative Art Tool A Take source images and generate art utilizing sour

null 5 Nov 21, 2022
A Go package converting a monochrome 1-bit bitmap image into a set of vector paths.

go-bmppath Overview Package bmppath converts a monochrome 1-bit bitmap image into a set of vector paths. Note that this package is by no means a sophi

tunabay 2 Mar 22, 2022
Image compression codec for 16 bit medical images

MIC - Medical Image Codec This library introduces a lossless medical image compression codec MIC for 16 bit images which provides compression ratio si

Kuldeep S 0 Dec 26, 2021
Pbm - Package ppm implements a Portable Bit Map (PBM) image decoder and encoder written in Go

Package pbm import "github.com/slashformotion/pbm" Package pbm implements a Portable Bit Map (PBM) image decoder and encoder. The supported image col

slashformotion 0 Jan 5, 2022
Merge multiple pprof profile files into a single file

pprof-merge Merges multiple pprof profile files into one. Installation $ go get github.com/rakyll/pprof-merge Usage $ pprof-merge profile1.data profi

Jaana Dogan 115 Dec 15, 2022
Generate image plots of processes' memory usage very quickly, within a single binary.

memplot A small utility written in golang to quickly plot memory usage of processes. memplot constantly samples memory usage of a process, for a given

Alessandro 173 Apr 17, 2021