red

Static red 

Source
pub static red: RedInternalType
Expand description

Extracts the red value from a color or pixel array.

Examples

let c = color(255, 204, 0); // Define color 'c'
fill(c); // Use color variable 'c' as fill color
rect(15, 20, 35, 60); // Draw left rectangle

let redValue = red(c); // Get red in 'c'
print(redValue); // Print "255.0"
fill(redValue, 0, 0); // Use 'redValue' in new fill
rect(50, 20, 35, 60); // Draw right rectangle
colorMode(RGB, 255); // Sets the range for red, green, and blue to 255
let c = color(127, 255, 0);
colorMode(RGB, 1); // Sets the range for red, green, and blue to 1
let myColor = red(c);
print(myColor); // 0.4980392156862745

Parameters

color p5.Color object, color components, or CSS color