Create custom colors with exact red, green, blue, and transparency values. Use this when color names aren't enough!
Creates a color from red, green, and blue values (0β255 each). You can also set transparency with the optional alpha value.
| Parameter | Type | Description |
|---|---|---|
r | number | Red (0β255) |
g | number | Green (0β255) |
b | number | Blue (0β255) |
aoptional | number | Alpha/transparency (0β255, default 255 = fully opaque) |
Returns: A color string you can use with fill(), stroke(), or background()
function setup() {
size(400, 300);
}
function draw() {
background("white");
noStroke();
fill(color(255, 0, 0));
circle(150, 150, 60);
fill(color(0, 0, 255, 128));
circle(250, 150, 60);
fill(color(0, 200, 0, 100));
circle(200, 100, 60);
}