|
|
|
@ -399,11 +399,15 @@ namespace CriticalPathAnalyzer.Server.Tool {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Obtain additional information about the cluster:
|
|
|
|
|
/// Collect all it's pegs and sockets.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static ClusterDetails CollectClusterInformation(Cluster cluster, int time) {
|
|
|
|
|
var details = new ClusterDetails {
|
|
|
|
|
Pegs = new List<PegAddress>(),
|
|
|
|
|
ConnectingComponents = new List<ComponentAddress>(),
|
|
|
|
|
Color = HsvToRgb(time * 20, 1, 1),
|
|
|
|
|
Time = time,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Two lists are never null, according to how it is created and used:
|
|
|
|
@ -418,59 +422,9 @@ namespace CriticalPathAnalyzer.Server.Tool {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (OutputPeg peg in outputPegs) {
|
|
|
|
|
details.Pegs.Add(peg.Address);
|
|
|
|
|
}
|
|
|
|
|
details.Pegs.AddRange(outputPegs.Select(peg => peg.Address));
|
|
|
|
|
|
|
|
|
|
return details;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <param name="h">0 - 360</param>
|
|
|
|
|
/// <param name="s">0.0 - 1.0</param>
|
|
|
|
|
/// <param name="v">0.0 - 1.0</param>
|
|
|
|
|
/// <returns>0xrrggbb</returns>
|
|
|
|
|
private static int HsvToRgb(int h, float s, float v) {
|
|
|
|
|
s = Math.Clamp(s, 0, 1);
|
|
|
|
|
v = Math.Clamp(v, 0, 1);
|
|
|
|
|
h = (h % 360 + 360) % 360; // Ensure hue is within 0-359 range
|
|
|
|
|
|
|
|
|
|
float c = v * s;
|
|
|
|
|
float x = c * (1 - Math.Abs((h / 60.0f) % 2 - 1));
|
|
|
|
|
float m = v - c;
|
|
|
|
|
|
|
|
|
|
float r, g, b;
|
|
|
|
|
|
|
|
|
|
if (h < 60) {
|
|
|
|
|
r = c;
|
|
|
|
|
g = x;
|
|
|
|
|
b = 0;
|
|
|
|
|
} else if (h < 120) {
|
|
|
|
|
r = x;
|
|
|
|
|
g = c;
|
|
|
|
|
b = 0;
|
|
|
|
|
} else if (h < 180) {
|
|
|
|
|
r = 0;
|
|
|
|
|
g = c;
|
|
|
|
|
b = x;
|
|
|
|
|
} else if (h < 240) {
|
|
|
|
|
r = 0;
|
|
|
|
|
g = x;
|
|
|
|
|
b = c;
|
|
|
|
|
} else if (h < 300) {
|
|
|
|
|
r = x;
|
|
|
|
|
g = 0;
|
|
|
|
|
b = c;
|
|
|
|
|
} else {
|
|
|
|
|
r = c;
|
|
|
|
|
g = 0;
|
|
|
|
|
b = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rInt = (byte) ((r + m) * 255);
|
|
|
|
|
int gInt = (byte) ((g + m) * 255);
|
|
|
|
|
int bInt = (byte) ((b + m) * 255);
|
|
|
|
|
|
|
|
|
|
return (rInt << 16) | (gInt << 8) | bInt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|