toColor method

Color toColor([
  1. double alpha = 1.0
])

对应 Kotlin OkLch.toColor,将 OkLCH 转换为 sRGB Color

明度按 l/100 裁剪到 [0, 1];色度先按 c/100*0.4 缩放再裁剪到 [0, 0.4]; 色相规范化到 [0, 360),随后交由 Transforms.oklchToColor 完成色域裁剪。

Implementation

Color toColor([double alpha = 1.0]) {
  final lN = (l / 100.0).clamp(0.0, 1.0);
  final cN = (c / 100.0 * 0.4).clamp(0.0, 0.4);
  final hDeg = ((h % 360.0) + 360.0) % 360.0;
  return Transforms.oklchToColor(lN, cN, hDeg, alpha);
}