MCPcopy Index your code
hub / github.com/python/cpython / calculateHeatColor

Function calculateHeatColor

Lib/profiling/sampling/_heatmap_assets/heatmap.js:325–340  ·  view source on GitHub ↗

* Calculate heat color for given intensity (0-1) * Hot spans (>30%) get warm orange, cold spans get dimmed gray * @param {number} intensity - Value between 0 and 1 * @returns {string} rgba color string

(intensity)

Source from the content-addressed store, hash-verified

323 * @returns {string} rgba color string
324 */
325function calculateHeatColor(intensity) {
326 // Hot threshold: only spans with >30% of max samples get color
327 if (intensity > 0.3) {
328 // Normalize intensity above threshold to 0-1
329 const normalizedIntensity = (intensity - 0.3) / 0.7;
330 // Warm orange-red with increasing opacity for hotter spans
331 const alpha = 0.25 + normalizedIntensity * 0.35; // 0.25 to 0.6
332 const hotColor = getComputedStyle(document.documentElement).getPropertyValue('--span-hot-base').trim();
333 return `rgba(${hotColor}, ${alpha})`;
334 } else if (intensity > 0) {
335 // Cold spans: very subtle gray, almost invisible
336 const coldColor = getComputedStyle(document.documentElement).getPropertyValue('--span-cold-base').trim();
337 return `rgba(${coldColor}, 0.1)`;
338 }
339 return 'transparent';
340}
341
342/**
343 * Apply intensity-based heat colors to source spans

Callers 1

applySpanHeatColorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…