Skip to content

Commit

Permalink
Deploy to GitHub Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Sep 8, 2024
0 parents commit 98805f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
<script type="module" crossorigin>(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))n(t);new MutationObserver(t=>{for(const r of t)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function s(t){const r={};return t.integrity&&(r.integrity=t.integrity),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?r.credentials="include":t.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(t){if(t.ep)return;t.ep=!0;const r=s(t);fetch(t.href,r)}})();class w{constructor(e){document.addEventListener("paste",s=>{var r;const n=(r=s.clipboardData)==null?void 0:r.items;let t=0;if(console.log("items",n),!n)throw new Error("Error: no items found");for(let i=0;i<n.length;i++){const l=n[i];if(console.log("item",l),l.kind==="file"){console.log("item",l);const m=l.getAsFile(),u=new FileReader;if(u.onload=d=>{var g,p;if(!((g=d.target)!=null&&g.result))throw new Error("Error: file format not supported");e((p=d.target)==null?void 0:p.result)},u.onerror=d=>{throw new Error(`${d}`)},!m)throw new Error("Error: blob was null");u.readAsDataURL(m)}else t++}if(t===n.length)throw new Error("No image/file found")})}}const c=document.createElement("canvas"),f=c.getContext("2d");if(!f)throw new Error("ERROR: 2d context not supported!");new w(o=>{if(typeof o!="string")throw new Error("Error: arraybuffer not supported!");const e=document.createElement("img");e.src=o,e.onload=()=>{console.log("loaded"),c.width=e.width,c.height=e.height,h(f,e,()=>{}),h(f,e,E)}});function h(o,e,s){o.drawImage(e,0,0);const n=o.getImageData(0,0,c.width,c.height);s(n.data),o.putImageData(n,0,0);const t=document.createElement("img");t.src=c.toDataURL(),document.body.prepend(t)}function E(o){for(let e=0;e<o.length;e+=4){const s=o[e]/255,n=o[e+1]/255,t=o[e+2]/255,r=a.YtoLstar(a.rgbToY(s,n,t));o[e]=r*255/100,o[e+1]=r*255/100,o[e+2]=r*255/100}}class a{static rgbToY(e,s,n){return .2126*a.sRGBtoLin(e)+.7152*a.sRGBtoLin(s)+.0722*a.sRGBtoLin(n)}static YtoLstar(e){return e<=.008856?e*903.3:Math.pow(e,1/3)*116-16}static sRGBtoLin(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}}
</script>
<style rel="stylesheet" crossorigin>*,html{padding:0;margin:0;font-family:Arial,Helvetica,sans-serif}img{display:block}#app{display:flex;justify-content:center;padding:2rem}
</style>
</head>

<body>
<div id="app">
<h1><b><i>CTRL+V</i></b> <span style="font-weight: 300;">to convert image to perceived lightness (L*)</span></h1>
</div>
</body>

</html>
1 change: 1 addition & 0 deletions vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98805f2

Please sign in to comment.