Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kriegsman <kriegsman@tr.org>2015-08-17 19:28:14 +0300
committerMark Kriegsman <kriegsman@tr.org>2015-08-17 19:28:14 +0300
commit5acbd1e9236008cd1cfb1905714ee819b487bc1d (patch)
treee93517daab197cd02221ca0958e16c2f5b0fd9ab
parentd38e818a47ebbd69e20b910df2c6091c32fab612 (diff)
First cut at paletteknife
-rw-r--r--tools/index.html7
-rw-r--r--tools/paletteknife/index.html7
-rw-r--r--tools/paletteknife/pk2.html16
-rw-r--r--tools/paletteknife/pk2.js193
4 files changed, 223 insertions, 0 deletions
diff --git a/tools/index.html b/tools/index.html
new file mode 100644
index 00000000..058bfa28
--- /dev/null
+++ b/tools/index.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; url=http://fastled.io/" />
+</head>
+<body>
+</body>
+</html>
diff --git a/tools/paletteknife/index.html b/tools/paletteknife/index.html
new file mode 100644
index 00000000..058bfa28
--- /dev/null
+++ b/tools/paletteknife/index.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; url=http://fastled.io/" />
+</head>
+<body>
+</body>
+</html>
diff --git a/tools/paletteknife/pk2.html b/tools/paletteknife/pk2.html
new file mode 100644
index 00000000..14f1f7e7
--- /dev/null
+++ b/tools/paletteknife/pk2.html
@@ -0,0 +1,16 @@
+<html>
+<title>PaletteKnife for FastLED</title>
+<body>
+<h3>PaletteKnife for FastLED</h3>
+<p>Drag this to a toolbar: <a href="javascript:(function(){s=document.createElement('script');s.type='text/javascript';s.src='http://fastled.io/tools/paletteknife/pk2.js?v='+parseInt(Math.random()*99999999);document.body.appendChild(s);})();">PaletteKnife</a>
+
+<p>Then:
+<ol>
+<li>Go to CPT-CITY here, <a href="http://soliton.vm.bytemark.co.uk/pub/cpt-city/\" target=_new>http://soliton.vm.bytemark.co.uk/pub/cpt-city/</a>
+<li>Find a palette you like, e.g. <a href="http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/purplefly.png.index.html" target=_new>http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/purplefly.png.index.html</a>
+<li>Click PaletteKnife in your toolbar,
+<li>Copy the resulting code and paste it into your FastLED project.
+<li>Relaxen und watchen das blinkenlights.
+</ol>
+</body>
+</html>
diff --git a/tools/paletteknife/pk2.js b/tools/paletteknife/pk2.js
new file mode 100644
index 00000000..f4b9e3ea
--- /dev/null
+++ b/tools/paletteknife/pk2.js
@@ -0,0 +1,193 @@
+var stdout = "";
+
+function cursor_wait() {
+ document.body.style.cursor = 'wait';
+}
+
+function cursor_clear() {
+ document.body.style.cursor = 'default';
+}
+
+cursor_wait();
+
+function getParameterByName(name) {
+ var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
+ return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
+}
+
+function isNumeric(o)
+{
+ return !isNaN(parseFloat(o)) && isFinite(o);
+}
+
+function out()
+{
+ var args = Array.prototype.slice.call(arguments, 0);
+ // document.getElementById('output').innerHTML += args.join(" ") + "\n";
+ stdout += args.join(" ") + "\n";
+}
+
+
+function adjustGamma( orig, gamma)
+{
+ var o = orig / 255.0;
+ var adj = Math.pow( o, gamma);
+ var res = Math.floor( adj * 255.0);
+ if( (orig != 0) && (res == 0)) {
+ res = 1;
+ }
+ return res;
+}
+
+
+var origurl = document.location.href;
+//"http://soliton.vm.bytemark.co.uk/pub/cpt-city/dca/tn/alarm.p1.0.2.png.index.html";
+
+// origurl = //document.location.href;
+var url2 = origurl.replace( "/tn/", "/");
+var url3 = url2.replace( ".png.index.html", ".c3g");
+
+var onSite = url3.indexOf("http://soliton.vm.bytemark.co.uk/");
+if( onSite != 0) {
+ window.location.href="http://soliton.vm.bytemark.co.uk/pub/cpt-city/";
+ //return;
+}
+
+var matches = url3.match("([^/]+)\.c3g");
+var nom = matches[1];
+nom = nom.replace(/[^A-Za-z0-9]/g,"_");
+nom = nom + "_gp";
+
+
+var src = "/*\n\
+ CSS3 gradient\n\
+ cptutils 1.55\n\
+ Mon Sep 1 00:02:16 2014\n\
+*/\n\
+\n\
+linear-gradient(\n\
+ 0deg,\n\
+ rgb(186,218,139) 0.000%,\n\
+ rgb(186,218,139) 3.330%,\n\
+ rgb(231,234,155) 3.330%,\n\
+ rgb(231,234,155) 8.330%,\n\
+ rgb(254,243,181) 8.330%,\n\
+ rgb(254,243,181) 16.670%,\n\
+ rgb(246,215,150) 16.670%,\n\
+ rgb(246,215,150) 25.000%,\n\
+ rgb(205,164,119) 25.000%,\n\
+ rgb(205,164,119) 33.330%,\n\
+ rgb(187,144,105) 33.330%,\n\
+ rgb(187,144,105) 50.000%,\n\
+ rgb(225,225,225) 50.000%,\n\
+ rgb(225,225,225) 100.000%\n\
+ );";
+
+
+var rgamma = 2.6;
+var ggamma = 2.2;
+var bgamma = 2.5;
+
+var garg = getParameterByName("gamma");
+if( isNumeric( garg)) { rgamma=garg; ggamma=garg; bgamma=garg; }
+var rgarg = getParameterByName("rgamma");
+if( isNumeric( rgarg)) { rgamma = rgarg; }
+var ggarg = getParameterByName("ggamma");
+if( isNumeric( ggarg)) { ggamma = ggarg; }
+var bgarg = getParameterByName("bgamma");
+if( isNumeric( bgarg)) { bgamma = bgarg; }
+
+function CreateConversion( src)
+{
+ stdout="";
+
+ if( src.indexOf("rgba(") > -1 ) {
+ alert("WARNING: TRANSPARENCY not supported.");
+ }
+
+ var segs = 0;
+ var lines = src.split('\n');
+
+ out("DEFINE_GRADIENT_PALETTE( " + nom + " ) {");
+
+ for(var i = 0;i < lines.length;i++){
+ var line = lines[i]
+
+ //out(line);
+ var nums = line.match("([0-9]+), *([0-9]+), *([0-9]+)\\) *([0-9.]+)");
+ if( nums ) {
+ //out( nums);
+ var r = nums[1];
+ var g = nums[2];
+ var b = nums[3];
+ var pct = nums[4];
+ var ndx = Math.floor( (pct * 255.0) / 100.0 );
+
+ r = adjustGamma( r, rgamma);
+ g = adjustGamma( g, ggamma);
+ b = adjustGamma( b, bgamma);
+
+ var rstr = (" " + r).slice(-3);
+ var gstr = (" " + g).slice(-3);
+ var bstr = (" " + b).slice(-3);
+ var ndxstr = (" " + ndx).slice(-3);
+
+ var outstr = " ";
+ outstr += ndxstr + ", ";
+ outstr += rstr + ",";
+ outstr += gstr + ",";
+ outstr += bstr;
+
+ if( ndx == 255 ) {
+ outstr += "};";
+ } else {
+ outstr += ",";
+ }
+ out( outstr);
+ segs++;
+ }
+ }
+
+ var prologue = "";
+ prologue += ("// Gradient palette \"" + nom + "\", originally from\n");
+ prologue += ("// " + origurl + "\n");
+ prologue += ("// converted for FastLED with gammas (" + rgamma + ", " + ggamma + ", " + bgamma + ")\n");
+ prologue += ("// Size: " + ((segs)* 4) + " bytes of program space.\n");
+
+ if( segs > 50) {
+ alert("NOTE: this is a BIG one (" + (segs) + " control points, " +((segs) * 4) + " bytes), and some colors may not show.");
+ } else if( segs > 16) {
+ alert("NOTE: >16 control points (" + (segs) + "), some colors may not show.");
+ }
+
+
+ return prologue + "\n" + stdout;
+}
+
+function DoConvert( content)
+{
+ var res = CreateConversion( content);
+ window.prompt("COPY this code, paste into your FastLED sketch:",res);
+
+}
+
+
+
+if( onSite == 0) {
+ var i = document.createElement('iframe');
+ i.id = 'srcframe';
+ i.style.display = 'none';
+ i.onload = function() {
+ var fr = document.getElementById("srcframe");
+ var iframeDocument = fr.contentDocument || fr.contentWindow.document;
+ var content = iframeDocument.body.innerHTML;
+ DoConvert( content);
+ i.parentNode.removeChild(i); };
+
+ i.src = url3;
+ document.body.appendChild(i);
+} else {
+ window.location.href="http://soliton.vm.bytemark.co.uk/pub/cpt-city/";
+}
+cursor_clear();
+//alert(stdout);