MCPcopy Index your code
hub / github.com/zxlie/FeHelper / getColorBrightness

Function getColorBrightness

apps/chart-maker/chart-generator.js:925–940  ·  view source on GitHub ↗
(color)

Source from the content-addressed store, hash-verified

923
924// 获取颜色亮度
925function getColorBrightness(color) {
926 // 处理rgb格式
927 if (color.startsWith('rgb(')) {
928 const parts = color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
929 if (parts) {
930 const r = parseInt(parts[1]);
931 const g = parseInt(parts[2]);
932 const b = parseInt(parts[3]);
933 // 计算亮度 (根据人眼对RGB的敏感度加权)
934 return (r * 0.299 + g * 0.587 + b * 0.114) / 255;
935 }
936 }
937
938 // 默认返回0.5
939 return 0.5;
940}
941
942// 获取热力图颜色
943function getHeatmapColor(value) {

Callers 1

renderHeatmapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected