From 20d56f61434bdf77db711a3562de4c50cf2b103c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 6 Mar 2021 19:44:12 +0000 Subject: [PATCH] chore(release): 1.5.0 [skip ci] # [1.5.0](https://github.com/seleb/sketch-to-lineart/compare/v1.4.1...v1.5.0) (2021-03-06) ### Bug Fixes * `lang` placed on `head` instead of `html` ([61f9965](https://github.com/seleb/sketch-to-lineart/commit/61f9965b8503a65c65077a435c94e86f1cc6324a)) * add `lang` to `html` ([0c3a266](https://github.com/seleb/sketch-to-lineart/commit/0c3a2662d5aa50f01e963040c506c88db24267b9)) * add alt text to source image ([39aa03f](https://github.com/seleb/sketch-to-lineart/commit/39aa03f33a8305fc754f5c8b9efc266044bbd94a)) * add description meta ([b60613d](https://github.com/seleb/sketch-to-lineart/commit/b60613da874535c4eefc61c78eeb9a720b2dbccb)) * add opengraph metadata ([2eaf350](https://github.com/seleb/sketch-to-lineart/commit/2eaf350a3e1cf9ea373a3ab0b3dbeebcbdf5ed99)) * add robots meta ([872b2e8](https://github.com/seleb/sketch-to-lineart/commit/872b2e88dcdada733b844f519ba074792e15fac6)) * add structured metadata ([950ee8e](https://github.com/seleb/sketch-to-lineart/commit/950ee8ecba39aadbf1c149206818a453a9f60730)) * add viewport meta ([52e1ec6](https://github.com/seleb/sketch-to-lineart/commit/52e1ec6dbd943c109088af76cc5b3ca216673197)) * allow buttons to wrap in modal nav ([47e7b59](https://github.com/seleb/sketch-to-lineart/commit/47e7b59a3bbb12828323926348ceb476b03e86d9)) * better header style on mobile ([96ec723](https://github.com/seleb/sketch-to-lineart/commit/96ec72399f41181d6c9cf051d5f371de38d63a53)) * hide source image when no source set ([ac958fe](https://github.com/seleb/sketch-to-lineart/commit/ac958fecd6ac6242498bfa0af676611fb09c1bf6)) * include `dialog-polyfill` for non-chrome ([7589fe2](https://github.com/seleb/sketch-to-lineart/commit/7589fe2bddf04d5736d18c747f693ac42319ce9a)) * only close modal if it has focus ([e166f43](https://github.com/seleb/sketch-to-lineart/commit/e166f430734c524867b0f3e77c3b26ba85ceb372)) * render modals into `body` ([ba3a309](https://github.com/seleb/sketch-to-lineart/commit/ba3a309a04c5b6b98d027877a16bf865bed6e477)) * update preact ([ed372ba](https://github.com/seleb/sketch-to-lineart/commit/ed372ba98ddad050c1512c920eb148b0380f2f05)) * use native `dialog` element ([7fcc48e](https://github.com/seleb/sketch-to-lineart/commit/7fcc48e806816f4faca6a40ca0c0fc824de8e456)) ### Features * close modals with escape key ([42c4507](https://github.com/seleb/sketch-to-lineart/commit/42c450774a0479f2e81a391fc2bbb0c32fe1f93c)) * include aria attributes in modals ([8146d71](https://github.com/seleb/sketch-to-lineart/commit/8146d711dd9703489cee961b2fd7e752432bc21f)) * include labels for modals ([8890b14](https://github.com/seleb/sketch-to-lineart/commit/8890b14e0c52a544d7a2226030cdab1a00695fbe)) --- CHANGELOG.md | 29 +++++++++++++++++++++ docs/app.6b359d69.js | 25 ------------------ docs/app.aec504c6.js | 31 +++++++++++++++++++++++ docs/index.html | 2 +- docs/{src.83272fb2.js => src.0c7b0e7f.js} | 2 +- docs/src.47b32491.css | 1 + docs/src.92dfdd89.css | 1 - package-lock.json | 2 +- package.json | 2 +- 9 files changed, 65 insertions(+), 30 deletions(-) delete mode 100644 docs/app.6b359d69.js create mode 100644 docs/app.aec504c6.js rename docs/{src.83272fb2.js => src.0c7b0e7f.js} (99%) create mode 100644 docs/src.47b32491.css delete mode 100644 docs/src.92dfdd89.css diff --git a/CHANGELOG.md b/CHANGELOG.md index a0110f8..456b696 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,32 @@ +# [1.5.0](https://github.com/seleb/sketch-to-lineart/compare/v1.4.1...v1.5.0) (2021-03-06) + + +### Bug Fixes + +* `lang` placed on `head` instead of `html` ([61f9965](https://github.com/seleb/sketch-to-lineart/commit/61f9965b8503a65c65077a435c94e86f1cc6324a)) +* add `lang` to `html` ([0c3a266](https://github.com/seleb/sketch-to-lineart/commit/0c3a2662d5aa50f01e963040c506c88db24267b9)) +* add alt text to source image ([39aa03f](https://github.com/seleb/sketch-to-lineart/commit/39aa03f33a8305fc754f5c8b9efc266044bbd94a)) +* add description meta ([b60613d](https://github.com/seleb/sketch-to-lineart/commit/b60613da874535c4eefc61c78eeb9a720b2dbccb)) +* add opengraph metadata ([2eaf350](https://github.com/seleb/sketch-to-lineart/commit/2eaf350a3e1cf9ea373a3ab0b3dbeebcbdf5ed99)) +* add robots meta ([872b2e8](https://github.com/seleb/sketch-to-lineart/commit/872b2e88dcdada733b844f519ba074792e15fac6)) +* add structured metadata ([950ee8e](https://github.com/seleb/sketch-to-lineart/commit/950ee8ecba39aadbf1c149206818a453a9f60730)) +* add viewport meta ([52e1ec6](https://github.com/seleb/sketch-to-lineart/commit/52e1ec6dbd943c109088af76cc5b3ca216673197)) +* allow buttons to wrap in modal nav ([47e7b59](https://github.com/seleb/sketch-to-lineart/commit/47e7b59a3bbb12828323926348ceb476b03e86d9)) +* better header style on mobile ([96ec723](https://github.com/seleb/sketch-to-lineart/commit/96ec72399f41181d6c9cf051d5f371de38d63a53)) +* hide source image when no source set ([ac958fe](https://github.com/seleb/sketch-to-lineart/commit/ac958fecd6ac6242498bfa0af676611fb09c1bf6)) +* include `dialog-polyfill` for non-chrome ([7589fe2](https://github.com/seleb/sketch-to-lineart/commit/7589fe2bddf04d5736d18c747f693ac42319ce9a)) +* only close modal if it has focus ([e166f43](https://github.com/seleb/sketch-to-lineart/commit/e166f430734c524867b0f3e77c3b26ba85ceb372)) +* render modals into `body` ([ba3a309](https://github.com/seleb/sketch-to-lineart/commit/ba3a309a04c5b6b98d027877a16bf865bed6e477)) +* update preact ([ed372ba](https://github.com/seleb/sketch-to-lineart/commit/ed372ba98ddad050c1512c920eb148b0380f2f05)) +* use native `dialog` element ([7fcc48e](https://github.com/seleb/sketch-to-lineart/commit/7fcc48e806816f4faca6a40ca0c0fc824de8e456)) + + +### Features + +* close modals with escape key ([42c4507](https://github.com/seleb/sketch-to-lineart/commit/42c450774a0479f2e81a391fc2bbb0c32fe1f93c)) +* include aria attributes in modals ([8146d71](https://github.com/seleb/sketch-to-lineart/commit/8146d711dd9703489cee961b2fd7e752432bc21f)) +* include labels for modals ([8890b14](https://github.com/seleb/sketch-to-lineart/commit/8890b14e0c52a544d7a2226030cdab1a00695fbe)) + ## [1.4.1](https://github.com/seleb/sketch-to-lineart/compare/v1.4.0...v1.4.1) (2021-01-18) diff --git a/docs/app.6b359d69.js b/docs/app.6b359d69.js deleted file mode 100644 index 28a81d9..0000000 --- a/docs/app.6b359d69.js +++ /dev/null @@ -1,25 +0,0 @@ -parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c3)for(n=[n],o=3;o0?a(g.type,g.props,g.key,null,g.__v):g)){if(g.__=n,g.__b=n.__b+1,null===(m=S[d])||m&&g.key==m.key&&g.type===m.type)S[d]=void 0;else for(v=0;v3)for(n=[n],o=3;o>>16,61!==r[1]&&(a[b++]=B>>>8),61!==r[0]&&(a[b++]=B),f=0));return a};e&&(o=new e([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])),!n||s.toBlob&&s.toBlobHD||(s.toBlob||(s.toBlob=function(t,o){if(o||(o="image/png"),this.mozGetAsFile)t(this.mozGetAsFile("canvas",o));else if(this.msToBlob&&/^\s*image\/png\s*(?:$|;)/i.test(o))t(this.msToBlob());else{var n,s=Array.prototype.slice.call(arguments,1),b=this[a].apply(this,s),r=b.indexOf(","),f=b.substring(r+1),B=i.test(b.substring(0,r));Blob.fake?((n=new Blob).encoding=B?"base64":"URI",n.data=f,n.size=f.length):e&&(n=B?new Blob([l(f)],{type:o}):new Blob([decodeURIComponent(f)],{type:o})),t(n)}}),!s.toBlobHD&&s.toDataURLHD?s.toBlobHD=function(){a="toDataURLHD";var t=this.toBlob();return a="toDataURL",t}:s.toBlobHD=s.toBlob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this); -},{}],"i0aF":[function(require,module,exports) { -var define; -var global = arguments[3]; -var e,t=arguments[3];!function(t,n){"function"==typeof e&&e.amd?e([],n):"undefined"!=typeof exports?n():(n(),t.FileSaver={})}(this,function(){"use strict";function e(e,t,n){var o=new XMLHttpRequest;o.open("GET",e),o.responseType="blob",o.onload=function(){r(o.response,t,n)},o.onerror=function(){console.error("could not download file")},o.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(e){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof t&&t.global===t?t:void 0,i=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),r=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(t,i,r){var s=a.URL||a.webkitURL,c=document.createElement("a");i=i||t.name||"download",c.download=i,c.rel="noopener","string"==typeof t?(c.href=t,c.origin===location.origin?o(c):n(c.href)?e(t,i,r):o(c,c.target="_blank")):(c.href=s.createObjectURL(t),setTimeout(function(){s.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(t,a,i){if(a=a||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(t,i),a);else if(n(t))e(t,a,i);else{var r=document.createElement("a");r.href=t,r.target="_blank",setTimeout(function(){o(r)})}}:function(t,n,o,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof t)return e(t,n,o);var s="application/octet-stream"===t.type,c=/constructor/i.test(a.HTMLElement)||a.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||s&&c||i)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=l?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},u.readAsDataURL(t)}else{var f=a.URL||a.webkitURL,d=f.createObjectURL(t);r?r.location=d:location.href=d,r=null,setTimeout(function(){f.revokeObjectURL(d)},4e4)}});a.saveAs=r.saveAs=r,"undefined"!=typeof module&&(module.exports=r)}); -},{}],"qsmZ":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useState=p,exports.useReducer=h,exports.useEffect=v,exports.useLayoutEffect=l,exports.useRef=m,exports.useImperativeHandle=H,exports.useMemo=d,exports.useCallback=x,exports.useContext=y,exports.useDebugValue=E,exports.useErrorBoundary=b;var _,n,t,o=require("preact"),e=0,u=[],r=o.options.__b,i=o.options.__r,c=o.options.diffed,s=o.options.__c,f=o.options.unmount;function a(_,t){o.options.__h&&o.options.__h(n,_,e||t),e=0;var u=n.__H||(n.__H={__:[],__h:[]});return _>=u.__.length&&u.__.push({}),u.__[_]}function p(_){return e=1,h(C,_)}function h(t,o,e){var u=a(_++,2);return u.t=t,u.__c||(u.__=[e?e(o):C(void 0,o),function(_){var n=u.t(u.__[0],_);u.__[0]!==n&&(u.__=[n,u.__[1]],u.__c.setState({}))}],u.__c=n),u.__}function v(t,e){var u=a(_++,3);!o.options.__s&&F(u.__H,e)&&(u.__=t,u.__H=e,n.__H.__h.push(u))}function l(t,e){var u=a(_++,4);!o.options.__s&&F(u.__H,e)&&(u.__=t,u.__H=e,n.__h.push(u))}function m(_){return e=5,d(function(){return{current:_}},[])}function H(_,n,t){e=6,l(function(){"function"==typeof _?_(n()):_&&(_.current=n())},null==t?t:t.concat(_))}function d(n,t){var o=a(_++,7);return F(o.__H,t)&&(o.__=n(),o.__H=t,o.__h=n),o.__}function x(_,n){return e=8,d(function(){return _},n)}function y(t){var o=n.context[t.__c],e=a(_++,9);return e.__c=t,o?(null==e.__&&(e.__=!0,o.sub(n)),o.props.value):t.__}function E(_,n){o.options.useDebugValue&&o.options.useDebugValue(n?n(_):_)}function b(t){var o=a(_++,10),e=p();return o.__=t,n.componentDidCatch||(n.componentDidCatch=function(_){o.__&&o.__(_),e[1](_)}),[e[0],function(){e[1](void 0)}]}function g(){u.forEach(function(_){if(_.__P)try{_.__H.__h.forEach(A),_.__H.__h.forEach(D),_.__H.__h=[]}catch(n){_.__H.__h=[],o.options.__e(n,_.__v)}}),u=[]}o.options.__b=function(_){n=null,r&&r(_)},o.options.__r=function(t){i&&i(t),_=0;var o=(n=t.__c).__H;o&&(o.__h.forEach(A),o.__h.forEach(D),o.__h=[])},o.options.diffed=function(_){c&&c(_);var e=_.__c;e&&e.__H&&e.__H.__h.length&&(1!==u.push(e)&&t===o.options.requestAnimationFrame||((t=o.options.requestAnimationFrame)||function(_){var n,t=function(){clearTimeout(o),q&&cancelAnimationFrame(n),setTimeout(_)},o=setTimeout(t,100);q&&(n=requestAnimationFrame(t))})(g)),n=void 0},o.options.__c=function(_,n){n.some(function(_){try{_.__h.forEach(A),_.__h=_.__h.filter(function(_){return!_.__||D(_)})}catch(t){n.some(function(_){_.__h&&(_.__h=[])}),n=[],o.options.__e(t,_.__v)}}),s&&s(_,n)},o.options.unmount=function(_){f&&f(_);var n=_.__c;if(n&&n.__H)try{n.__H.__.forEach(A)}catch(_){o.options.__e(_,n.__v)}};var q="function"==typeof requestAnimationFrame;function A(_){var t=n;"function"==typeof _.__c&&_.__c(),n=t}function D(_){var t=n;_.__c=_.__(),n=t}function F(_,n){return!_||_.length!==n.length||n.some(function(n,t){return n!==_[t]})}function C(_,n){return"function"==typeof n?n(_):n} -},{"preact":"u8ui"}],"ZN2e":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("preact/jsx-runtime"),t=require("preact");function i(e,t){if(null==e)return{};var i,n,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i])}return o}function r(e,t){if(null==e)return{};var i,r,n={},o=Object.keys(e);for(r=0;r=0||(n[i]=e[i]);return n}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var i=0;i0?t[0]:"object"===n(t)&&t.ideal?t.ideal:null};MediaStreamTrack.getSources(function(e){var n=null,a=null;e.forEach(function(e){"audio"===e.kind?n=e.id:"video"===e.kind&&(a=e.id)});var s=o(t.audioConstraints);s&&(n=s);var u=o(t.videoConstraints);u&&(a=u),i(r(n),r(a))})}}},{key:"handleUserMedia",value:function(e,t){var i=this.props;if(e||!t)return this.setState({hasUserMedia:!1}),void i.onUserMediaError(e);this.stream=t;try{this.video&&(this.video.srcObject=t),this.setState({hasUserMedia:!0})}catch(r){this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(t)})}}},{key:"render",value:function(){var t=this,r=this.state,n=this.props,o=n.audio,a=(n.forceScreenshotSourceSize,n.onUserMedia,n.onUserMediaError,n.screenshotFormat,n.screenshotQuality,n.minScreenshotWidth,n.minScreenshotHeight,n.audioConstraints,n.videoConstraints,n.imageSmoothing,n.mirrored),s=i(n,["audio","forceScreenshotSourceSize","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored"]),u=a?{transform:"scaleX(-1)"}:void 0;return(0,e.jsx)("video",Object.assign({autoPlay:!0,src:r.src,muted:o,playsInline:!0,ref:function(e){t.video=e},style:u},s),void 0)}}],[{key:"stopMediaStream",value:function(e){e&&(e.getVideoTracks&&e.getAudioTracks?(e.getVideoTracks().map(function(e){return e.stop()}),e.getAudioTracks().map(function(e){return e.stop()})):e.stop())}}]),c}();exports.default=m; -},{"preact/jsx-runtime":"I8Gw","preact":"u8ui"}],"cgfr":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Capture=i;var e=require("preact/jsx-runtime"),r=require("preact/hooks"),t=n(require("./Webcam"));function n(e){return e&&e.__esModule?e:{default:e}}var o={facingMode:"environment"};function i(n){var i=n.onCapture,s=(0,r.useRef)(),a=(0,r.useCallback)(function(){i(s.current.getScreenshot())},[]),c=(0,r.useCallback)(function(){i("")},[]);return(0,e.jsxs)("div",Object.assign({className:"modal"},{children:[(0,e.jsx)(t.default,{audio:!1,ref:s,screenshotFormat:"image/jpeg",onUserMediaError:alert,videoConstraints:o,forceScreenshotSourceSize:!0},void 0),(0,e.jsxs)("nav",{children:[(0,e.jsx)("button",Object.assign({type:"button",onClick:a},{children:"Save"}),void 0),(0,e.jsx)("button",Object.assign({type:"button",onClick:c},{children:"Cancel"}),void 0)]},void 0)]}),void 0)} -},{"preact/jsx-runtime":"I8Gw","preact/hooks":"qsmZ","./Webcam":"ZN2e"}],"wp4r":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sortNumeric=r,exports.hexToRgb=t,exports.rgbToLuma=u,exports.useCheckbox=n,exports.useRange=o;var e=require("preact/hooks");function r(e,r){return e-r}function t(e){var r=parseInt(e.replace("#","0x"));return[(r>>16&255)/255,(r>>8&255)/255,(255&r)/255]}function u(e,r,t){return.2126*e+.7152*r+.0722*t}function n(r){return(0,e.useCallback)(function(e){r(e.currentTarget.checked)},[r])}function o(r){return(0,e.useCallback)(function(e){r(parseFloat(e.currentTarget.value))},[r])} -},{"preact/hooks":"qsmZ"}],"hN9c":[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cutout=s;var e=require("preact/jsx-runtime"),t=require("preact/hooks"),r=require("./utils");function n(e,t){return a(e)||c(e,t)||u(e,t)||i()}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r 0.0) {\n\t\tv = mix(0.0, contrast, v);\n\t} else {\n\t\tv = 0.0;\n\t}\n\tv = clamp(v, 0.0, 1.0);\n\tif (threshold <= 1.0) {\n\t\tv = step(threshold, v);\n\t}\n\tgl_FragColor = vec4(fill, v);\n}\n"),y=new Float32Array([-1,-1,1,-1,-1,1,1,-1,1,1,-1,1]),w=x.createBuffer();x.bindBuffer(x.ARRAY_BUFFER,w),x.bufferData(x.ARRAY_BUFFER,y,x.STATIC_DRAW);var C={position:x.getAttribLocation(j.program,"position"),tex0:x.getUniformLocation(j.program,"tex0"),resolution:x.getUniformLocation(j.program,"resolution"),brightness:x.getUniformLocation(j.program,"brightness"),contrast:x.getUniformLocation(j.program,"contrast"),threshold:x.getUniformLocation(j.program,"threshold"),fill:x.getUniformLocation(j.program,"fill")};x.enableVertexAttribArray(C.position),j.useProgram(),x.vertexAttribPointer(C.position,2,x.FLOAT,!1,0,0),x.clearColor(0,0,0,0),x.uniform1i(C.tex0,0);var A=new a.Texture(new Image,0,!1);function O(){x.drawArrays(x.TRIANGLES,0,y.length/2)}function k(){O(),b.toBlob(e.saveAs)}function F(){var e=c((0,n.useState)(1),2),r=e[0],a=e[1],u=c((0,n.useState)(1),2),s=u[0],d=u[1],f=c((0,n.useState)(!1),2),h=f[0],v=f[1],p=c((0,n.useState)(.5),2),j=p[0],y=p[1],w=c((0,n.useState)(""),2),F=w[0],S=w[1],R=c((0,n.useState)("#000000"),2),I=R[0],q=R[1],E=c((0,n.useState)(!0),2),T=E[0],L=E[1],U=(0,n.useRef)(),M=(0,n.useCallback)(function(t){var e,r;if(null===(r=null===(e=t.currentTarget)||void 0===e?void 0:e.files)||void 0===r?void 0:r[0]){var n=new FileReader;n.onload=function(){var t,e;S(null!==(e=null===(t=n.result)||void 0===t?void 0:t.toString())&&void 0!==e?e:"")},n.readAsDataURL(t.currentTarget.files[0])}},[]);(0,n.useEffect)(function(){if(T){var t=new Image;t.onload=function(){g.width=Math.min(t.naturalWidth,256),g.height=Math.min(t.naturalHeight,256),m.clearRect(0,0,g.width,g.height),m.filter="grayscale() invert()",m.drawImage(t,0,0,t.naturalWidth,t.naturalHeight,0,0,g.width,g.height);var e=m.getImageData(0,0,g.width,g.height),r=e.data.filter(function(t,r){return r%4==0&&0!==e.data[r+3]});r.sort(l.sortNumeric);var n=r[Math.floor(r.length/2)]/255,i=Math.sqrt(r.reduce(function(t,e){return t+Math.pow(e/255-n,2)},0)/r.length),o=parseFloat((n+i/2).toFixed(3)),u=parseFloat((1/i).toFixed(3));o==o&&o!==1/0&&o!==-1/0||(o=0),u==u&&u!==1/0&&u!==-1/0||(u=1),a(o),d(u)},t.src=F}},[F,T]),(0,n.useEffect)(function(){x.uniform1f(C.brightness,r),O()},[r]),(0,n.useEffect)(function(){x.uniform1f(C.contrast,s),O()},[s]),(0,n.useEffect)(function(){x.uniform1f(C.threshold,h?j:1/0),O()},[j,h]),(0,n.useEffect)(function(){var t=(0,l.hexToRgb)(I);x.uniform3f(C.fill,t[0],t[1],t[2]),O()},[I]),(0,n.useEffect)(function(){var t=new Image;t.onerror=t.onload=function(){b.width=t.naturalWidth,b.height=t.naturalHeight,x.viewport(0,0,b.width,b.height),x.uniform2f(C.resolution,b.width,b.height),A.source=t,A.update(),A.bind(),O()},t.src=F},[F]),(0,n.useEffect)(function(){var t;null===(t=document.querySelector("#output-img"))||void 0===t||t.appendChild(b)},[]);var D=(0,n.useCallback)(function(){S(""),O(),document.querySelector("#source-file").value=""},[]),P=c((0,n.useState)(!1),2),_=P[0],B=P[1],W=(0,n.useCallback)(function(){return B(!0)},[]),H=(0,n.useCallback)(function(t){t&&S(t),B(!1)},[]),N=c((0,n.useState)(!1),2),Y=N[0],G=N[1],V=(0,n.useCallback)(function(){return G(!0)},[]),$=(0,n.useCallback)(function(t){t&&S(t),G(!1)},[]),z=(0,l.useCheckbox)(L),J=(0,l.useRange)(a),K=(0,l.useRange)(d),Q=(0,l.useCheckbox)(v),X=(0,l.useRange)(y),Z=(0,n.useCallback)(function(t){q(t.currentTarget.value)},[]);return(0,t.jsxs)("main",{children:[(0,t.jsx)("h1",{children:"sketch-to-lineart"},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"source-file"},{children:"source:"}),void 0),(0,t.jsxs)("ul",{children:[(0,t.jsx)("li",{children:(0,t.jsx)("input",{id:"source-file",type:"file",accept:"image/*",onChange:M},void 0)},void 0),(0,t.jsx)("li",{children:(0,t.jsx)("button",Object.assign({type:"button",onClick:W},{children:"Take photo"}),void 0)},void 0)]},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"auto",title:"Automatically set brightness/contrast"},{children:"auto:"}),void 0),(0,t.jsx)("input",{id:"auto",title:"Automatically set brightness/contrast",type:"checkbox",checked:T,onChange:z},void 0),!T&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("label",Object.assign({htmlFor:"brightness"},{children:"brightness:"}),void 0),(0,t.jsx)("input",{disabled:T,id:"brightness",type:"range",min:0,max:5,step:.001,value:r,"data-value":r,onInput:J},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"contrast"},{children:"contrast:"}),void 0),(0,t.jsx)("input",{disabled:T,id:"contrast",type:"range",min:1,max:10,step:.001,value:s,"data-value":s,onInput:K},void 0)]},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"use-threshold",title:"Output is fully opaque/fully transparent, with no partially transparent pixels"},{children:"use threshold:"}),void 0),(0,t.jsx)("input",{id:"use-threshold",title:"Output is fully opaque/fully transparent, with no partially transparent pixels",type:"checkbox",checked:h,onChange:Q},void 0),h&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("label",Object.assign({htmlFor:"threshold"},{children:"threshold:"}),void 0),(0,t.jsx)("input",{disabled:!h,id:"threshold",type:"range",min:0,max:1,step:.001,value:j,"data-value":j,onInput:X},void 0)]},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"fill"},{children:"fill:"}),void 0),(0,t.jsx)("input",{id:"fill",type:"color",value:I,onInput:Z},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsxs)("figure",{children:[(0,t.jsxs)("figcaption",{children:["original"," ",(0,t.jsxs)("div",{children:[(0,t.jsx)("button",Object.assign({disabled:!F,type:"button",onClick:V},{children:"cutout"}),void 0),(0,t.jsx)("button",Object.assign({disabled:!F,type:"button",onClick:D},{children:"clear"}),void 0)]},void 0)]},void 0),(0,t.jsx)("img",{id:"source-img",src:F,ref:U},void 0)]},void 0),(0,t.jsxs)("figure",{children:[(0,t.jsxs)("figcaption",{children:["output"," ",(0,t.jsx)("button",Object.assign({type:"button",onClick:k},{children:"save"}),void 0)]},void 0),(0,t.jsx)("div",{id:"output-img",className:l.rgbToLuma.apply(void 0,(0,l.hexToRgb)(I))>.5?"invert":""},void 0)]},void 0),_&&(0,t.jsx)(i.Capture,{onCapture:H},void 0),Y&&(0,t.jsx)(o.Cutout,{srcInput:F,onCutout:$},void 0)]},void 0)}(0,r.render)((0,t.jsx)(F,{},void 0),document.body); -},{"preact/jsx-runtime":"I8Gw","canvas-toBlob":"EQlm","file-saver":"i0aF","preact":"u8ui","preact/hooks":"qsmZ","./Capture":"cgfr","./Cutout":"hN9c","./gl":"fbLS","./utils":"wp4r"}]},{},["mo85"], null) \ No newline at end of file diff --git a/docs/app.aec504c6.js b/docs/app.aec504c6.js new file mode 100644 index 0000000..19e93a1 --- /dev/null +++ b/docs/app.aec504c6.js @@ -0,0 +1,31 @@ +parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c3)for(t=[t],o=3;o0?f(m.type,m.props,m.key,null,m.__v):m)){if(m.__=t,m.__b=t.__b+1,null===(y=P[a])||y&&m.key==y.key&&m.type===y.type)P[a]=void 0;else for(h=0;h3)for(t=[t],o=3;o>>16,61!==r[1]&&(a[b++]=B>>>8),61!==r[0]&&(a[b++]=B),f=0));return a};e&&(o=new e([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])),!n||s.toBlob&&s.toBlobHD||(s.toBlob||(s.toBlob=function(t,o){if(o||(o="image/png"),this.mozGetAsFile)t(this.mozGetAsFile("canvas",o));else if(this.msToBlob&&/^\s*image\/png\s*(?:$|;)/i.test(o))t(this.msToBlob());else{var n,s=Array.prototype.slice.call(arguments,1),b=this[a].apply(this,s),r=b.indexOf(","),f=b.substring(r+1),B=i.test(b.substring(0,r));Blob.fake?((n=new Blob).encoding=B?"base64":"URI",n.data=f,n.size=f.length):e&&(n=B?new Blob([l(f)],{type:o}):new Blob([decodeURIComponent(f)],{type:o})),t(n)}}),!s.toBlobHD&&s.toDataURLHD?s.toBlobHD=function(){a="toDataURLHD";var t=this.toBlob();return a="toDataURL",t}:s.toBlobHD=s.toBlob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this); +},{}],"i0aF":[function(require,module,exports) { +var define; +var global = arguments[3]; +var e,t=arguments[3];!function(t,n){"function"==typeof e&&e.amd?e([],n):"undefined"!=typeof exports?n():(n(),t.FileSaver={})}(this,function(){"use strict";function e(e,t,n){var o=new XMLHttpRequest;o.open("GET",e),o.responseType="blob",o.onload=function(){r(o.response,t,n)},o.onerror=function(){console.error("could not download file")},o.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(e){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(n)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof t&&t.global===t?t:void 0,i=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),r=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(t,i,r){var s=a.URL||a.webkitURL,c=document.createElement("a");i=i||t.name||"download",c.download=i,c.rel="noopener","string"==typeof t?(c.href=t,c.origin===location.origin?o(c):n(c.href)?e(t,i,r):o(c,c.target="_blank")):(c.href=s.createObjectURL(t),setTimeout(function(){s.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(t,a,i){if(a=a||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(t,i),a);else if(n(t))e(t,a,i);else{var r=document.createElement("a");r.href=t,r.target="_blank",setTimeout(function(){o(r)})}}:function(t,n,o,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof t)return e(t,n,o);var s="application/octet-stream"===t.type,c=/constructor/i.test(a.HTMLElement)||a.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||s&&c||i)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=l?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},u.readAsDataURL(t)}else{var f=a.URL||a.webkitURL,d=f.createObjectURL(t);r?r.location=d:location.href=d,r=null,setTimeout(function(){f.revokeObjectURL(d)},4e4)}});a.saveAs=r.saveAs=r,"undefined"!=typeof module&&(module.exports=r)}); +},{}],"qsmZ":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useState=p,exports.useReducer=h,exports.useEffect=v,exports.useLayoutEffect=l,exports.useRef=m,exports.useImperativeHandle=H,exports.useMemo=d,exports.useCallback=x,exports.useContext=y,exports.useDebugValue=E,exports.useErrorBoundary=b;var _,n,t,o=require("preact"),e=0,u=[],r=o.options.__b,i=o.options.__r,c=o.options.diffed,s=o.options.__c,f=o.options.unmount;function a(_,t){o.options.__h&&o.options.__h(n,_,e||t),e=0;var u=n.__H||(n.__H={__:[],__h:[]});return _>=u.__.length&&u.__.push({}),u.__[_]}function p(_){return e=1,h(C,_)}function h(t,o,e){var u=a(_++,2);return u.t=t,u.__c||(u.__=[e?e(o):C(void 0,o),function(_){var n=u.t(u.__[0],_);u.__[0]!==n&&(u.__=[n,u.__[1]],u.__c.setState({}))}],u.__c=n),u.__}function v(t,e){var u=a(_++,3);!o.options.__s&&F(u.__H,e)&&(u.__=t,u.__H=e,n.__H.__h.push(u))}function l(t,e){var u=a(_++,4);!o.options.__s&&F(u.__H,e)&&(u.__=t,u.__H=e,n.__h.push(u))}function m(_){return e=5,d(function(){return{current:_}},[])}function H(_,n,t){e=6,l(function(){"function"==typeof _?_(n()):_&&(_.current=n())},null==t?t:t.concat(_))}function d(n,t){var o=a(_++,7);return F(o.__H,t)&&(o.__=n(),o.__H=t,o.__h=n),o.__}function x(_,n){return e=8,d(function(){return _},n)}function y(t){var o=n.context[t.__c],e=a(_++,9);return e.__c=t,o?(null==e.__&&(e.__=!0,o.sub(n)),o.props.value):t.__}function E(_,n){o.options.useDebugValue&&o.options.useDebugValue(n?n(_):_)}function b(t){var o=a(_++,10),e=p();return o.__=t,n.componentDidCatch||(n.componentDidCatch=function(_){o.__&&o.__(_),e[1](_)}),[e[0],function(){e[1](void 0)}]}function g(){u.forEach(function(_){if(_.__P)try{_.__H.__h.forEach(A),_.__H.__h.forEach(D),_.__H.__h=[]}catch(n){_.__H.__h=[],o.options.__e(n,_.__v)}}),u=[]}o.options.__b=function(_){n=null,r&&r(_)},o.options.__r=function(t){i&&i(t),_=0;var o=(n=t.__c).__H;o&&(o.__h.forEach(A),o.__h.forEach(D),o.__h=[])},o.options.diffed=function(_){c&&c(_);var e=_.__c;e&&e.__H&&e.__H.__h.length&&(1!==u.push(e)&&t===o.options.requestAnimationFrame||((t=o.options.requestAnimationFrame)||function(_){var n,t=function(){clearTimeout(o),q&&cancelAnimationFrame(n),setTimeout(_)},o=setTimeout(t,100);q&&(n=requestAnimationFrame(t))})(g)),n=void 0},o.options.__c=function(_,n){n.some(function(_){try{_.__h.forEach(A),_.__h=_.__h.filter(function(_){return!_.__||D(_)})}catch(t){n.some(function(_){_.__h&&(_.__h=[])}),n=[],o.options.__e(t,_.__v)}}),s&&s(_,n)},o.options.unmount=function(_){f&&f(_);var n=_.__c;if(n&&n.__H)try{n.__H.__.forEach(A)}catch(_){o.options.__e(_,n.__v)}};var q="function"==typeof requestAnimationFrame;function A(_){var t=n;"function"==typeof _.__c&&_.__c(),n=t}function D(_){var t=n;_.__c=_.__(),n=t}function F(_,n){return!_||_.length!==n.length||n.some(function(n,t){return n!==_[t]})}function C(_,n){return"function"==typeof n?n(_):n} +},{"preact":"u8ui"}],"gT7M":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=window.CustomEvent;function t(e,t){var o="on"+t.type.toLowerCase();return"function"==typeof e[o]&&e[o](t),e.dispatchEvent(t)}function o(e){for(;e&&e!==document.body;){var t=window.getComputedStyle(e),o=function(e,o){return!(void 0===t[e]||t[e]===o)};if(t.opacity<1||o("zIndex","auto")||o("transform","none")||o("mixBlendMode","normal")||o("filter","none")||o("perspective","none")||"isolate"===t.isolation||"fixed"===t.position||"touch"===t.webkitOverflowScrolling)return!0;e=e.parentElement}return!1}function i(e){for(;e;){if("dialog"===e.localName)return e;e=e.parentElement?e.parentElement:e.parentNode?e.parentNode.host:null}return null}function n(e){for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;e&&e.blur&&e!==document.body&&e.blur()}function a(e,t){for(var o=0;o=0&&(e=this.dialog_),e||(e=s(this.dialog_)),n(document.activeElement),e&&e.focus()},updateZIndex:function(e,t){if(e, the polyfill may not work correctly",e),"dialog"!==e.localName)throw new Error("Failed to register dialog: The element is not a dialog.");new c(e)},registerDialog:function(e){e.showModal||h.forceRegisterDialog(e)},DialogManager:function(){this.pendingDialogStack=[];var e=this.checkDOM_.bind(this);this.overlay=document.createElement("div"),this.overlay.className="_dialog_overlay",this.overlay.addEventListener("click",function(t){this.forwardTab_=void 0,t.stopPropagation(),e([])}.bind(this)),this.handleKey_=this.handleKey_.bind(this),this.handleFocus_=this.handleFocus_.bind(this),this.zIndexLow_=1e5,this.zIndexHigh_=100150,this.forwardTab_=void 0,"MutationObserver"in window&&(this.mo_=new MutationObserver(function(t){var o=[];t.forEach(function(e){for(var t,i=0;t=e.removedNodes[i];++i)t instanceof Element&&("dialog"===t.localName&&o.push(t),o=o.concat(t.querySelectorAll("dialog")))}),o.length&&e(o)}))}};if(h.DialogManager.prototype.blockDocument=function(){document.documentElement.addEventListener("focus",this.handleFocus_,!0),document.addEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.observe(document,{childList:!0,subtree:!0})},h.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0),document.removeEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.disconnect()},h.DialogManager.prototype.updateStacking=function(){for(var e,t=this.zIndexHigh_,o=0;e=this.pendingDialogStack[o];++o)e.updateZIndex(--t,--t),0===o&&(this.overlay.style.zIndex=--t);var i=this.pendingDialogStack[0];i?(i.dialog.parentNode||document.body).appendChild(this.overlay):this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)},h.DialogManager.prototype.containedByTopDialog_=function(e){for(;e=i(e);){for(var t,o=0;t=this.pendingDialogStack[o];++o)if(t.dialog===e)return 0===o;e=e.parentElement}return!1},h.DialogManager.prototype.handleFocus_=function(e){var t=e.composedPath?e.composedPath()[0]:e.target;if(!this.containedByTopDialog_(t)&&document.activeElement!==document.documentElement&&(e.preventDefault(),e.stopPropagation(),n(t),void 0!==this.forwardTab_)){var o=this.pendingDialogStack[0];return o.dialog.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?o.focus_():t!==document.documentElement&&document.documentElement.focus()),!1}},h.DialogManager.prototype.handleKey_=function(o){if(this.forwardTab_=void 0,27===o.keyCode){o.preventDefault(),o.stopPropagation();var i=new e("cancel",{bubbles:!1,cancelable:!0}),n=this.pendingDialogStack[0];n&&t(n.dialog,i)&&n.dialog.close()}else 9===o.keyCode&&(this.forwardTab_=!o.shiftKey)},h.DialogManager.prototype.checkDOM_=function(e){this.pendingDialogStack.slice().forEach(function(t){-1!==e.indexOf(t.dialog)?t.downgradeModal():t.maybeHideModal()})},h.DialogManager.prototype.pushDialog=function(e){var t=(this.zIndexHigh_-this.zIndexLow_)/2-1;return!(this.pendingDialogStack.length>=t)&&(1===this.pendingDialogStack.unshift(e)&&this.blockDocument(),this.updateStacking(),!0)},h.DialogManager.prototype.removeDialog=function(e){var t=this.pendingDialogStack.indexOf(e);-1!==t&&(this.pendingDialogStack.splice(t,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())},h.dm=new h.DialogManager,h.formSubmitter=null,h.imagemapUseValue=null,void 0===window.HTMLDialogElement){var p=document.createElement("form");if(p.setAttribute("method","dialog"),"dialog"!==p.method){var g=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method");if(g){var m=g.get;g.get=function(){return r(this)?"dialog":m.call(this)};var f=g.set;g.set=function(e){return"string"==typeof e&&"dialog"===e.toLowerCase()?this.setAttribute("method",e):f.call(this,e)},Object.defineProperty(HTMLFormElement.prototype,"method",g)}}document.addEventListener("click",function(e){if(h.formSubmitter=null,h.imagemapUseValue=null,!e.defaultPrevented){var t=e.target;if("composedPath"in e)t=e.composedPath().shift()||t;if(t&&r(t.form)){if(!("submit"===t.type&&["button","input"].indexOf(t.localName)>-1)){if("input"!==t.localName||"image"!==t.type)return;h.imagemapUseValue=e.offsetX+","+e.offsetY}i(t)&&(h.formSubmitter=t)}}},!1),document.addEventListener("submit",function(e){var t=e.target;if(!i(t)){var o=d(e);"dialog"===(o&&o.getAttribute("formmethod")||t.getAttribute("method"))&&e.preventDefault()}});var b=HTMLFormElement.prototype.submit,v=function(){if(!r(this))return b.call(this);var e=i(this);e&&e.close()};HTMLFormElement.prototype.submit=v}var y=h;exports.default=y; +},{}],"oSOp":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={version:!0,Children:!0,render:!0,hydrate:!0,unmountComponentAtNode:!0,createPortal:!0,createFactory:!0,cloneElement:!0,isValidElement:!0,findDOMNode:!0,PureComponent:!0,memo:!0,forwardRef:!0,unstable_batchedUpdates:!0,StrictMode:!0,Suspense:!0,SuspenseList:!0,lazy:!0,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:!0,unstable_ImmediatePriority:!0,unstable_UserBlockingPriority:!0,unstable_NormalPriority:!0,unstable_LowPriority:!0,unstable_IdlePriority:!0,unstable_runWithPriority:!0,unstable_now:!0,createElement:!0,createContext:!0,createRef:!0,Fragment:!0,Component:!0};exports.render=O,exports.hydrate=g,exports.unmountComponentAtNode=Y,exports.createPortal=x,exports.createFactory=$,exports.cloneElement=H,exports.isValidElement=z,exports.findDOMNode=q,exports.PureComponent=i,exports.memo=u,exports.forwardRef=_,exports.Suspense=f,exports.SuspenseList=h,exports.lazy=m,exports.unstable_runWithPriority=j,Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return n.createElement}}),Object.defineProperty(exports,"createContext",{enumerable:!0,get:function(){return n.createContext}}),Object.defineProperty(exports,"createRef",{enumerable:!0,get:function(){return n.createRef}}),Object.defineProperty(exports,"Fragment",{enumerable:!0,get:function(){return n.Fragment}}),Object.defineProperty(exports,"Component",{enumerable:!0,get:function(){return n.Component}}),exports.unstable_now=exports.unstable_IdlePriority=exports.unstable_LowPriority=exports.unstable_NormalPriority=exports.unstable_UserBlockingPriority=exports.unstable_ImmediatePriority=exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=exports.StrictMode=exports.unstable_batchedUpdates=exports.Children=exports.version=exports.default=void 0;var t=require("preact/hooks");Object.keys(t).forEach(function(n){"default"!==n&&"__esModule"!==n&&(Object.prototype.hasOwnProperty.call(e,n)||n in exports&&exports[n]===t[n]||Object.defineProperty(exports,n,{enumerable:!0,get:function(){return t[n]}}))});var n=require("preact");function r(e,t){for(var n in t)e[n]=t[n];return e}function o(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function i(e){this.props=e}function u(e,t){function r(e){var n=this.props.ref,r=n==e.ref;return!r&&n&&(n.call?n(null):n.current=null),t?!t(this.props,e)||!r:o(this.props,e)}function i(t){return this.shouldComponentUpdate=r,(0,n.createElement)(e,t)}return i.displayName="Memo("+(e.displayName||e.name)+")",i.prototype.isReactComponent=!0,i.__f=!0,i}(i.prototype=new n.Component).isPureReactComponent=!0,i.prototype.shouldComponentUpdate=function(e,t){return o(this.props,e)||o(this.state,t)};var l=n.options.__b;n.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),l&&l(e)};var a="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function _(e){function t(t,n){var o=r({},t);return delete o.ref,e(o,(n=t.ref||n)&&("object"!=typeof n||"current"in n)?n:null)}return t.$$typeof=a,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var c=function(e,t){return null==e?null:(0,n.toChildArray)((0,n.toChildArray)(e).map(t))},s={map:c,forEach:c,count:function(e){return e?(0,n.toChildArray)(e).length:0},only:function(e){var t=(0,n.toChildArray)(e);if(1!==t.length)throw"Children.only";return t[0]},toArray:n.toChildArray},p=n.options.__e;function f(){this.__u=0,this.t=null,this.__b=null}function d(e){var t=e.__.__c;return t&&t.__e&&t.__e(e)}function m(e){var t,r,o;function i(i){if(t||(t=e()).then(function(e){r=e.default||e},function(e){o=e}),o)throw o;if(!r)throw t;return(0,n.createElement)(r,i)}return i.displayName="Lazy",i.__f=!0,i}function h(){this.u=null,this.o=null}exports.Children=s,n.options.__e=function(e,t,n){if(e.then)for(var r,o=t;o=o.__;)if((r=o.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);p(e,t,n)},(f.prototype=new n.Component).__c=function(e,t){var n=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(n);var o=d(r.__v),i=!1,u=function(){i||(i=!0,n.componentWillUnmount=n.__c,o?o(l):l())};n.__c=n.componentWillUnmount,n.componentWillUnmount=function(){u(),n.__c&&n.__c()};var l=function(){if(!--r.__u){if(r.state.__e){var e=r.state.__e;r.__v.__k[0]=function e(t,n,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return e(t,n,r)}),t.__c&&t.__c.__P===n&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate()}},a=!0===t.__h;r.__u++||a||r.setState({__e:r.__b=r.__v.__k[0]}),e.then(u,u)},f.prototype.componentWillUnmount=function(){this.t=[]},f.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var o=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=function e(t,n,o){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),t.__c.__H=null),null!=(t=r({},t)).__c&&(t.__c.__P===o&&(t.__c.__P=n),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return e(t,n,o)})),t}(this.__b,o,i.__O=i.__P)}this.__b=null}var u=t.__e&&(0,n.createElement)(n.Fragment,null,e.fallback);return u&&(u.__h=null),[(0,n.createElement)(n.Fragment,null,t.__e?null:e.children),u]};var y=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]>>1,1),t.i.removeChild(e)}}),(0,n.render)((0,n.createElement)(v,{context:t.context},e.__v),t.l)):t.l&&t.componentWillUnmount()}function x(e,t){return(0,n.createElement)(b,{__v:e,i:t})}(h.prototype=new n.Component).__e=function(e){var t=this,n=d(t.__v),r=t.o.get(e);return r[0]++,function(o){var i=function(){t.props.revealOrder?(r.push(o),y(t,e,r)):o()};n?n(i):i()}},h.prototype.render=function(e){this.u=null,this.o=new Map;var t=(0,n.toChildArray)(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var r=t.length;r--;)this.o.set(t[r],this.u=[1,0,this.u]);return e.children},h.prototype.componentDidUpdate=h.prototype.componentDidMount=function(){var e=this;this.o.forEach(function(t,n){y(e,n,t)})};var C="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,E=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,P=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(e)};function O(e,t,r){return null==t.__k&&(t.textContent=""),(0,n.render)(e,t),"function"==typeof r&&r(),e?e.__c:null}function g(e,t,r){return(0,n.hydrate)(e,t),"function"==typeof r&&r(),e?e.__c:null}n.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(n.Component.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var N=n.options.event;function R(){}function S(){return this.cancelBubble}function U(){return this.defaultPrevented}n.options.event=function(e){return N&&(e=N(e)),e.persist=R,e.isPropagationStopped=S,e.isDefaultPrevented=U,e.nativeEvent=e};var k,w={configurable:!0,get:function(){return this.class}},L=n.options.vnode;n.options.vnode=function(e){var t=e.type,r=e.props,o=r;if("string"==typeof t){for(var i in o={},r){var u=r[i];"value"===i&&"defaultValue"in r&&null==u||("defaultValue"===i&&"value"in r&&null==r.value?i="value":"download"===i&&!0===u?u="":/ondoubleclick/i.test(i)?i="ondblclick":/^onchange(textarea|input)/i.test(i+t)&&!P(r.type)?i="oninput":/^on(Ani|Tra|Tou|BeforeInp)/.test(i)?i=i.toLowerCase():E.test(i)?i=i.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===u&&(u=void 0),o[i]=u)}"select"==t&&o.multiple&&Array.isArray(o.value)&&(o.value=(0,n.toChildArray)(r.children).forEach(function(e){e.props.selected=-1!=o.value.indexOf(e.props.value)})),"select"==t&&null!=o.defaultValue&&(o.value=(0,n.toChildArray)(r.children).forEach(function(e){e.props.selected=o.multiple?-1!=o.defaultValue.indexOf(e.props.value):o.defaultValue==e.props.value})),e.props=o}t&&r.class!=r.className&&(w.enumerable="className"in r,null!=r.className&&(o.class=r.className),Object.defineProperty(o,"className",w)),e.$$typeof=C,L&&L(e)};var A=n.options.__r;n.options.__r=function(e){A&&A(e),k=e.__c};var I={ReactCurrentDispatcher:{current:{readContext:function(e){return k.__n[e.__c].props.value}}}},D=1,F=2,W=3,T=4,M=5;function j(e,t){return t()}exports.unstable_IdlePriority=M,exports.unstable_LowPriority=T,exports.unstable_NormalPriority=W,exports.unstable_UserBlockingPriority=F,exports.unstable_ImmediatePriority=D,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I;var B="object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):function(){return Date.now()},V="16.8.0";function $(e){return n.createElement.bind(null,e)}function z(e){return!!e&&e.$$typeof===C}function H(e){return z(e)?n.cloneElement.apply(null,arguments):e}function Y(e){return!!e.__k&&((0,n.render)(null,e),!0)}function q(e){return e&&(e.base||1===e.nodeType&&e)||null}exports.version=V,exports.unstable_now=B;var Z=function(e,t){return e(t)},G=n.Fragment;exports.StrictMode=G,exports.unstable_batchedUpdates=Z;var J={useState:t.useState,useReducer:t.useReducer,useEffect:t.useEffect,useLayoutEffect:t.useLayoutEffect,useRef:t.useRef,useImperativeHandle:t.useImperativeHandle,useMemo:t.useMemo,useCallback:t.useCallback,useContext:t.useContext,useDebugValue:t.useDebugValue,version:"16.8.0",Children:s,render:O,hydrate:g,unmountComponentAtNode:Y,createPortal:x,createElement:n.createElement,createContext:n.createContext,createFactory:$,cloneElement:H,createRef:n.createRef,Fragment:n.Fragment,isValidElement:z,findDOMNode:q,Component:n.Component,PureComponent:i,memo:u,forwardRef:_,unstable_batchedUpdates:Z,StrictMode:n.Fragment,Suspense:f,SuspenseList:h,lazy:m,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:I};exports.default=J; +},{"preact/hooks":"qsmZ","preact":"u8ui"}],"PxFf":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Modal=u;var e=require("preact/jsx-runtime"),r=n(require("dialog-polyfill")),t=require("preact/compat"),o=require("preact/hooks");function n(e){return e&&e.__esModule?e:{default:e}}function l(e,r){if(null==e)return{};var t,o,n=i(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}function i(e,r){if(null==e)return{};var t,o,n={},l=Object.keys(e);for(o=0;o=0||(n[t]=e[t]);return n}function u(n){var i=n.children,u=n.close,a=l(n,["children","close"]),c=(0,o.useRef)();return(0,o.useEffect)(function(){var e=c.current;e&&(r.default.registerDialog(e),e.showModal(),e.addEventListener("close",u))},[u]),(0,t.createPortal)((0,e.jsx)("dialog",Object.assign({ref:c,"aria-modal":!0},a,{children:i}),void 0),document.body)} +},{"preact/jsx-runtime":"I8Gw","dialog-polyfill":"gT7M","preact/compat":"oSOp","preact/hooks":"qsmZ"}],"ZN2e":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("preact/jsx-runtime"),t=require("preact");function i(e,t){if(null==e)return{};var i,n,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i])}return o}function r(e,t){if(null==e)return{};var i,r,n={},o=Object.keys(e);for(r=0;r=0||(n[i]=e[i]);return n}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var i=0;i0?t[0]:"object"===n(t)&&t.ideal?t.ideal:null};MediaStreamTrack.getSources(function(e){var n=null,a=null;e.forEach(function(e){"audio"===e.kind?n=e.id:"video"===e.kind&&(a=e.id)});var s=o(t.audioConstraints);s&&(n=s);var u=o(t.videoConstraints);u&&(a=u),i(r(n),r(a))})}}},{key:"handleUserMedia",value:function(e,t){var i=this.props;if(e||!t)return this.setState({hasUserMedia:!1}),void i.onUserMediaError(e);this.stream=t;try{this.video&&(this.video.srcObject=t),this.setState({hasUserMedia:!0})}catch(r){this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(t)})}}},{key:"render",value:function(){var t=this,r=this.state,n=this.props,o=n.audio,a=(n.forceScreenshotSourceSize,n.onUserMedia,n.onUserMediaError,n.screenshotFormat,n.screenshotQuality,n.minScreenshotWidth,n.minScreenshotHeight,n.audioConstraints,n.videoConstraints,n.imageSmoothing,n.mirrored),s=i(n,["audio","forceScreenshotSourceSize","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored"]),u=a?{transform:"scaleX(-1)"}:void 0;return(0,e.jsx)("video",Object.assign({autoPlay:!0,src:r.src,muted:o,playsInline:!0,ref:function(e){t.video=e},style:u},s),void 0)}}],[{key:"stopMediaStream",value:function(e){e&&(e.getVideoTracks&&e.getAudioTracks?(e.getVideoTracks().map(function(e){return e.stop()}),e.getAudioTracks().map(function(e){return e.stop()})):e.stop())}}]),c}();exports.default=m; +},{"preact/jsx-runtime":"I8Gw","preact":"u8ui"}],"cgfr":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Capture=a;var e=require("preact/jsx-runtime"),t=require("preact/hooks"),r=require("./Modal"),o=n(require("./Webcam"));function n(e){return e&&e.__esModule?e:{default:e}}var i={facingMode:"environment"};function a(n){var a=n.onCapture,s=(0,t.useRef)(),c=(0,t.useCallback)(function(){a(s.current.getScreenshot())},[]),u=(0,t.useCallback)(function(){a("")},[]);return(0,e.jsxs)(r.Modal,Object.assign({close:u,"aria-labelled-by":"capture-modal-title"},{children:[(0,e.jsx)("h2",Object.assign({id:"capture-modal-title"},{children:"Take photo"}),void 0),(0,e.jsx)(o.default,{audio:!1,ref:s,screenshotFormat:"image/jpeg",onUserMediaError:alert,videoConstraints:i,forceScreenshotSourceSize:!0},void 0),(0,e.jsxs)("nav",{children:[(0,e.jsx)("button",Object.assign({type:"button",onClick:c},{children:"Save"}),void 0),(0,e.jsx)("button",Object.assign({type:"button",onClick:u},{children:"Cancel"}),void 0)]},void 0)]}),void 0)} +},{"preact/jsx-runtime":"I8Gw","preact/hooks":"qsmZ","./Modal":"PxFf","./Webcam":"ZN2e"}],"wp4r":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sortNumeric=r,exports.hexToRgb=t,exports.rgbToLuma=u,exports.useCheckbox=n,exports.useRange=o;var e=require("preact/hooks");function r(e,r){return e-r}function t(e){var r=parseInt(e.replace("#","0x"));return[(r>>16&255)/255,(r>>8&255)/255,(255&r)/255]}function u(e,r,t){return.2126*e+.7152*r+.0722*t}function n(r){return(0,e.useCallback)(function(e){r(e.currentTarget.checked)},[r])}function o(r){return(0,e.useCallback)(function(e){r(parseFloat(e.currentTarget.value))},[r])} +},{"preact/hooks":"qsmZ"}],"hN9c":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Cutout=s;var e=require("preact/jsx-runtime"),t=require("preact/hooks"),r=require("./Modal"),n=require("./utils");function i(e,t){return l(e)||c(e,t)||o(e,t)||u()}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r 0.0) {\n\t\tv = mix(0.0, contrast, v);\n\t} else {\n\t\tv = 0.0;\n\t}\n\tv = clamp(v, 0.0, 1.0);\n\tif (threshold <= 1.0) {\n\t\tv = step(threshold, v);\n\t}\n\tgl_FragColor = vec4(fill, v);\n}\n"),y=new Float32Array([-1,-1,1,-1,-1,1,1,-1,1,1,-1,1]),w=x.createBuffer();x.bindBuffer(x.ARRAY_BUFFER,w),x.bufferData(x.ARRAY_BUFFER,y,x.STATIC_DRAW);var C={position:x.getAttribLocation(j.program,"position"),tex0:x.getUniformLocation(j.program,"tex0"),resolution:x.getUniformLocation(j.program,"resolution"),brightness:x.getUniformLocation(j.program,"brightness"),contrast:x.getUniformLocation(j.program,"contrast"),threshold:x.getUniformLocation(j.program,"threshold"),fill:x.getUniformLocation(j.program,"fill")};x.enableVertexAttribArray(C.position),j.useProgram(),x.vertexAttribPointer(C.position,2,x.FLOAT,!1,0,0),x.clearColor(0,0,0,0),x.uniform1i(C.tex0,0);var A=new a.Texture(new Image,0,!1);function O(){x.drawArrays(x.TRIANGLES,0,y.length/2)}function k(){O(),b.toBlob(e.saveAs)}function F(){var e=c((0,n.useState)(1),2),r=e[0],a=e[1],u=c((0,n.useState)(1),2),s=u[0],d=u[1],f=c((0,n.useState)(!1),2),h=f[0],v=f[1],p=c((0,n.useState)(.5),2),j=p[0],y=p[1],w=c((0,n.useState)(""),2),F=w[0],S=w[1],R=c((0,n.useState)("#000000"),2),I=R[0],q=R[1],E=c((0,n.useState)(!0),2),T=E[0],L=E[1],U=(0,n.useRef)(),M=(0,n.useCallback)(function(t){var e,r;if(null===(r=null===(e=t.currentTarget)||void 0===e?void 0:e.files)||void 0===r?void 0:r[0]){var n=new FileReader;n.onload=function(){var t,e;S(null!==(e=null===(t=n.result)||void 0===t?void 0:t.toString())&&void 0!==e?e:"")},n.readAsDataURL(t.currentTarget.files[0])}},[]);(0,n.useEffect)(function(){if(T){var t=new Image;t.onload=function(){g.width=Math.min(t.naturalWidth,256),g.height=Math.min(t.naturalHeight,256),m.clearRect(0,0,g.width,g.height),m.filter="grayscale() invert()",m.drawImage(t,0,0,t.naturalWidth,t.naturalHeight,0,0,g.width,g.height);var e=m.getImageData(0,0,g.width,g.height),r=e.data.filter(function(t,r){return r%4==0&&0!==e.data[r+3]});r.sort(l.sortNumeric);var n=r[Math.floor(r.length/2)]/255,i=Math.sqrt(r.reduce(function(t,e){return t+Math.pow(e/255-n,2)},0)/r.length),o=parseFloat((n+i/2).toFixed(3)),u=parseFloat((1/i).toFixed(3));o==o&&o!==1/0&&o!==-1/0||(o=0),u==u&&u!==1/0&&u!==-1/0||(u=1),a(o),d(u)},t.src=F}},[F,T]),(0,n.useEffect)(function(){x.uniform1f(C.brightness,r),O()},[r]),(0,n.useEffect)(function(){x.uniform1f(C.contrast,s),O()},[s]),(0,n.useEffect)(function(){x.uniform1f(C.threshold,h?j:1/0),O()},[j,h]),(0,n.useEffect)(function(){var t=(0,l.hexToRgb)(I);x.uniform3f(C.fill,t[0],t[1],t[2]),O()},[I]),(0,n.useEffect)(function(){var t=new Image;t.onerror=t.onload=function(){b.width=t.naturalWidth,b.height=t.naturalHeight,x.viewport(0,0,b.width,b.height),x.uniform2f(C.resolution,b.width,b.height),A.source=t,A.update(),A.bind(),O()},t.src=F},[F]),(0,n.useEffect)(function(){var t;null===(t=document.querySelector("#output-img"))||void 0===t||t.appendChild(b)},[]);var D=(0,n.useCallback)(function(){S(""),O(),document.querySelector("#source-file").value=""},[]),P=c((0,n.useState)(!1),2),_=P[0],B=P[1],W=(0,n.useCallback)(function(){return B(!0)},[]),H=(0,n.useCallback)(function(t){t&&S(t),B(!1)},[]),N=c((0,n.useState)(!1),2),Y=N[0],G=N[1],V=(0,n.useCallback)(function(){return G(!0)},[]),$=(0,n.useCallback)(function(t){t&&S(t),G(!1)},[]),z=(0,l.useCheckbox)(L),J=(0,l.useRange)(a),K=(0,l.useRange)(d),Q=(0,l.useCheckbox)(v),X=(0,l.useRange)(y),Z=(0,n.useCallback)(function(t){q(t.currentTarget.value)},[]);return(0,t.jsxs)("main",{children:[(0,t.jsx)("h1",{children:"sketch-to-lineart"},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"source-file"},{children:"source:"}),void 0),(0,t.jsxs)("ul",{children:[(0,t.jsx)("li",{children:(0,t.jsx)("input",{id:"source-file",type:"file",accept:"image/*",onChange:M},void 0)},void 0),(0,t.jsx)("li",{children:(0,t.jsx)("button",Object.assign({type:"button",onClick:W},{children:"Take photo"}),void 0)},void 0)]},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"auto",title:"Automatically set brightness/contrast"},{children:"auto:"}),void 0),(0,t.jsx)("input",{id:"auto",title:"Automatically set brightness/contrast",type:"checkbox",checked:T,onChange:z},void 0),!T&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("label",Object.assign({htmlFor:"brightness"},{children:"brightness:"}),void 0),(0,t.jsx)("input",{disabled:T,id:"brightness",type:"range",min:0,max:5,step:.001,value:r,"data-value":r,onInput:J},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"contrast"},{children:"contrast:"}),void 0),(0,t.jsx)("input",{disabled:T,id:"contrast",type:"range",min:1,max:10,step:.001,value:s,"data-value":s,onInput:K},void 0)]},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"use-threshold",title:"Output is fully opaque/fully transparent, with no partially transparent pixels"},{children:"use threshold:"}),void 0),(0,t.jsx)("input",{id:"use-threshold",title:"Output is fully opaque/fully transparent, with no partially transparent pixels",type:"checkbox",checked:h,onChange:Q},void 0),h&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("label",Object.assign({htmlFor:"threshold"},{children:"threshold:"}),void 0),(0,t.jsx)("input",{disabled:!h,id:"threshold",type:"range",min:0,max:1,step:.001,value:j,"data-value":j,onInput:X},void 0)]},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsx)("label",Object.assign({htmlFor:"fill"},{children:"fill:"}),void 0),(0,t.jsx)("input",{id:"fill",type:"color",value:I,onInput:Z},void 0),(0,t.jsx)("hr",{},void 0),(0,t.jsxs)("figure",{children:[(0,t.jsxs)("figcaption",{children:["original"," ",(0,t.jsxs)("div",{children:[(0,t.jsx)("button",Object.assign({disabled:!F,type:"button",onClick:V},{children:"cutout"}),void 0),(0,t.jsx)("button",Object.assign({disabled:!F,type:"button",onClick:D},{children:"clear"}),void 0)]},void 0)]},void 0),(0,t.jsx)("img",{alt:"Source image",id:"source-img",src:F,ref:U},void 0)]},void 0),(0,t.jsxs)("figure",{children:[(0,t.jsxs)("figcaption",{children:["output"," ",(0,t.jsx)("button",Object.assign({type:"button",onClick:k},{children:"save"}),void 0)]},void 0),(0,t.jsx)("div",{id:"output-img",className:l.rgbToLuma.apply(void 0,(0,l.hexToRgb)(I))>.5?"invert":""},void 0)]},void 0),_&&(0,t.jsx)(i.Capture,{onCapture:H},void 0),Y&&(0,t.jsx)(o.Cutout,{srcInput:F,onCutout:$},void 0)]},void 0)}(0,r.render)((0,t.jsx)(F,{},void 0),document.body); +},{"preact/jsx-runtime":"I8Gw","canvas-toBlob":"EQlm","file-saver":"i0aF","preact":"u8ui","preact/hooks":"qsmZ","./Capture":"cgfr","./Cutout":"hN9c","./gl":"fbLS","./utils":"wp4r"}]},{},["mo85"], null) \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 3fa6dee..89bad50 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1 +1 @@ -sketch-to-lineart \ No newline at end of file +sketch-to-lineart \ No newline at end of file diff --git a/docs/src.83272fb2.js b/docs/src.0c7b0e7f.js similarity index 99% rename from docs/src.83272fb2.js rename to docs/src.0c7b0e7f.js index d128a5d..5740934 100644 --- a/docs/src.83272fb2.js +++ b/docs/src.0c7b0e7f.js @@ -699,7 +699,7 @@ var t=null;function e(){return t||(t=n()),t}function n(){try{throw new Error}cat var r=require("./bundle-url").getBundleURL;function e(r){Array.isArray(r)||(r=[r]);var e=r[r.length-1];try{return Promise.resolve(require(e))}catch(n){if("MODULE_NOT_FOUND"===n.code)return new s(function(n,i){t(r.slice(0,-1)).then(function(){return require(e)}).then(n,i)});throw n}}function t(r){return Promise.all(r.map(u))}var n={};function i(r,e){n[r]=e}module.exports=exports=e,exports.load=t,exports.register=i;var o={};function u(e){var t;if(Array.isArray(e)&&(t=e[1],e=e[0]),o[e])return o[e];var i=(e.substring(e.lastIndexOf(".")+1,e.length)||e).toLowerCase(),u=n[i];return u?o[e]=u(r()+e).then(function(r){return r&&module.bundle.register(t,r),r}).catch(function(r){throw delete o[e],r}):void 0}function s(r){this.executor=r,this.promise=null}s.prototype.then=function(r,e){return null===this.promise&&(this.promise=new Promise(this.executor)),this.promise.then(r,e)},s.prototype.catch=function(r){return null===this.promise&&(this.promise=new Promise(this.executor)),this.promise.catch(r)}; },{"./bundle-url":"MBwg"}],"B6dB":[function(require,module,exports) { "use strict";function e(e,r,n,t,o,i,u){try{var a=e[i](u),c=a.value}catch(s){return void n(s)}a.done?r(c):Promise.resolve(c).then(t,o)}function r(r){return function(){var n=this,t=arguments;return new Promise(function(o,i){var u=r.apply(n,t);function a(r){e(u,o,i,a,c,"next",r)}function c(r){e(u,o,i,a,c,"throw",r)}a(void 0)})}}require("babel-polyfill"),require("reset-css"),require("./style");var n=document.createElement("p");n.innerText="Loading...",document.body.appendChild(n),requestAnimationFrame(r(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,require("_bundle_loader")(require.resolve("./app"));case 3:n.remove(),e.next=10;break;case 6:e.prev=6,e.t0=e.catch(0),document.body.innerHTML="

Something went wrong. Sorry :(

",console.error(e.t0);case 10:case"end":return e.stop()}},e,null,[[0,6]])}))); -},{"babel-polyfill":"JIy0","reset-css":"szrR","./style":"szrR","_bundle_loader":"wl3f","./app":[["app.6b359d69.js","mo85"],"mo85"]}],"PrmA":[function(require,module,exports) { +},{"babel-polyfill":"JIy0","reset-css":"szrR","./style":"szrR","_bundle_loader":"wl3f","./app":[["app.aec504c6.js","mo85"],"mo85"]}],"PrmA":[function(require,module,exports) { module.exports=function(n){return new Promise(function(e,o){var r=document.createElement("script");r.async=!0,r.type="text/javascript",r.charset="utf-8",r.src=n,r.onerror=function(n){r.onerror=r.onload=null,o(n)},r.onload=function(){r.onerror=r.onload=null,e()},document.getElementsByTagName("head")[0].appendChild(r)})}; },{}],0:[function(require,module,exports) { var b=require("wl3f");b.register("js",require("PrmA")); diff --git a/docs/src.47b32491.css b/docs/src.47b32491.css new file mode 100644 index 0000000..4230955 --- /dev/null +++ b/docs/src.47b32491.css @@ -0,0 +1 @@ +a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,main,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section{display:block}[hidden]{display:none}body{line-height:1}menu,ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}table{border-collapse:collapse;border-spacing:0}html{background:#fff;color:#000;font-family:Courier New,Courier,monospace}*{box-sizing:border-box}body{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;padding:1rem;gap:1rem}h1{text-align:initial;font-size:200%;font-weight:700}main{display:grid;grid-template-columns:0fr 1fr;grid-gap:.25rem 1rem;min-height:100%}hr,main{width:100%}hr{grid-column:span 2;margin:0;border:0;border-top:1px solid #bbb}h1{grid-column-start:2}@media screen and (max-width:32rem){h1{grid-column-start:unset;grid-column:span 2;text-align:center;font-size:125%}}label{text-align:right;align-self:center}ul li:not(:last-of-type):after{content:"or"}input[type=file]{width:100%}input[type=range]{position:relative;margin-right:4rem}input[type=range]:after{content:attr(data-value);position:absolute;left:100%;margin-left:.5rem}button:disabled,input:disabled{opacity:.5;cursor:not-allowed}canvas,img,video{border:1px solid #000;max-width:100%;max-height:100%}img[src=""]{display:none}dialog{position:fixed;top:0;left:0;right:0;bottom:0;width:100%;height:100%;background:transparent;border:0;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:1rem}dialog+.backdrop,dialog::backdrop{background:rgba(0,0,0,.8)}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;width:100%;height:100%}dialog h2{color:#fff}dialog video{background:#000;width:100%;height:100%}dialog nav{width:100%;flex:none;display:flex;flex-wrap:wrap}dialog nav button{flex:auto;width:auto}button{width:100%}button,input{font-family:inherit;cursor:pointer;padding:.25rem}#fill{width:auto;padding:0}.invert canvas{background:#000} \ No newline at end of file diff --git a/docs/src.92dfdd89.css b/docs/src.92dfdd89.css deleted file mode 100644 index db66caf..0000000 --- a/docs/src.92dfdd89.css +++ /dev/null @@ -1 +0,0 @@ -a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,main,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section{display:block}[hidden]{display:none}body{line-height:1}menu,ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}table{border-collapse:collapse;border-spacing:0}html{background:#fff;color:#000;font-family:Courier New,Courier,monospace}*{box-sizing:border-box}body{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;padding:1rem;gap:1rem}h1{text-align:initial;font-size:200%;font-weight:700}main{display:grid;grid-template-columns:0fr 1fr;grid-gap:.25rem 1rem;min-height:100%}hr,main{width:100%}hr{grid-column:span 2;margin:0;border:0;border-top:1px solid #bbb}h1{grid-column-start:2}label{text-align:right;align-self:center}ul li:not(:last-of-type):after{content:"or"}input[type=file]{width:100%}input[type=range]{position:relative;margin-right:4rem}input[type=range]:after{content:attr(data-value);position:absolute;left:100%;margin-left:.5rem}button:disabled,input:disabled{opacity:.5;cursor:not-allowed}canvas,img,video{border:1px solid #000;max-width:100%;max-height:100%}.modal{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.8);display:flex;flex-direction:column;justify-content:center;align-items:center;padding:1rem}.modal video{background:#000;width:100%;height:100%}.modal nav{width:100%;flex:none;display:flex}button{width:100%}button,input{font-family:inherit;cursor:pointer;padding:.25rem}#fill{width:auto;padding:0}.invert canvas{background:#000} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5d0b9c8..389c31c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sketch-to-lineart", - "version": "1.4.1", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 46e80e8..25b8ff5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sketch-to-lineart", - "version": "1.4.1", + "version": "1.5.0", "description": "tool for converting sketches to transparent lineart", "main": "index.js", "scripts": {