Skip to content
This repository has been archived by the owner. It is now read-only.
Indexed color PNG image generator.
JavaScript HTML
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.
browser
demo Initial commit Apr 5, 2016
lib Initial commit Apr 5, 2016
test Initial commit Apr 5, 2016
.eslintrc.json Initial commit Apr 5, 2016
.gitignore
LICENSE
README.md Initial commit Apr 5, 2016
package.json Initial commit Apr 5, 2016

README.md

PZNTG

Indexed color PNG image generator.

Usage

pzntg.create(options) → String (base64) | Uint8Array
  • options (object, required).

Supported options:

  • pixels (matrix, required).
  • palette (matrix, required).
  • scale (positive integer, optional, default = 1).
  • asBase64 (boolean, optional, default = true).
  • zlib_level (integer from 0 to 9, optional, default = Z_DEFAULT_COMPRESSION).
  • zlib_strategy (integer from 0 to 4, optional, default = Z_RLE).
  • zlib_memlevel (integer from 1 to 9, optional, default = 8).
  • callback (function, optional).

If callback is not defined, value is returned.

Read this for more information about zlib options.

Example

Octocat

pzntg.create({
	pixels: [
		[0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
		[0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0],
		[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
		[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
		[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
		[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
		[0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],
		[0,0,0,0,0,1,1,1,1,2,2,2,2,1,1,1,2,2,2,2,1,1,1,1,0,0,0,0,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,6,0,0,0,0,0,0],
		[0,0,0,0,0,6,6,6,1,1,6,6,1,1,6,1,1,6,6,1,1,6,6,6,0,0,0,0,0],
		[0,0,0,0,0,6,6,6,6,6,6,6,1,6,6,6,1,6,6,6,6,6,6,6,0,0,0,0,0],
		[0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,0,0],
		[0,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0]
	],
	palette: [
		[0,  0,   0,   0,   0],
		[0, 32,  32,  32, 255],
		[0,244, 202, 177, 255],
		[0,172,  92,  81, 255],
		[0,255, 255, 255, 255],
		[0,148, 148, 148, 255],
		[0,156, 218, 240, 255]
	],
	scale: 4
});
You can’t perform that action at this time.