Composite.Image Class
Image Class
Constructor
Item Index
Methods
Attributes
Methods
_getGetAtFunction
()
private
Call this function with the length of each dimension followed by the number of channels. Returns a function which accepts a pixel index and returns an at array.
Returns:
_getGetPixelIndexFunction
()
private
Call this function with the length of each dimension. Returns a function which accepts dimension indices and returns a pixel index.
Returns:
clear
()
chainable
Clears the image. This method is chainable.
conformChannelValue
-
value
-
channel
Conforms the given value to the channel's specifications.
Returns:
eachPixel
-
pixelParameters
-
callbackFunction
-
contextObject
Invokes a function for each pixel in the image. This method is chainable.
Parameters:
-
pixelParameters
ObjectThis object contains the following members
- ctx - Object - Optional scope with which to call fn.
-
fn - Function - This function is invoked once per pixel.
This function will receive an object with the following
parameters
- at - Array of image pixel coordinates.
- chs - Array of image channel definitions.
- dims - Array of image dimension lengths.
- img - Reference to this image.
- pch - Array of pixel channel indices.
- pcnt - Number of pixels in this image.
- pix - Integer index of this pixel.
- pxl - Array of pixel channel values.
- pch - Array - Optional array of channel indexes. If undefined, pixels will contain all channels in order.
-
callbackFunction
FunctionThis function is invoked after the function has been invoked for each pixel in the image. This function will receive an object with the following members
- chs - Array of image channel definitions.
- dims - Array of image dimension lengths.
- img - Reference to this image.
- pcnt - Number of pixels in this image.
- pix - The last integer pixel index processed. If eachPixel was not stopped early, this value should be equal to pcnt and not a valid pixel index.
-
contextObject
ObjectOptional scope with which to call the callback function.
getAt
-
pixelIndex
Converts a pixel index to an at array.
Parameters:
-
pixelIndex
Number
Returns:
getPixel
-
at
-
pixelChannels
Accessor method to get a pixel from the image.
Parameters:
Returns:
setPixel
-
at
-
pixel
-
pixelChannels
Accessor method to set a pixel in the image. This method is chainable.
Parameters:
-
at
ArrayArray containing pixel coordinates. The length of this array should match the number of dimensions of the image.
-
pixel
ArrayArray containing the pixel's channel values.
-
pixelChannels
ArrayOptional array of channel indexes. If undefined, the given pixel is assumed to contain all channels in order.
Attributes
channels
Array
Defines the color space for the image.
An image can have as many channels as needed. 3 or 4 channels is most common. Usually the first channel is the red color component, the second is green, the third is blue, and the fourth is alpha.
There are various ways to represent the value of a channel. Values can either be stored as integers or floating-point numbers. Values may be constrained within a minimum and maximum value.
Most commonly red, green, and blue channels are represented by integers between 0 and 255. In this case the values 0, 0, 0 represent black and the values 255, 255, 255 represent white.
The alpha channel is commonly stored as a floating-point value from 0 to 1. 1 represents a completely visible pixel while 0 is completely transparent.
Values are not required to be constrained. For example, sometimes it is interesting or useful to store colors which have brightness beyond white.
This attribute should be set to an array of objects. This array represents the channels in order. This array should have at least one element. This should not be a sparse array. Each object must have a mode property. The mode property must be set to either 'f' for floating-point values or 'i' for integer values. Each object may include the optional maximum and/or minimum properties. Each object may include the optional blackValue and/or whiteValue properties. If undefined, blackValue will default to 0 and whiteValue will default to 255 when mode is set to 'i' or 1 otherwise.
Default: [ {maximum: 255, minimum: 0, mode:'i'}, {maximum: 255, minimum: 0, mode:'i'}, {maximum: 255, minimum: 0, mode:'i'}, {maximum: 1, minimum: 0, mode:'f'} ]
Fires event channelsChange
Fires when the value for the configuration attribute channels
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
dimensions
Array
Defines the pixel dimensions of the image.
An image can have as many dimensions as needed. 2 dimensions is most common. Usually the first dimension is width and the second is height.
Default: [512, 512]
Fires event dimensionsChange
Fires when the value for the configuration attribute dimensions
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
pixelCount
Number
Contains the number of pixels in the image.
Fires event pixelCountChange
Fires when the value for the configuration attribute pixelCount
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added: