Utilities to manipulate RGBA pixels.
Static methods
staticcopy(srcBuffer:UInt8Array, srcBufferWidth:Int, dstBuffer:UInt8Array, dstBufferWidth:Int, srcX:Int, srcY:Int, srcWidth:Int, srcHeight:Int, dstX:Int, dstY:Int, copyRed:Bool = true, copyGreen:Bool = true, copyBlue:Bool = true, copyAlpha:Bool = true):Void
Copy pixels from srcBuffer
to dstBuffer
Parameters:
srcBuffer | Source buffer to copy pixels from |
---|---|
srcBufferWidth | Source buffer image width (needed to know index from x,y coordinates) |
dstBuffer | Destination buffer to past pixels into |
dstBufferWidth | Destination buffer image width (needed to know index from x,y coordinates) |
srcX | Source x position to copy from |
srcY | Source y position to copy from |
srcWidth | Source width to copy from |
srcHeight | Source height to copy from |
dstX | Destination x to paste into |
dstY | Destination y to paste into |
copyRed | Set to |
copyGreen | Set to |
copyBlue | Set to |
copyAlpha | Set to |
staticcreate(width:Int, height:Int, fillColor:AlphaColor):UInt8Array
Create a pixels buffer
Parameters:
width | Image width |
---|---|
height | Image height |
fillColor | Default color |
Returns:
UInt8Array
staticinlineget(buffer:UInt8Array, bufferWidth:Int, x:Int, y:Int):AlphaColor
Get a pixel as AlphaColor
at x
,y
coordinates on the given buffer
Parameters:
buffer | The pixel buffer to read from |
---|---|
bufferWidth | Image width |
x | Pixel x position |
y | Pixel y position |
Returns:
AlphaColor
staticinlineset(buffer:UInt8Array, bufferWidth:Int, x:Int, y:Int, color:AlphaColor):Void
Set a pixel as AlphaColor
at x
,y
coordinates on the given buffer
Parameters:
buffer | The pixel buffer to write into |
---|---|
bufferWidth | Image width |
x | Pixel x position |
y | Pixel y position |
color | AlphaColor of the pixel |
staticinlinesetRectangle(buffer:UInt8Array, bufferWidth:Int, x:Int, y:Int, width:Int, height:Int, color:AlphaColor):Void
Set a rectangle of pixels as AlphaColor
at x
,y
coordinates and with the specified width
and height
on the given buffer
Parameters:
buffer | The pixel buffer to write into |
---|---|
bufferWidth | Image width |
x | Rectangle x position |
y | Rectangle y position |
width | Rectangle width |
height | Rectangle height |
color | AlphaColor of the rectangle's pixels |
staticinlinepixelsToPng(width:Int, height:Int, pixels:UInt8Array, path:String, done:() ‑> Void):Void
staticinlinepixelsToPng(width:Int, height:Int, pixels:UInt8Array, done:(data:Bytes) ‑> Void):Void
Export the given pixels pixels as PNG data and save it to the given file path
Parameters:
width | Image width |
---|---|
height | Image height |
pixels | The pixels buffer |
path | The png file path where to save the image ( |
done | Called when the png has been exported |
staticrgbaPixelsToRgbPixels(width:Int, height:Int, inPixels:UInt8Array, ?outPixels:Null<UInt8Array>):UInt8Array
Converts a RGBA pixels buffer into RGB pixels buffer
Parameters:
width | Image width |
---|---|
height | Image height |
inPixels | The source RGBA pixels buffer |
outPixels | (optional) The destination RGB pixels buffer |
Returns:
The final RGB pixels buffer
staticrgbPixelsToRgbaPixels(width:Int, height:Int, alpha:Int = 255, inPixels:UInt8Array, ?outPixels:Null<UInt8Array>):UInt8Array
Converts a RGB pixels buffer into RGBA pixels buffer
Parameters:
width | Image width |
---|---|
height | Image height |
alpha | Alpha value (0-255) to use (default to 255) |
inPixels | The source RGBA pixels buffer |
outPixels | (optional) The destination RGB pixels buffer |
Returns:
The final RGBA pixels buffer
staticmixPixelsBuffers(inPixelsList:Array<UInt8Array>, middleFactor:Float = 1, ?outPixels:Null<UInt8Array>):UInt8Array
Mix the given list of pixels buffers into a single one.
Parameters:
inPixelsList | An array of pixels buffers |
---|---|
middleFactor | A multiplicator that makes the middle buffers more important than the rest if above 1 |
outPixels | (optional) The destination pixels buffer |
Returns:
The final mixed pixels buffer
staticflipY(buffer:UInt8Array, bufferWidth:Int):Void
Flip the given pixels buffer on the Y axis
Parameters:
buffer | The pixel buffer to read from and write to |
---|---|
bufferWidth | Image width |
staticflipX(buffer:UInt8Array, bufferWidth:Int):Void
Flip the given pixels buffer on the X axis
Parameters:
buffer | The pixel buffer to read from and write to |
---|---|
bufferWidth | Image width |