Skip to content
Generating tiled images with Go and Gopherjs
Go HTML Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/stickergen
output
render
LICENSE
Makefile
README.md
color-picker.min.css
color-picker.min.js
index.html
main.go
stickergen
stickergen.js
stickergen.js.map

README.md

This is a toy app which generates pixel grids, like so:

pixel grid

For more context, check out the Generative Laptop Skin post on my blog.

It comes with a CLI app (stickergen) and has been transpiled to javascript with gopherjs so it can be embedded in web apps.

Command line options:

  --rows value, -r value      (default: 50)
  --cols value, -c value      (default: 72)
  --cellsize value, -s value  (default: 35)
  --outfile value, -o value   (default: "output.png")
  --palette value, -p value   (default: "random")

To use javascript, include the script:

<script src="stickergen.js"></script>

And then call the function:

var img = generateImage(rows, columns, cellsize, firstColor, secondColor)

The returned value is a Data URI encoded PNG, so can be assigned as the src attribute of an img element. Example usage:

<img id="targetImg"></img>

...
myImg = document.getElementById("targetImg")
myImg.src = generateImage(40, 80, 9, "#f21326", "#eac4f9")

There is a more fully worked example in index.html in this repository.

You can’t perform that action at this time.