1.1.1 • Published 2 years ago

randpix v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Fastest random pixel avatar generator

  • ~8000 pixel arts per second
  • Many color schemes
  • Very simple
  • Browser support

Live demo

Installing Canvas for Randpix

OSCommand
OS XUsing Homebrew:brew install pkg-config cairo pango libpng jpeg giflib librsvg
Ubuntusudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
Fedorasudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel
Solarispkgin install cairo pango pkg-config xproto renderproto kbproto xextproto
OpenBSDdoas pkg_add cairo pango png jpeg giflib
WindowsSee the wiki
OthersSee the wiki

Example

import { randpix, RandpixColorScheme, Symmetry } from 'randpix'

const generate = randpix({
  colorScheme: RandpixColorScheme.DARKULA, // Color theme (default: NEUTRAL)
  size: 8, // Art size. Recommended 7 or 8 (odd/even symmetry) (default: 8)
  scale: 32, // Pixel scale (default: 1)
  symmetry: Symmetry.VERTICAL, // Symmetry (default: VERTICAL)
  color: [255, 100, 50], // [R, G, B] like color for solid art (default: undefined),
  seed: 'Some string', // Seed (default: undefined)
  colorBias: 15, // Slightly changes the color hue, which adds more color to the image (default: undefined)
  grayscaleBias: false // Change only the brightness of the color instead of the hue (default: undefined)
})

const art = generate() // Generating the pixel art

const pngBuffer = art.toBuffer('image/png')
const dataURL = art.toDataURL()

Custom color scheme

const customColorScheme = [
  // [R, G, B, C], C is the frequency of this color appearing in the pixel art
  [151, 219, 174, 1],
  [195, 229, 174, 0.5],
  [241, 225, 166, 0.5],
  [244, 187, 187, 0.2],
]

My Benchmarks

With defaults: 0.11812 ms/art. Speed: 8465 arts/s
With scale 32: 0.14147 ms/art. Speed: 7068 arts/s
With bias 15: 0.11686 ms/art. Speed: 8557 arts/s
With full fill: 0.21214 ms/art. Speed: 4713 arts/s
With quarter fill: 0.06061 ms/art. Speed: 16497 arts/s
With quad symmetry: 0.11023 ms/art. Speed: 9072 arts/s
With solid color: 0.10263 ms/art. Speed: 9744 arts/s
Every instanced: 0.15031 ms/art. Speed: 6652 arts/s
1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago