client/annotviz/app/js/utils.js
changeset 122 3b11017a76a4
parent 121 df6b39f962bc
parent 119 e6605fecb175
child 124 b5697bcdbaff
--- a/client/annotviz/app/js/utils.js	Thu Jan 22 15:03:58 2015 +0100
+++ b/client/annotviz/app/js/utils.js	Thu Jan 22 15:49:07 2015 +0100
@@ -14,6 +14,11 @@
 	return ((hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds  < 10 ? '0' + seconds : seconds));
 }
 
+function colorToHex(c) {
+	var m = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(c);
+	return m ? '#' + (1 << 24 | m[1] << 16 | m[2] << 8 | m[3]).toString(16).substr(1) : c;
+}
+
 function getAnnotCategories(urlCategories, annotCategories) {
 
     var jsonLoader = new PIXI.JsonLoader(urlCategories, true);
@@ -48,5 +53,6 @@
 
 module.exports = {
 	formatTime: formatTime,
-	getAnnotCategories: getAnnotCategories
+	getAnnotCategories: getAnnotCategories,
+	colorToHex: colorToHex
 };