Commit 2134e4ab by Alexander Bazo

Fix bug in color generator

parent de596a27
......@@ -50,7 +50,7 @@ class ImageViewerRoom extends colyseus.Room {
if (message.type === "gaze") {
if (client.color === undefined) {
client.color = Colors.createRandomColor();
Logger.log(`Assign clien color: ${client.color}`, "ImageViewer Room");
Logger.log(`Assign client color: ${client.color}`, "ImageViewer Room");
}
message.data.color = client.color;
let point = GazePoint.fromClientData(message.data);
......
......@@ -7,8 +7,11 @@ function createRandomColorChannel() {
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
var hex = Number(c).toString(16);
if (hex.length < 2) {
hex = "0" + hex;
}
return hex;
}
function rgbToHex(r, g, b) {
......@@ -21,7 +24,7 @@ class Colors {
let r = createRandomColorChannel(),
g = createRandomColorChannel(),
b = createRandomColorChannel();
return rgbToHex(r,g,b);
return rgbToHex(r, g, b);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment