Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

hectorm/pzntg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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,0],
		[0,0,0,0,0,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,0,0,0,0,0],
		[0,0,0,0,0,1,1,2,2,2,4,2,2,2,2,2,2,2,4,2,2,2,1,1,0,0,0,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,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
});

About

Indexed color PNG image generator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published