1.0.1 • Published 8 years ago

ndpixels v1.0.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
8 years ago

ndpixels

ndpixels are ndarrays in a format for pixels.

unstable

spec

each ndpixels frame should have the following properties:

shape

should be an Array of the form:

[width, channels]
[width, height, channels]
[width, height, depth, channels]

data

if we .pick(width, ...), we should see channel data in a form such as:

[keyword] // keyword
[red, green, blue] // rgb
[hue, saturation, value] // hsv
[hue, saturation, lightness] // hsl
[hue, whiteness, blackness] // hwb
[x, y, z] // xyz
[lightness, a, b] // lab
[l, c, h] // lch
[cyan, magenta, yellow, key] // cmyk

format

should be a String identifier for the color space model, e.g. rgb.

modules

some modules use ndpixels.

feel free to add what's missing. :)

ndpixels type

npm install --save ndpixels

extended from t-ndarray

for performant iterations, use cwise

Ndpixels = require('ndpixels')

ndpixels = Ndpixels(options)

  • options.data is a 1D array storage. It is either an instance of Array, a typed array, or an object that implements get(), set(), .length
  • options.shape is the shape of the view (Default: data.length)
  • options.stride is the resulting stride of the new array. (Default: row major)
  • options.offset is the offset to start the view (Default: 0)

Ndarray.is(any)

example

var Ndpixels = require('ndxpixels')

var rgb = Ndpixels({
  data: [
    0x00, 0xff, 0x00,
    0xff, 0x00, 0xff
  ],
  shape: [2, 3],
  format: 'rgb'
})
Ndpixels.is(rgb)

var hsl = Ndpixels({
  data: [
    0, 50, 50,
    120, 50, 50,
    240, 50, 50
    360, 50, 50
  ],
  shape: [4, 3],
  format: 'hsl'
})
Ndpixels.is(hsl)

license

The Apache License

Copyright © 2016 Michael Williams

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.