vue-eyedrop-tool
Version:
Eyedrop tool for vue
2 lines • 14.3 kB
JavaScript
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["eyedrop"]=t(require("vue")):e["eyedrop"]=t(e["Vue"])})("undefined"!==typeof self?self:this,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({"167d":function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a};Object.defineProperty(t,"__esModule",{value:!0});var i=n("60a3"),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.canvas=null,t.pixel=null,t.magnifierGlassStyle={},t.magnifierColorStyle={},t.mouseOver=!1,t}return r(t,e),t.prototype.onImageSourceUpdate=function(e){this.createCanvas(e),this.createMagnifyingGlass(e)},Object.defineProperty(t.prototype,"colorPickerStyle",{get:function(){return{width:this.width,height:this.height}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"label",{get:function(){if(this.pixel){var e=this.pixel[0],t=this.pixel[1],n=this.pixel[2];return"r:"+e+" g:"+t+" b:"+n+" "+u(e,t,n)}return""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showMagnifierColor",{get:function(){return this.pixel&&this.colorLabel&&this.mouseOver},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showMagnifierGlass",{get:function(){return!!this.canvas&&this.mouseOver},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"magnifierColorSquareStyle",{get:function(){return this.pixel?{backgroundColor:"rgb("+this.pixel[0]+","+this.pixel[1]+","+this.pixel[2]+")"}:{}},enumerable:!0,configurable:!0}),t.prototype.mouseleave=function(e){this.mouseOver=!1},t.prototype.mousemove=function(e){this.mouseOver=!0,this.canvas&&(this.pixel=this.canvas.getContext("2d").getImageData(e.offsetX,e.offsetY,1,1).data,this.$emit("color-update",{r:this.pixel[0],g:this.pixel[1],b:this.pixel[2]}),i.Vue.set(this.magnifierGlassStyle,"left",e.pageX-this.magnifierGlassWidth/2+"px"),i.Vue.set(this.magnifierGlassStyle,"top",e.pageY-this.magnifierGlassHeight/2+"px"),i.Vue.set(this.magnifierGlassStyle,"width",this.magnifierGlassWidth+"px"),i.Vue.set(this.magnifierGlassStyle,"height",this.magnifierGlassHeight+"px"),i.Vue.set(this.magnifierColorStyle,"left",e.pageX-this.magnifierGlassWidth/2-100+"px"),i.Vue.set(this.magnifierColorStyle,"top",e.pageY+this.magnifierGlassHeight/2+5+"px"),i.Vue.set(this.magnifierGlassStyle,"backgroundPosition",0-(e.offsetX*this.zoom-this.magnifierGlassWidth/2)+"px "+(0-(e.offsetY*this.zoom-this.magnifierGlassHeight/2))+"px"))},t.prototype.createCanvas=function(e){var t=this,n=document.createElement("canvas");n.width=this.width,n.height=this.height;var r=n.getContext("2d"),o=new Image;o.src=e,o.onload=function(){r.drawImage(o,0,0,t.width,t.height)},this.canvas=n},t.prototype.createMagnifyingGlass=function(e){i.Vue.set(this.magnifierGlassStyle,"backgroundImage","url('"+e+"')"),i.Vue.set(this.magnifierGlassStyle,"backgroundRepeat","no-repeat"),i.Vue.set(this.magnifierGlassStyle,"backgroundSize",this.width*this.zoom+"px "+this.height*this.zoom+"px")},o([i.Prop({default:4,type:Number})],t.prototype,"zoom",void 0),o([i.Prop({default:100,type:Number})],t.prototype,"magnifierGlassWidth",void 0),o([i.Prop({default:100,type:Number})],t.prototype,"magnifierGlassHeight",void 0),o([i.Prop({default:!1,type:Boolean})],t.prototype,"colorLabel",void 0),o([i.Prop({required:!0,type:String})],t.prototype,"src",void 0),o([i.Prop({required:!0,type:Number})],t.prototype,"width",void 0),o([i.Prop({required:!0,type:Number})],t.prototype,"height",void 0),o([i.Prop({required:!0,type:String})],t.prototype,"alt",void 0),o([i.Watch("src",{immediate:!0})],t.prototype,"onImageSourceUpdate",null),t=o([i.Component],t),t}(i.Vue);function u(e,t,n){var r=e.toString(16),o=t.toString(16),i=n.toString(16);return 1===r.length&&(r="0"+r),1===o.length&&(o="0"+o),1===i.length&&(i="0"+i),"#"+r+o+i}t.default=a},"1eb2":function(e,t,n){"use strict";var r;"undefined"!==typeof window&&(n("f6fd"),(r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=r[1]))},2877:function(e,t,n){"use strict";function r(e,t,n,r,o,i,a,u){var c,f="function"===typeof e?e.options:e;if(t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),r&&(f.functional=!0),i&&(f._scopeId="data-v-"+i),a?(c=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(a)},f._ssrRegister=c):o&&(c=u?function(){o.call(this,this.$root.$options.shadowRoot)}:o),c)if(f.functional){f._injectStyles=c;var s=f.render;f.render=function(e,t){return c.call(t),s(e,t)}}else{var p=f.beforeCreate;f.beforeCreate=p?[].concat(p,c):[c]}return{exports:e,options:f}}n.d(t,"a",function(){return r})},"37bd":function(e,t,n){"use strict";var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("img",{attrs:{width:e.width,height:e.height,src:e.src,alt:e.alt},on:{mousemove:e.mousemove,mouseleave:e.mouseleave}}),e.showMagnifierGlass?n("div",{staticClass:"magnifier-glass",style:e.magnifierGlassStyle}):e._e(),e.showMagnifierColor?n("div",{staticClass:"magnifier-color",style:e.magnifierColorStyle},[e._v(e._s(e.label)+"\r\n "),n("div",{staticClass:"magnifier-color-square",style:e.magnifierColorSquareStyle})]):e._e()])},o=[];n.d(t,"a",function(){return r}),n.d(t,"b",function(){return o})},"60a3":function(e,t,n){"use strict";n.r(t);var r=n("8bbf"),o=n.n(r),i="undefined"!==typeof Reflect&&Reflect.defineMetadata&&Reflect.getOwnMetadataKeys;function a(e,t){u(e,t),Object.getOwnPropertyNames(t.prototype).forEach(function(n){u(e.prototype,t.prototype,n)}),Object.getOwnPropertyNames(t).forEach(function(n){u(e,t,n)})}function u(e,t,n){var r=n?Reflect.getOwnMetadataKeys(t,n):Reflect.getOwnMetadataKeys(t);r.forEach(function(r){var o=n?Reflect.getOwnMetadata(r,t,n):Reflect.getOwnMetadata(r,t);n?Reflect.defineMetadata(r,o,e,n):Reflect.defineMetadata(r,o,e)})}var c={__proto__:[]},f=c instanceof Array;function s(e){return function(t,n,r){var o="function"===typeof t?t:t.constructor;o.__decorators__||(o.__decorators__=[]),"number"!==typeof r&&(r=void 0),o.__decorators__.push(function(t){return e(t,n,r)})}}function p(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.a.extend({mixins:e})}function d(e){var t=typeof e;return null==e||"object"!==t&&"function"!==t}function l(e,t){var n=t.prototype._init;t.prototype._init=function(){var t=this,n=Object.getOwnPropertyNames(e);if(e.$options.props)for(var r in e.$options.props)e.hasOwnProperty(r)||n.push(r);n.forEach(function(n){"_"!==n.charAt(0)&&Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){e[n]=t},configurable:!0})})};var r=new t;t.prototype._init=n;var o={};return Object.keys(r).forEach(function(e){void 0!==r[e]&&(o[e]=r[e])}),o}var h=["data","beforeCreate","created","beforeMount","mounted","beforeDestroy","destroyed","beforeUpdate","updated","activated","deactivated","render","errorCaptured","serverPrefetch"];function y(e,t){void 0===t&&(t={}),t.name=t.name||e._componentTag||e.name;var n=e.prototype;Object.getOwnPropertyNames(n).forEach(function(e){if("constructor"!==e)if(h.indexOf(e)>-1)t[e]=n[e];else{var r=Object.getOwnPropertyDescriptor(n,e);void 0!==r.value?"function"===typeof r.value?(t.methods||(t.methods={}))[e]=r.value:(t.mixins||(t.mixins=[])).push({data:function(){var t;return t={},t[e]=r.value,t}}):(r.get||r.set)&&((t.computed||(t.computed={}))[e]={get:r.get,set:r.set})}}),(t.mixins||(t.mixins=[])).push({data:function(){return l(this,e)}});var r=e.__decorators__;r&&(r.forEach(function(e){return e(t)}),delete e.__decorators__);var u=Object.getPrototypeOf(e.prototype),c=u instanceof o.a?u.constructor:o.a,f=c.extend(t);return g(f,e,c),i&&a(f,e),f}var v={prototype:!0,arguments:!0,callee:!0,caller:!0};function g(e,t,n){Object.getOwnPropertyNames(t).forEach(function(r){if(!v[r]){var o=Object.getOwnPropertyDescriptor(e,r);if(!o||o.configurable){var i=Object.getOwnPropertyDescriptor(t,r);if(!f){if("cid"===r)return;var a=Object.getOwnPropertyDescriptor(n,r);if(!d(i.value)&&a&&a.value===i.value)return}0,Object.defineProperty(e,r,i)}}})}function m(e){return"function"===typeof e?y(e):function(t){return y(t,e)}}m.registerHooks=function(e){h.push.apply(h,e)};var b=m;n.d(t,"Inject",function(){return O}),n.d(t,"InjectReactive",function(){return j}),n.d(t,"Provide",function(){return x}),n.d(t,"ProvideReactive",function(){return w}),n.d(t,"Model",function(){return C}),n.d(t,"Prop",function(){return G}),n.d(t,"PropSync",function(){return M}),n.d(t,"Watch",function(){return R}),n.d(t,"Emit",function(){return V}),n.d(t,"Ref",function(){return N}),n.d(t,"Component",function(){return b}),n.d(t,"Vue",function(){return o.a}),n.d(t,"Mixins",function(){return p});var _="__reactiveInject__";function O(e){return s(function(t,n){"undefined"===typeof t.inject&&(t.inject={}),Array.isArray(t.inject)||(t.inject[n]=e||n)})}function j(e){return s(function(t,n){if("undefined"===typeof t.inject&&(t.inject={}),!Array.isArray(t.inject)){var r=e?e.from||e:n,o=!!e&&e.default||void 0;t.computed||(t.computed={}),t.computed[n]=function(){var e=this[_];return e?e[r]:o},t.inject[_]=_}})}function x(e){return s(function(t,n){var r=t.provide;if("function"!==typeof r||!r.managed){var o=t.provide;r=t.provide=function(){var e=Object.create(("function"===typeof o?o.call(this):o)||null);for(var t in r.managed)e[r.managed[t]]=this[t];return e},r.managed={}}r.managed[n]=e||n})}function w(e){return s(function(t,n){var r=t.provide;if("function"!==typeof r||!r.managed){var o=t.provide;r=t.provide=function(){var e=this,t=Object.create(("function"===typeof o?o.call(this):o)||null);t[_]={};var n=function(n){t[r.managed[n]]=i[n],Object.defineProperty(t[_],r.managed[n],{enumerable:!0,get:function(){return e[n]}})},i=this;for(var a in r.managed)n(a);return t},r.managed={}}r.managed[n]=e||n})}var P="undefined"!==typeof Reflect&&"undefined"!==typeof Reflect.getMetadata;function S(e,t,n){P&&(Array.isArray(e)||"function"===typeof e||"undefined"!==typeof e.type||(e.type=Reflect.getMetadata("design:type",t,n)))}function C(e,t){return void 0===t&&(t={}),function(n,r){S(t,n,r),s(function(n,r){(n.props||(n.props={}))[r]=t,n.model={prop:r,event:e||r}})(n,r)}}function G(e){return void 0===e&&(e={}),function(t,n){S(e,t,n),s(function(t,n){(t.props||(t.props={}))[n]=e})(t,n)}}function M(e,t){return void 0===t&&(t={}),function(n,r){S(t,n,r),s(function(n,r){(n.props||(n.props={}))[e]=t,(n.computed||(n.computed={}))[r]={get:function(){return this[e]},set:function(t){this.$emit("update:"+e,t)}}})(n,r)}}function R(e,t){void 0===t&&(t={});var n=t.deep,r=void 0!==n&&n,o=t.immediate,i=void 0!==o&&o;return s(function(t,n){"object"!==typeof t.watch&&(t.watch=Object.create(null));var o=t.watch;"object"!==typeof o[e]||Array.isArray(o[e])?"undefined"===typeof o[e]&&(o[e]=[]):o[e]=[o[e]],o[e].push({handler:n,deep:r,immediate:i})})}var E=/\B([A-Z])/g,$=function(e){return e.replace(E,"-$1").toLowerCase()};function V(e){return function(t,n,r){n=$(n);var o=r.value;r.value=function(){for(var t=this,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=function(o){void 0!==o&&r.unshift(o),t.$emit.apply(t,[e||n].concat(r))},u=o.apply(this,r);return A(u)?u.then(function(e){a(e)}):a(u),u}}}function N(e){return s(function(t,n){t.computed=t.computed||{},t.computed[n]={cache:!1,get:function(){return this.$refs[e||n]}}})}function A(e){return e instanceof Promise||e&&"function"===typeof e.then}},6605:function(e,t,n){"use strict";n.r(t);var r=n("37bd"),o=n("aa5e");for(var i in o)"default"!==i&&function(e){n.d(t,e,function(){return o[e]})}(i);n("9604");var a=n("2877"),u=Object(a["a"])(o["default"],r["a"],r["b"],!1,null,null,null);t["default"]=u.exports},"786d":function(e,t,n){},"8bbf":function(t,n){t.exports=e},9604:function(e,t,n){"use strict";var r=n("786d"),o=n.n(r);o.a},aa5e:function(e,t,n){"use strict";n.r(t);var r=n("167d"),o=n.n(r);for(var i in r)"default"!==i&&function(e){n.d(t,e,function(){return r[e]})}(i);t["default"]=o.a},f6fd:function(e,t){(function(e){var t="currentScript",n=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(r){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.stack)||[!1])[1];for(e in n)if(n[e].src==t||"interactive"==n[e].readyState)return n[e];return null}}})})(document)},fb15:function(e,t,n){"use strict";n.r(t);n("1eb2");var r=n("6605");for(var o in r)"default"!==o&&function(e){n.d(t,e,function(){return r[e]})}(o);t["default"]=r["default"]}})["default"]});
//# sourceMappingURL=eyedrop.umd.min.js.map