pub fn color_to_css(c: &Color) -> StringExpand description
Converts a plotkit Color to a CSS rgba(...) string.
The alpha channel is normalized from the 0-255 range to a 0.0-1.0 float with four decimal places of precision, matching CSS color level 4 syntax.
ยงExamples
use plotkit_render_wasm::{color_to_css, Color};
assert_eq!(color_to_css(&Color::rgb(255, 0, 0)), "rgba(255,0,0,1)");
assert_eq!(color_to_css(&Color::new(0, 128, 255, 128)), "rgba(0,128,255,0.5020)");