color_gray
color_gray(color, [mode]) -> Hex color
Return the color in gray
Syntaxe
var col = color_gray(color="7C0C09")
Arguments
| Name | Required | Default | Description |
|---|---|---|---|
color | yes | - | Color |
mode | - | - | Mode to convert: luminance (by default), rgbmedian, lightness, lab |
Full example
canvas(width=550, height=120);
var base = "#FFC107";
var col = color_gray(color=base); // mode==luminance
circle(x= 50, y=50, radius=40, fill=base);
circle(x=200, y=50, radius=40, fill=col);
text("luminance", 160, 105);
col = color_gray(color=base, mode="rgbmedian");
circle(x=300, y=50, radius=40, fill=col);
text("rgbmedian", 260, 105);
col = color_gray(color=base, mode="lightness");
circle(x=400, y=50, radius=40, fill=col);
text("lightness", 360, 105);
col = color_gray(color=base, mode="lab");
circle(x=500, y=50, radius=40, fill=col);
text("lab", 460, 105);
arrow(x=150, y=50, rotation=0, length=50, shaft=10, head=25, position=true);
save("color_gray.png");
