2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
var ColorWheel=function(t){"use strict";var e=function(t,e,i,s,a,r,n,o){var h,c=("function"==typeof i?i.options:i)||{};if(c.__file="color-wheel.vue",c.render||(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,a&&(c.functional=!0)),c._scopeId=s,e&&(h=function(t){e.call(this,n(t))}),void 0!==h)if(c.functional){var d=c.render;c.render=function(t,e){return h.call(e),d(t,e)}}else{var l=c.beforeCreate;c.beforeCreate=l?[].concat(l,h):[h]}return c}({render:function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{ref:"color-wheel",staticClass:"cpw_container",class:{s_disabled:t.disabled},style:{width:t.width+"px",height:t.height+"px",position:"relative"},attrs:{id:"color-wheel"}},[i("div",{ref:"farbtastic-solid",staticClass:"farbtastic-solid",staticStyle:{position:"absolute"},style:t.solidStyle}),t._v(" "),i("canvas",{ref:"farbtastic-mask",staticClass:"farbtastic-mask",style:{width:t.width,height:t.height},attrs:{width:t.width,height:t.height}}),t._v(" "),i("canvas",{ref:"farbtastic-overlay",staticClass:"farbtastic-overlay",style:{width:t.width,height:t.height},attrs:{width:t.width,height:t.height},on:{mousedown:t.mousedown,touchstart:t.touchHandleStart,touchmove:t.touchHandleMove,touchend:t.touchHandleEnd}})])},staticRenderFns:[]},function(t){t&&t("data-v-58e7c5c8_0",{source:"\n.s_disabled[data-v-58e7c5c8]{opacity:.5\n}\n.cpw_container[data-v-58e7c5c8]{-webkit-touch-callout:none;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none;tap-highlight-color:transparent;tap-highlight-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none\n}\n.cpw_container .farbtastic-mask[data-v-58e7c5c8]{position:absolute;left:0\n}\n.cpw_container .farbtastic-overlay[data-v-58e7c5c8]{position:absolute;left:0\n}",map:void 0,media:void 0})},{name:"color-wheel",props:{width:{required:!1,type:Number,default:300},height:{required:!1,type:Number,default:300},disabled:{required:!1,type:Boolean,default:!1},startColor:{required:!1,type:String},value:{required:!1,type:String}},mounted:function(){this.hasCamelCaseColorChangeListener&&console.warn("Using the colorChange event is deprecated since version 0.4.0. It will be deleted in version 1.0.0. 'v-model' or the kebab-case variant 'color-change' should be used."),this.initWidget(),this.setColor(this.value||this.startColor||"#000000")},data:function(){return{debug:!1,dragging:!1,circleDrag:!1,color:"",rgb:"",hsl:"",radius:"",square:"",mid:"",markerSize:"",ctxMask:"",ctxOverlay:"",cnvMask:"",cnvOverlay:"",offset:{left:"",top:""}}},watch:{value:function(t,e){t!==e&&this.setColor(t)}},computed:{hasCamelCaseColorChangeListener:function(){return this.$listeners&&this.$listeners.colorChange},solidStyle:function(){return{"background-color":this.pack(this.HSLToRGB([this.hsl[0],1,.5])),width:2*this.square-1+"px",height:2*this.square-1+"px",left:this.mid-this.square+"px",top:this.mid-this.square+"px"}},wheelWidth:function(){return(this.width||300)/10}},methods:{setColor:function(t,e){void 0===e&&(e=!1);var i=this.unpack(t);return this.color!==t&&i&&(this.color=t,this.rgb=i,this.hsl=this.RGBToHSL(this.rgb),this.updateDisplay(e)),this},setHSL:function(t){return this.hsl=t,this.rgb=this.HSLToRGB(t),this.color=this.pack(this.rgb),this.updateDisplay(),this},initWidget:function(){this.radius=(this.width-this.wheelWidth)/2-1,this.square=Math.floor(.7*(this.radius-this.wheelWidth/2))-1,this.mid=Math.floor(this.width/2),this.markerSize=.3*this.wheelWidth,this.cnvMask=this.$refs["farbtastic-mask"],this.ctxMask=this.cnvMask.getContext("2d"),this.cnvOverlay=this.$refs["farbtastic-overlay"],this.ctxOverlay=this.cnvOverlay.getContext("2d"),this.devicePixelRatio=window.devicePixelRatio||1,this.upscaleCanvas(this.cnvMask),this.upscaleCanvas(this.cnvOverlay),this.ctxMask.translate(this.mid,this.mid),this.ctxOverlay.translate(this.mid,this.mid),this.drawCircle(),this.drawMask()},upscaleCanvas:function(t){var e=t.getContext("2d"),i=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStor
|