Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Tweak user colors and add a little testing script for future experimenting. Closes #170

Gabe Kangas6706ce83a3cb
diff --git a/test/userColorsTest.js b/test/userColorsTest.js
new file mode 100644
index 0000000000..59a34f053a
--- /dev/null
+++ b/test/userColorsTest.js
@@ -0,0 +1,36 @@
+// Run on the command line to test colors.
+// node userColorsTest.js > colorTest.html
+
+console.log(`<body style="background: #2d3748">`);
+
+for (var i = 0; i < 20; i++) {
+ const element = generateElement(randomString(6));
+ console.log(element);
+}
+
+console.log(`</body>`);
+
+function generateElement(string) {
+ const color = messageBubbleColorForString(string);
+ return `<div style="color: ${color}">${string}</div>`
+}
+
+function randomString(length) {
+ return Math.random().toString(36).substring(length);
+}
+
+function messageBubbleColorForString(str) {
+ let hash = 0;
+ for (let i = 0; i < str.length; i++) {
+ // eslint-disable-next-line
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
+ }
+
+ // Tweak these to adjust the result of the color
+ const saturation = 75;
+ const lightness = 65;
+ const alpha = 1.0;
+ const hue = parseInt(Math.abs(hash), 16) % 300;
+
+ return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
+}
diff --git a/webroot/js/utils/user-colors.js b/webroot/js/utils/user-colors.js
index 9dac505c4e..dbb413dacb 100644
--- a/webroot/js/utils/user-colors.js
+++ b/webroot/js/utils/user-colors.js
@@ -6,8 +6,8 @@ export function messageBubbleColorForString(str) {
}
// Tweak these to adjust the result of the color
- const saturation = 70;
- const lightness = 50;
+ const saturation = 75;
+ const lightness = 65;
const alpha = 1.0;
const hue = parseInt(Math.abs(hash), 16) % 300;