All Projects → czycha → pxlsrt.js

czycha / pxlsrt.js

Licence: MIT license
Node.js module for pixel sorting.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pxlsrt.js

Pix
🎨 Pix is an online pixel art community where everyone can unleash their creativity on a 16x16 canvas, built with React-Native for iOS devices. 🚀
Stars: ✭ 86 (+86.96%)
Mutual labels:  art, pixel-art
Geopattern
📐 Create beautiful generative image patterns from a string in golang.
Stars: ✭ 1,113 (+2319.57%)
Mutual labels:  art, pixel-art
pixelino
Pixel-drawing app for iOS ✍️
Stars: ✭ 45 (-2.17%)
Mutual labels:  art, pixel-art
Icon Machine
Web application for randomly generating pixel art icons.
Stars: ✭ 73 (+58.7%)
Mutual labels:  art, pixel-art
Gitfiti
abusing github commit history for the lulz
Stars: ✭ 6,750 (+14573.91%)
Mutual labels:  art, pixel-art
Pixelorama
A free & open-source 2D sprite editor, made with the Godot Engine! Available on Windows, Linux, macOS and the Web!
Stars: ✭ 2,535 (+5410.87%)
Mutual labels:  art, pixel-art
Ascii py
Make some ascii arts
Stars: ✭ 211 (+358.7%)
Mutual labels:  art
Shan Shui Inf
Procedurally generated Chinese landscape painting.
Stars: ✭ 3,168 (+6786.96%)
Mutual labels:  art
Sky Design
🌃 the design reference for the developers who care about good design.
Stars: ✭ 199 (+332.61%)
Mutual labels:  art
Omnidome
Dome Mapping Projection Software
Stars: ✭ 184 (+300%)
Mutual labels:  art
Art1
Art1 by Richard Williams, 1968
Stars: ✭ 24 (-47.83%)
Mutual labels:  art
gapdecoder
Google Arts And Culture Downloader. Python script to download high-resolution images from google arts & culture.
Stars: ✭ 78 (+69.57%)
Mutual labels:  art
Chataigne
Artist-friendly Modular Machine for Art and Technology
Stars: ✭ 251 (+445.65%)
Mutual labels:  art
Nonflowers
Procedurally generated paintings of nonexistent flowers.
Stars: ✭ 208 (+352.17%)
Mutual labels:  art
P5.js
p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
Stars: ✭ 16,542 (+35860.87%)
Mutual labels:  art
Lief
Authors
Stars: ✭ 2,730 (+5834.78%)
Mutual labels:  art
pixelart.js
punks.js - draw punk (pixel) art images using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes and more
Stars: ✭ 132 (+186.96%)
Mutual labels:  pixel-art
Creative Adversarial Networks
(WIP) Implementation of Creative Adversarial Networks https://arxiv.org/pdf/1706.07068.pdf
Stars: ✭ 193 (+319.57%)
Mutual labels:  art
Circle Evolution
Evolutionary Art Using Circles in Python
Stars: ✭ 237 (+415.22%)
Mutual labels:  art
voxel-builder
Voxel-based 3D modeling application
Stars: ✭ 31 (-32.61%)
Mutual labels:  pixel-art

pxlsrt.js

This Node.js module is based on the RubyGem pxlsrt. Pixel sorting is where an image is divided into sections (called "bands" in pxlsrt nomenclature) and those sections are in turn sorted based off of properties of the pixels within them. Pxlsrt is a basic library that allows you to do this.

Installation

npm install pxlsrt

Example

Check out example/example.js for examples.

import Pxlsrt from 'pxlsrt';

Pxlsrt.read('./test.png').then(image => {
  image.filter('brute', { min: 10, max: 20, method: 'saturation', direction: 'vertical' }).write('./output.png');
})

Browser environment

There is a browser-friendly version as well. The only differences are that it loads a browser-friendly version of Jimp and removes methods that can't be taken in the browser (like writing to a file). Please note that even when minimized, this will be a pretty large file because of Jimp and its dependencies.

import Pxlsrt from 'pxlsrt/dist/browser';

Filters

Pxlsrt implements filters which affect how the image is pixel sorted. There are two filters included by default, "Brute" and "Smart". Pxlsrt is also extensible so custom filters can be written and included.

Default filter options

Filters are not required to have these options, but the default filters have these in common:

  • method – Sort method applied to band.
    • uniqueness – How unique the pixel is compared to the others in its band.
    • random – Shuffles band.
    • none – Performs no sorting option.
    • sumRGBA – Sum red, green, blue, and alpha channels. Default.
    • sumHSLA – Sum hue, saturation, lightness, and alpha channels.
    • sumHSVA – Sum hue, saturation, value, and alpha channels.
    • sumCMYKA – Sum cyan, magenta, yellow, black, and alpha channels.
    • luma – Alternative brightness value
    • alpha
    • red
    • green
    • blue
    • hue
    • saturation
    • lightness
    • value
    • cyan
    • magenta
    • yellow
    • black
  • direction – Direction to sort in.
    • horizontalDefault.
    • vertical
    • tlbr – Top-left to bottom-right diagonal.
    • trbl – Top-right to bottom-left diagonal.
  • reverse – Whether or not to reverse the band after sorting.
    • true – Reverses band.
    • false – Doesn't reverse band. Default.
    • 'either' – Randomly reverse or not reverse band.
  • middlate – Apply "middlation" effect. Middlation rearranges a band so the first pixel is in the middle, and continues to wind outwards. For example, {1 2 3 4 5 6} middlated once is {5 3 1 2 4 6}. You can loop and apply middlation multiple times or applying the process in reverse.
    • 0 – Apply no middlation . Default.
    • > 0 – Middlate that many times.
    • < 0 – Middlate in reverse that many times.
  • smooth – When sorting, keeps colors that are the same together. Default: false.

Brute filter

The Brute filter doesn't care about the contents of the image. Brute randomly divides the image into bands within a range of length. It is then sorted within those bands.

Options

  • min – The minimum band length. If less than 0, will equal the maximum band length. Default: -1.
  • max – The maximum band length. If less than 0, will equal the total size of the line. Default: -1.

Smart filter

The Smart filter uses edge detection to find regions of the image which it then sorts.

Options

  • tolerance – The higher the tolerance, the larger the regions, and the more pixels that are added to the bands. Different images may require different tolerances in order to achieve the intended effects. Default: 20.

Creating your own filter

Pxlsrt filters are based off of the Filter class and added via the FilterCollection. The filters that are included by default are built on top of DefaultFilter in order to centralize some of the common processes. Below is an example of how to create your own filter and apply it.

myfilter.js

import Pxlsrt from 'pxlsrt';

class MyFilter extends Pxlsrt.Filter {  // Alternatively, extend Pxlsrt.DefaultFilter
  // Your filter must override the run function
  // It only accepts two arguments:
  //   - image: Pxlsrt.Image that is calling the filter.
  //   - options: Object with options for the filter.
  static run(image, options = {}) {
    // Apply some effects to image
    return image;
  }
}

module.exports = MyFilter;

applymyfilter.js

import Pxlsrt from 'pxlsrt';
import MyFilter from './myfilter.js';

Pxlsrt.FilterCollection.add('myfilter', MyFilter);
Pxlsrt.read('./test.png').then(image => {
  image.filter('myfilter').write('./output.png');
});

API

To see classes and functions, run jsdoc and checkout the docs folder:

npm run jsdoc

License

Pxlsrt is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].