Browse Source

still working

kyle 1 year ago
parent
commit
fbb842fe86
1 changed files with 4 additions and 3 deletions
  1. 4 3
      web/index.php

+ 4 - 3
web/index.php

@@ -162,13 +162,14 @@ async function post(url = '', color = '000000') {
     fd.append('color', color);
     return await fetch(url, { method: 'POST', body: fd });
 }
+function sg(x) { return Math.round((x*x)/255); }
 function callback(red, green, blue) {
     console.log('logged', red, green, blue);
     post(
         /* url */ '',
-        red.toString(16).padStart(2,'0') +
-        green.toString(16).padStart(2,'0') +
-        blue.toString(16).padStart(2,'0')
+        sg(red).toString(16).padStart(2,'0') +
+        sg(green).toString(16).padStart(2,'0') +
+        sg(blue).toString(16).padStart(2,'0')
     ).then((data) => { console.log(data, data.text()); });
 }
 canvas.removeEventListener('click', (event) => pick(event, selected));