Random colour: index = hash(window.internalId) modulo number of colours, stable per window (also on restore)
@@ -110,8 +110,8 @@ class BurnMyWindowsMarbleEffect {
110
110
let c;
111
111
if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }
112
112
else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
113
else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)
114
let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);
113
else if (window) { // random: window id (internalId) hashed modulo the number of colours; stable per window
114
let h = 0; const id = String(window.internalId);
115
115
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;
116
116
c = C[Math.abs(h) % C.length]; window.bmwTint = c;
117
117
}
@@ -110,8 +110,8 @@ class BurnMyWindowsMarbleEffect {110
let c;110
let c;111
if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }111
if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }112
else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }112
else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }113
else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)113
else if (window) { // random: window id (internalId) hashed modulo the number of colours; stable per window114
let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);114
let h = 0; const id = String(window.internalId);115
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;115
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;116
c = C[Math.abs(h) % C.length]; window.bmwTint = c;116
c = C[Math.abs(h) % C.length]; window.bmwTint = c;117
}117
}@@ -114,8 +114,8 @@ class BurnMyWindowsMarbleMinimizeEffect {
114
114
let c;
115
115
if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }
116
116
else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
117
else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)
118
let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);
117
else if (window) { // random: window id (internalId) hashed modulo the number of colours; stable per window
118
let h = 0; const id = String(window.internalId);
119
119
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;
120
120
c = C[Math.abs(h) % C.length]; window.bmwTint = c;
121
121
}
@@ -114,8 +114,8 @@ class BurnMyWindowsMarbleMinimizeEffect {114
let c;114
let c;115
if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }115
if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }116
else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }116
else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }117
else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)117
else if (window) { // random: window id (internalId) hashed modulo the number of colours; stable per window118
let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);118
let h = 0; const id = String(window.internalId);119
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;119
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;120
c = C[Math.abs(h) % C.length]; window.bmwTint = c;120
c = C[Math.abs(h) % C.length]; window.bmwTint = c;121
}121
}