ndpixels v1.0.1
ndpixels
ndpixels are ndarrays in a format for pixels.
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] // cmykformat
should be a String identifier for the color space model, e.g. rgb.
modules
some modules use ndpixels.
- get-pixels
- ndarray-from-image
- ndarray-from-canvas
- save-pixels
- data-uri-to-ndarray
- apply-colormap
- ndarray-imshow
- baboon-image
- ndarray-warp
- ndarray-homography
- ndpack-image
- ndarray-pixel-sort
- pixels-canvas
- pixel-to-css-color
- rainbow-pixels
- ndpixels-convert
- pixels-apa102
- ndpixels-opc
- 2dpixels-terminal
feel free to add what's missing. :)
ndpixels type
npm install --save ndpixelsextended from t-ndarray
for performant iterations, use cwise
Ndpixels = require('ndpixels')
ndpixels = Ndpixels(options)
options.datais a 1D array storage. It is either an instance ofArray, a typed array, or an object that implementsget(), set(), .lengthoptions.shapeis the shape of the view (Default:data.length)options.strideis the resulting stride of the new array. (Default: row major)options.offsetis 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.0Unless 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.