Skip to content

Commit

Permalink
Update...
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirus2000 committed Nov 10, 2024
1 parent 2c62483 commit 4b16faa
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,27 @@ DoubleFunction<Color> buildColorFunction(ResourceManager resourceManager)
case GREEN_GRAY_RED -> performance -> {
// Performance interpolates between green (positive) and gray
// (neutral) or red (negative)
double p = normalizePerformance(performance);
double p = Math.min(MAX_PERFORMANCE, Math.abs(performance)) / MAX_PERFORMANCE;
RGB color;

if (performance > 0)
{
color = Colors.interpolate(Colors.GRAY.getRGB(), Colors.HEATMAP_DARK_GREEN.getRGB(), (float) p);
}
else
{
// Using -p for correct mapping of negatives
color = Colors.interpolate(Colors.GRAY.getRGB(), Colors.RED.getRGB(), (float) -p);
}
color = Colors.interpolate(Colors.GRAY.getRGB(), Colors.RED.getRGB(), (float) p);

return resourceManager.createColor(color);
};

case BLUE_GRAY_ORANGE -> performance -> {
// Performance interpolates between blue (stable) and gray
// (neutral) or orange (volatile)
double p = normalizePerformance(performance);
double p = Math.min(MAX_PERFORMANCE, Math.abs(performance)) / MAX_PERFORMANCE;
RGB color;

if (performance > 0)
{
color = Colors.interpolate(Colors.GRAY.getRGB(), Colors.BLUE.getRGB(), (float) p);
}
else
{
// Using -p for correct mapping of negatives
color = Colors.interpolate(Colors.GRAY.getRGB(), Colors.HEATMAP_ORANGE.getRGB(), (float) -p);
}
color = Colors.interpolate(Colors.GRAY.getRGB(), Colors.HEATMAP_ORANGE.getRGB(), (float) p);

return resourceManager.createColor(color);
};
Expand Down Expand Up @@ -151,6 +141,7 @@ DoubleFunction<Color> buildColorFunction(ResourceManager resourceManager)
*/
private double normalizePerformance(double performance)
{
// -0.05 + 0.07 / (2 * 0.07) = 0.02 / 0.14 = -0.14285714285714285
performance = Math.max(-MAX_PERFORMANCE, performance);
performance = Math.min(MAX_PERFORMANCE, performance);
return (performance + MAX_PERFORMANCE) / (2 * MAX_PERFORMANCE);
Expand Down

0 comments on commit 4b16faa

Please sign in to comment.