MCPcopy
hub / github.com/zxlie/FeHelper / hexToRgba

Function hexToRgba

apps/chart-maker/chart-generator.js:801–812  ·  view source on GitHub ↗
(hex, alpha)

Source from the content-addressed store, hash-verified

799
800// 将十六进制颜色转换为rgba格式
801function hexToRgba(hex, alpha) {
802 // 移除井号
803 hex = hex.replace('#', '');
804
805 // 解析RGB值
806 const r = parseInt(hex.length === 3 ? hex.substring(0, 1).repeat(2) : hex.substring(0, 2), 16);
807 const g = parseInt(hex.length === 3 ? hex.substring(1, 2).repeat(2) : hex.substring(2, 4), 16);
808 const b = parseInt(hex.length === 3 ? hex.substring(2, 3).repeat(2) : hex.substring(4, 6), 16);
809
810 // 返回rgba字符串
811 return `rgba(${r}, ${g}, ${b}, ${alpha})`;
812}
813
814// 渲染热力图(自定义实现)
815function renderHeatmap(ctx, data, options) {

Callers 1

applyColorSchemeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected