pub static tint: TintInternalTypeExpand description
Sets the fill value for displaying images. Images can be tinted to specified colors or made transparent by including an alpha value.
To apply transparency to an image without affecting its color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50% transparent (assuming the default alpha range of 0-255, which can be changed with colorMode()).
The value for the gray parameter must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
Examples
let img;
function preload() {
img = loadImage('assets/laDefense.jpg');
}
function setup() {
image(img, 0, 0);
tint(0, 153, 204); // Tint blue
image(img, 50, 0);
}let img;
function preload() {
img = loadImage('assets/laDefense.jpg');
}
function setup() {
image(img, 0, 0);
tint(0, 153, 204, 126); // Tint blue and set transparency
image(img, 50, 0);
}let img;
function preload() {
img = loadImage('assets/laDefense.jpg');
}
function setup() {
image(img, 0, 0);
tint(255, 126); // Apply transparency without changing color
image(img, 50, 0);
}Overloads
v1 red or hue value relative to
the current color range
v2 green or saturation value
relative to the current color range
v3 blue or brightness value
relative to the current color range
alpha?
value a color string
gray a gray value
alpha?
values an array containing the red,green,blue &
and alpha components of the color
color the tint color