public void Add(double h, double s, double b, double w) {
if (Equals(w, 0d)) return;
if (h - H >= 180) {
h -= 360;
} else if (H - h >= 180) {
H -= 360;
}
H = (H * Weight + h * w) / (Weight + w);
if (H < 0) {
H += 360;
} else if (H >= 360) {
H -= 360;
}
S = (S * Weight + s * w) / (Weight + w);
Smax = Math.Max(Smax, s);
B = (B * Weight + b * w) / (Weight + w);
Bmax = Math.Max(Bmax, b);
Weight += w;
}