Pixel Manipulation
The setPixels()
method allows for modification of a specific section of pixels from the canvas.
To modify the pixels, you can loop through each pixel using the each
callback method.
The each
callback function accepts two parameters:
- An object containing the properties for red, green, blue, and alpha color values (
r
,g
,b
,a
) - The parameters passed to the
setPixels()
method
Basic usage
Pixels and Events
In this example, hovering over the image will manipulate the pixels closest to the part you hovered over.
Notes
If the width
, and height
properties are not specified, the method loops through every pixel on the canvas.
The r
, g
, b
, and a
properties all range from 0
to 255
.
As with all jCanvas methods, the setPixels()
method respects the value of the fromCenter
property, which defaults to true
.