From bc69d53152f7b8fd5ddd8afbee9ec88f47a19a0b Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 27 Apr 2014 17:53:27 +0000 Subject: Miscellaneous foo --- svg/subcan.js | 27 +++++++++++++++----- svg/subcan_dxf.svg | 74 +++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 89 insertions(+), 12 deletions(-) (limited to 'svg') diff --git a/svg/subcan.js b/svg/subcan.js index 63d0e74..4b328cf 100644 --- a/svg/subcan.js +++ b/svg/subcan.js @@ -45,12 +45,26 @@ function picker_begin(target) { var pickelem = document.getElementById('picker'); pickelem.style.visibility = 'visible'; - picktimer = window.setTimeout(picker_end, 5000); + picktimer = window.setTimeout(picker_end, 30000); } function picker_refresh() { window.clearTimeout(picktimer); - picktimer = window.setTimeout(picker_end, 5000); + picktimer = window.setTimeout(picker_end, 30000); +} + +function rgb2dmx(r, g, b) { + r = Math.floor((Math.pow(4.0, r / 255.0) - 1) / 3 * 255); + g = Math.floor((Math.pow(4.0, g / 255.0) - 1) / 3 * 180); + b = Math.floor((Math.pow(4.0, b / 255.0) - 1) / 3 * 144); + return [r,g,b]; +} +function dmx2rgb(r, g, b) { + l4 = 255.0 / Math.log(4.0); + r = Math.floor(Math.log(r / 255.0 * 3 + 1) * l4); + g = Math.floor(Math.log(g / 180.0 * 3 + 1) * l4); + b = Math.floor(Math.log(g / 144.0 * 3 + 1) * l4); + return [r,g,b]; } function on_picker(hex, hsv, rgb) { @@ -58,7 +72,7 @@ function on_picker(hex, hsv, rgb) { picker_refresh(); $.jsonRPC.request('light_set', { - params: [picktgt, [rgb.r, rgb.g, rgb.b]], + params: [picktgt, rgb2dmx(rgb.r, rgb.g, rgb.b)], error: function(result) { console.log('light_set RGB error', result); }, @@ -383,10 +397,11 @@ function update_elements(json) { continue; if (node.localName == "path") { + rgb = dmx2rgb(dataelem['r'], dataelem['g'], dataelem['b']); node.style.fill = "rgb(" - + dataelem['r'] + ", " - + dataelem['g'] + ", " - + dataelem['b'] + ")"; + + rgb[0] + ", " + + rgb[1] + ", " + + rgb[2] + ")"; } else { console.log("unknown dynamic content type", node.localName); } diff --git a/svg/subcan_dxf.svg b/svg/subcan_dxf.svg index 7e923c2..5a4ca69 100644 --- a/svg/subcan_dxf.svg +++ b/svg/subcan_dxf.svg @@ -175,8 +175,8 @@ borderopacity="1.0" inkscape:pageopacity="1" inkscape:pageshadow="2" - inkscape:zoom="1.3229167" - inkscape:cx="420" + inkscape:zoom="1.3" + inkscape:cx="480" inkscape:cy="240" inkscape:document-units="px" inkscape:current-layer="layer1" @@ -232,6 +232,66 @@ x="0.5" y="-0.5" /> + + + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" />