/*! * vue2 v1.3.6 * 2022年11月Fri Nov 04 2022 18:18:10 GMT+0800 (中国标准时间) * 制作 (function(_,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","vue-demi"],l):(_=typeof globalThis!="undefined"?globalThis:_||self,l(_.SketchRuler={},_.vueDemi))})(this,function(_,l){"use strict";*/var V=l.defineComponent({name:"LineRuler",props:{scale:Number,thick:Number,palette:Object,index:Number,start:Number,vertical:Boolean,value:Number,isShowReferLine:Boolean},emits:["onMouseDown","onRelease","onRemove"],setup(e,{emit:n}){const t=l.ref(0),i=l.ref(!0);l.onMounted(()=>{t.value=e.value});const s=o=>{i.value=o>=0},d=l.computed(()=>{const o=(t.value-e.start)*e.scale;s(o);const h=o+"px";return e.vertical?{top:h}:{left:h}}),u=l.computed(()=>{var f;const o=`1px solid ${(f=e.palette)==null?void 0:f.lineColor}`,h=e.vertical?{borderTop:o}:{borderLeft:o};return{cursor:e.isShowReferLine?e.vertical?"ns-resize":"ew-resize":"none",...h}}),v=l.computed(()=>e.vertical?{left:e.thick+"px"}:{top:e.thick+"px"});return{startValue:t,showLine:i,offset:d,borderCursor:u,actionStyle:v,handleDown:o=>{const h=e.vertical?o.clientY:o.clientX,c=t.value;n("onMouseDown");const f=b=>{const p=e.vertical?b.clientY:b.clientX,R=Math.round(c+(p-h)/e.scale);t.value=R},g=()=>{n("onRelease",t.value,e.index),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",g)},handleRemove:()=>{n("onRemove",e.index)}}}}),X=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{directives:[{name:"show",rawName:"v-show",value:e.showLine,expression:"showLine"}],staticClass:"line",style:[e.offset,e.borderCursor],on:{mousedown:e.handleDown}},[t("div",{staticClass:"action",style:e.actionStyle},[t("span",{staticClass:"del",on:{click:e.handleRemove}},[e._v("\xD7")]),t("span",{staticClass:"value"},[e._v(e._s(e.startValue))])])])},I=[],he=(()=>`.line[data-v-1672e414]{pointer-events:auto;position:absolute}.line .action[data-v-1672e414]{position:absolute;display:flex;justify-content:center;align-items:center}.line .value[data-v-1672e414]{pointer-events:none;transform:scale(.83)}.line .del[data-v-1672e414]{padding:3px 5px;cursor:pointer;visibility:hidden}.line:hover .del[data-v-1672e414]{visibility:visible} `)();function y(e,n,t,i,s,d,u,v){var r=typeof e=="function"?e.options:e;n&&(r.render=n,r.staticRenderFns=t,r._compiled=!0),i&&(r.functional=!0),d&&(r._scopeId="data-v-"+d);var a;if(u?(a=function(c){c=c||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!c&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(c=__VUE_SSR_CONTEXT__),s&&s.call(this,c),c&&c._registeredComponents&&c._registeredComponents.add(u)},r._ssrRegister=a):s&&(a=v?function(){s.call(this,(r.functional?this.parent:this).$root.$options.shadowRoot)}:s),a)if(r.functional){r._injectStyles=a;var o=r.render;r.render=function(f,g){return a.call(g),o(f,g)}}else{var h=r.beforeCreate;r.beforeCreate=h?[].concat(h,a):[a]}return{exports:e,options:r}}const S={};var $=y(V,X,I,!1,F,"1672e414",null,null);function F(e){for(let n in S)this[n]=S[n]}var M=function(){return $.exports}();const Q=e=>e<=.25?40:e<=.5?20:e<=1?10:e<=2?5:e<=4?2:1,N=.83,z=(e,n,t,i,s,d)=>{const{scale:u,width:v,height:r,ratio:a,palette:o}=s,{bgColor:h,fontColor:c,shadowColor:f,longfgColor:g,shortfgColor:b}=o;if(e.scale(a,a),e.clearRect(0,0,v,r),e.fillStyle=h,e.fillRect(0,0,v,r),i){const w=(t-n)*u,C=i*u;e.fillStyle=f,d?e.fillRect(w,0,C,r*3/8):e.fillRect(0,w,v*3/8,C)}const p=Q(u),R=p*u,A=p*10,k=A*u,U=Math.floor(n/p)*p,O=Math.floor(n/A)*A,ue=(U-n)/p*R,de=(O-n)/A*k,T=n+Math.ceil((d?v:r)/u);e.beginPath(),e.fillStyle=c,e.strokeStyle=g;for(let w=O,C=0;w{i=e.ratio||window.devicePixelRatio||1,d(),u(i),v(i)});const d=()=>{t.canvasContext=s.value&&s.value.getContext("2d")},u=a=>{if(s.value){s.value.width=e.width*a,s.value.height=e.height*a;const o=t.canvasContext;o&&(o.font=`${12*a}px -apple-system, "Helvetica Neue", ".SFNSText-Regular", "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Zen Hei", sans-serif`,o.lineWidth=1,o.textBaseline="middle")}},v=a=>{const o={scale:e.scale,width:e.width,height:e.height,palette:e.palette,ratio:a};t.canvasContext&&z(t.canvasContext,e.start,e.selectStart,e.selectLength,o,!e.vertical)};return l.watch(()=>e.start,()=>v(i)),l.watch([()=>e.width,()=>e.height],()=>{u(i),v(i)}),{handle:(a,o)=>{const h=(g,b,p)=>Math.round(b+g/p),c=e.vertical?a.offsetY:a.offsetX,f=h(c,e.start,e.scale);switch(o){case"click":n("onAddLine",f);break;case"enter":n("update:valueNum",f),n("update:showIndicator",!0);break;default:n("update:valueNum",f);break}},canvas:s}}}),Y=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("canvas",{ref:"canvas",staticClass:"ruler",on:{click:function(i){return e.handle(i,"click")},mouseenter:function(i){return e.handle(i,"enter")},mousemove:function(i){return e.handle(i,"move")},mouseleave:function(i){return e.$emit("update:showIndicator",!1)}}})},P=[];const E={};var W=y(K,Y,P,!1,q,null,null,null);function q(e){for(let n in E)this[n]=E[n]}var G=function(){return W.exports}();const H={scale:Number,ratio:Number,thick:Number,palette:Object,vertical:{type:Boolean,default:!0},width:{type:Number,default:200},height:{type:Number,default:200},start:{type:Number,default:0},lines:{type:Array,default:()=>[]},selectStart:{type:Number},selectLength:{type:Number},isShowReferLine:{type:Boolean}};var j=l.defineComponent({name:"RulerWrapper",components:{CanvasRuler:G,RulerLine:M},props:H,setup(e){const n=l.ref(!1),t=l.ref(0),i=l.computed(()=>e.vertical?"v-container":"h-container"),s=l.computed(()=>{const a={width:`calc(100% - ${e.thick}px)`,height:`${e.thick+1}px`,left:`${e.thick}px`},o={width:`${e.thick&&e.thick+1}px`,height:`calc(100% - ${e.thick}px)`,top:`${e.thick}px`};return e.vertical?o:a}),d=l.computed(()=>{var c;const a=(t.value-e.start)*e.scale;let o="top",h="borderLeft";return o=e.vertical?"top":"left",h=e.vertical?"borderBottom":"borderLeft",{[o]:a+"px",[h]:`1px solid ${(c=e.palette)==null?void 0:c.lineColor}`}}),u=a=>{e.lines.push(a)},v=(a,o)=>{const h=a-e.start,c=(e.vertical?e.height:e.width)/e.scale;h<0||h>c?r(o):e.lines[o]=a},r=a=>{e.lines.splice(a,1)};return{showIndicator:n,valueNum:t,rwClassName:i,rwStyle:s,indicatorStyle:d,handleNewLine:u,handleLineRelease:v,handleLineRemove:r}}}),Z=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{class:e.rwClassName,style:e.rwStyle},[t("CanvasRuler",{attrs:{vertical:e.vertical,scale:e.scale,width:e.width,height:e.height,start:e.start,ratio:e.ratio,"select-start":e.selectStart,"select-length":e.selectLength,palette:e.palette},on:{onAddLine:e.handleNewLine},model:{value:e.showIndicator,callback:function(i){e.showIndicator=i},expression:"showIndicator"}}),t("div",{directives:[{name:"show",rawName:"v-show",value:e.isShowReferLine,expression:"isShowReferLine"}],staticClass:"lines"},e._l(e.lines,function(i,s){return t("RulerLine",{key:i+s,attrs:{index:s,value:i>>0,scale:e.scale,start:e.start,thick:e.thick,palette:e.palette,vertical:e.vertical,"is-show-refer-line":e.isShowReferLine},on:{onRemove:e.handleLineRemove,onRelease:e.handleLineRelease}})}),1),t("div",{directives:[{name:"show",rawName:"v-show",value:e.showIndicator,expression:"showIndicator"}],staticClass:"indicator",style:e.indicatorStyle},[t("div",{staticClass:"value"},[e._v(e._s(e.valueNum))])])],1)},D=[],ve=(()=>`.line[data-v-042af537],.h-container[data-v-042af537],.v-container[data-v-042af537]{position:absolute}.h-container .lines[data-v-042af537],.v-container .lines[data-v-042af537]{pointer-events:none}.h-container:hover .lines[data-v-042af537],.v-container:hover .lines[data-v-042af537]{pointer-events:auto}.h-container[data-v-042af537]{top:0}.h-container .line[data-v-042af537]{top:0;height:100vh;padding-left:5px}.h-container .line .action[data-v-042af537]{transform:translate(-24px)}.h-container .line .action .value[data-v-042af537]{margin-left:4px}.h-container .indicator[data-v-042af537]{top:0;height:100vw}.h-container .indicator .value[data-v-042af537]{width:auto;padding:0 2px;margin-top:4px;margin-left:4px}.v-container[data-v-042af537]{left:0}.v-container .line[data-v-042af537]{left:0;width:100vw;padding-top:5px}.v-container .line .action[data-v-042af537]{transform:translateY(-24px);flex-direction:column}.v-container .line .action .value[data-v-042af537]{margin-top:4px}.v-container .indicator[data-v-042af537]{width:100vw}.v-container .indicator .value[data-v-042af537]{left:0;width:auto;padding:0 2px;margin-top:-5px;margin-left:2px;transform:rotate(-90deg);transform-origin:0 0} `)();const x={};var J=y(j,Z,D,!1,ee,"042af537",null,null);function ee(e){for(let n in x)this[n]=x[n]}var te=function(){return J.exports}();const ne="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAAAXNSR0IArs4c6QAAAopJREFUOE/FlE9IVEEcx7+/N9ouds1Mu0QUSFZYdIgoUqQoKPBQHsKozpXE7jbTO/U8xLJvn6usBHWQ6hBFXupSkQeVbh0KJEPp0sH+eLGTsKs77xcj78m0ax0E8cHjzZv5zef3/c33xxA24KENYGJzoEEQbNNaN4Zh2OQ4znwYhr9c1/39vwrXVDo0NNS0tLR0GYB5D64BmAMwzMyvlFKz1es10Hw+f4mZ7wHYBeA9gNdENFepVOaEEM3M3OI4Thczn41gt6WUgQ3+C+r7/h0AWQD3mXnYqPA8L9nQ0HCemduIaFpKOWoAhUJhT6VSuQXgOjP3K6W8GLwKzeVyp4jonR0QBEErM48w8zFLyayUsjX+z+VyHhHdZebTSqkxM78CHRgYOKS1/ghgVErZY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abVqsh3a2h+x1h5qQjNrae/yE4+iaCwDJkky73neTuBZe129Xk+H+BS4l7ZqLVIZ2BhzuFKpvMsDVXXWGPMxFdAedOfcKeCRqj7MYrUhpz09PfXl5eXrectFWXXODQHpOq2qd/95o/JXr6ura3J1dXU6SZIfwKKIHAD2tVYMPBGRx77vN10UXtO85fTkmZmZHUtLSzUR2QXsBhaAL6r6DXhbrVYXi1yss59GqOgub/bN3Z7v6X/tb9Zmp/q/kN8s+lJb8oEAAAAASUVORK5CYII=",oe={eyeIcon:{type:String},closeEyeIcon:{type:String},scale:{type:Number,default:1},ratio:{type:Number},thick:{type:Number,default:16},palette:Object,startX:{type:Number},startY:{type:Number,default:0},width:{type:Number,default:200},height:{type:Number,default:200},shadow:{type:Object,default:()=>({x:0,y:0,width:0,height:0})},lines:{type:Object,default:()=>({h:[],v:[]})},isShowReferLine:{type:Boolean,default:!0}};var re=l.defineComponent({name:"SketchRule",components:{RulerWrapper:te},props:oe,emits:["onCornerClick"],setup(e,{emit:n}){let t=l.ref(!0);t.value=e.isShowReferLine;const i=l.computed(()=>{function u(r,a){return Object.keys(r).forEach(o=>{o&&r.hasOwnProperty(o)&&(typeof a.key=="object"?r[o]=u(r[o],a[o]):a.hasOwnProperty(o)&&(r[o]=a[o]))}),r}return u({bgColor:"rgba(225,225,225, 0)",longfgColor:"#BABBBC",shortfgColor:"#C8CDD0",fontColor:"#7D8694",shadowColor:"#E8E8E8",lineColor:"#EB5648",borderColor:"#DADADC",cornerActiveColor:"rgb(235, 86, 72, 0.6)",menu:{bgColor:"#fff",dividerColor:"#DBDBDB",listItem:{textColor:"#415058",hoverTextColor:"#298DF8",disabledTextColor:"rgba(65, 80, 88, 0.4)",bgColor:"#fff",hoverBgColor:"#F2F2F2"}}},e.palette||{})}),s=l.computed(()=>({backgroundImage:t.value?`url(${e.eyeIcon||ne})`:`url(${e.closeEyeIcon||ae})`,width:e.thick+"px",height:e.thick+"px",borderRight:`1px solid ${i.value.borderColor}`,borderBottom:`1px solid ${i.value.borderColor}`})),d=u=>{t.value=!t.value,n("onCornerClick",t.value)};return l.watch([()=>e.isShowReferLine],()=>{t.value=e.isShowReferLine}),{showReferLine:t,paletteCpu:i,cornerStyle:s,onCornerClick:d}}}),ie=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{staticClass:"style-ruler mb-ruler",attrs:{id:"mb-ruler"}},[t("RulerWrapper",{attrs:{vertical:!1,width:e.width,height:e.thick,"is-show-refer-line":e.showReferLine,thick:e.thick,ratio:e.ratio,start:e.startX,lines:e.lines.h,"select-start":e.shadow.x,"select-length":e.shadow.width,scale:e.scale,palette:e.paletteCpu}}),t("RulerWrapper",{attrs:{vertical:!0,width:e.thick,height:e.height,"is-show-refer-line":e.showReferLine,thick:e.thick,ratio:e.ratio,start:e.startY,lines:e.lines.v,"select-start":e.shadow.y,"select-length":e.shadow.height,scale:e.scale,palette:e.paletteCpu}}),t("a",{staticClass:"corner",style:e.cornerStyle,on:{click:e.onCornerClick}})],1)},le=[],fe=(()=>`@charset "UTF-8";.style-ruler{position:absolute;z-index:3;width:100%;height:100%;overflow:hidden;font-size:12px;pointer-events:none}.style-ruler span{line-height:1}.corner{position:absolute;top:0;left:0;pointer-events:auto;cursor:pointer;box-sizing:content-box;transition:all .2s ease-in-out}.indicator{position:absolute;pointer-events:none}.indicator .value{position:absolute;background:white}.ruler{width:100%;height:100%;pointer-events:auto} `)();const B={};var se=y(re,ie,le,!1,ce,null,null,null);function ce(e){for(let n in B)this[n]=B[n]}var L=function(){return se.exports}();_.SketchRule=L,_.default=L,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});