index.es.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /*!
  2. * vue2 v1.3.6
  3. * 2022年11月Fri Nov 04 2022 18:18:10 GMT+0800 (中国标准时间)
  4. * 制作
  5. */
  6. import { defineComponent, ref, onMounted, computed, reactive, watch } from "vue-demi";
  7. var __vue2_script$3 = defineComponent({
  8. name: "LineRuler",
  9. props: {
  10. scale: Number,
  11. thick: Number,
  12. palette: Object,
  13. index: Number,
  14. start: Number,
  15. vertical: Boolean,
  16. value: Number,
  17. isShowReferLine: Boolean
  18. },
  19. emits: ["onMouseDown", "onRelease", "onRemove"],
  20. setup(props, { emit }) {
  21. const startValue = ref(0);
  22. const showLine = ref(true);
  23. onMounted(() => {
  24. startValue.value = props.value;
  25. });
  26. const setShowLine = (offset2) => {
  27. showLine.value = offset2 >= 0;
  28. };
  29. const offset = computed(() => {
  30. const offset2 = (startValue.value - props.start) * props.scale;
  31. setShowLine(offset2);
  32. const positionValue = offset2 + "px";
  33. const position = props.vertical ? { top: positionValue } : { left: positionValue };
  34. return position;
  35. });
  36. const borderCursor = computed(() => {
  37. var _a;
  38. const borderValue = `1px solid ${(_a = props.palette) == null ? void 0 : _a.lineColor}`;
  39. const border = props.vertical ? { borderTop: borderValue } : { borderLeft: borderValue };
  40. const cursorValue = props.isShowReferLine ? props.vertical ? "ns-resize" : "ew-resize" : "none";
  41. return {
  42. cursor: cursorValue,
  43. ...border
  44. };
  45. });
  46. const actionStyle = computed(() => {
  47. const actionStyle2 = props.vertical ? { left: props.thick + "px" } : { top: props.thick + "px" };
  48. return actionStyle2;
  49. });
  50. const handleDown = (e) => {
  51. const startD = props.vertical ? e.clientY : e.clientX;
  52. const initValue = startValue.value;
  53. emit("onMouseDown");
  54. const onMove = (e2) => {
  55. const currentD = props.vertical ? e2.clientY : e2.clientX;
  56. const newValue = Math.round(initValue + (currentD - startD) / props.scale);
  57. startValue.value = newValue;
  58. };
  59. const onEnd = () => {
  60. emit("onRelease", startValue.value, props.index);
  61. document.removeEventListener("mousemove", onMove);
  62. document.removeEventListener("mouseup", onEnd);
  63. };
  64. document.addEventListener("mousemove", onMove);
  65. document.addEventListener("mouseup", onEnd);
  66. };
  67. const handleRemove = () => {
  68. emit("onRemove", props.index);
  69. };
  70. return {
  71. startValue,
  72. showLine,
  73. offset,
  74. borderCursor,
  75. actionStyle,
  76. handleDown,
  77. handleRemove
  78. };
  79. }
  80. });
  81. var render$3 = function() {
  82. var _vm = this;
  83. var _h = _vm.$createElement;
  84. var _c = _vm._self._c || _h;
  85. return _c("div", {
  86. directives: [{
  87. name: "show",
  88. rawName: "v-show",
  89. value: _vm.showLine,
  90. expression: "showLine"
  91. }],
  92. staticClass: "line",
  93. style: [_vm.offset, _vm.borderCursor],
  94. on: {
  95. "mousedown": _vm.handleDown
  96. }
  97. }, [_c("div", {
  98. staticClass: "action",
  99. style: _vm.actionStyle
  100. }, [_c("span", {
  101. staticClass: "del",
  102. on: {
  103. "click": _vm.handleRemove
  104. }
  105. }, [_vm._v("\xD7")]), _c("span", {
  106. staticClass: "value"
  107. }, [_vm._v(_vm._s(_vm.startValue))])])]);
  108. };
  109. var staticRenderFns$3 = [];
  110. var rulerLine_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".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}\n")();
  111. function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
  112. var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
  113. if (render2) {
  114. options.render = render2;
  115. options.staticRenderFns = staticRenderFns2;
  116. options._compiled = true;
  117. }
  118. if (functionalTemplate) {
  119. options.functional = true;
  120. }
  121. if (scopeId) {
  122. options._scopeId = "data-v-" + scopeId;
  123. }
  124. var hook;
  125. if (moduleIdentifier) {
  126. hook = function(context) {
  127. context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
  128. if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
  129. context = __VUE_SSR_CONTEXT__;
  130. }
  131. if (injectStyles) {
  132. injectStyles.call(this, context);
  133. }
  134. if (context && context._registeredComponents) {
  135. context._registeredComponents.add(moduleIdentifier);
  136. }
  137. };
  138. options._ssrRegister = hook;
  139. } else if (injectStyles) {
  140. hook = shadowMode ? function() {
  141. injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
  142. } : injectStyles;
  143. }
  144. if (hook) {
  145. if (options.functional) {
  146. options._injectStyles = hook;
  147. var originalRender = options.render;
  148. options.render = function renderWithStyleInjection(h, context) {
  149. hook.call(context);
  150. return originalRender(h, context);
  151. };
  152. } else {
  153. var existing = options.beforeCreate;
  154. options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
  155. }
  156. }
  157. return {
  158. exports: scriptExports,
  159. options
  160. };
  161. }
  162. const __cssModules$3 = {};
  163. var __component__$3 = /* @__PURE__ */ normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "1672e414", null, null);
  164. function __vue2_injectStyles$3(context) {
  165. for (let o in __cssModules$3) {
  166. this[o] = __cssModules$3[o];
  167. }
  168. }
  169. var RulerLine = /* @__PURE__ */ function() {
  170. return __component__$3.exports;
  171. }();
  172. const getGridSize = (scale) => {
  173. if (scale <= 0.25)
  174. return 40;
  175. if (scale <= 0.5)
  176. return 20;
  177. if (scale <= 1)
  178. return 10;
  179. if (scale <= 2)
  180. return 5;
  181. if (scale <= 4)
  182. return 2;
  183. return 1;
  184. };
  185. const FONT_SCALE = 0.83;
  186. const drawCavaseRuler = (ctx, start, selectStart, selectLength, options, h) => {
  187. const { scale, width, height, ratio, palette } = options;
  188. const { bgColor, fontColor, shadowColor, longfgColor, shortfgColor } = palette;
  189. ctx.scale(ratio, ratio);
  190. ctx.clearRect(0, 0, width, height);
  191. ctx.fillStyle = bgColor;
  192. ctx.fillRect(0, 0, width, height);
  193. if (selectLength) {
  194. const shadowX = (selectStart - start) * scale;
  195. const shadowWidth = selectLength * scale;
  196. ctx.fillStyle = shadowColor;
  197. h ? ctx.fillRect(shadowX, 0, shadowWidth, height * 3 / 8) : ctx.fillRect(0, shadowX, width * 3 / 8, shadowWidth);
  198. }
  199. const gridSize = getGridSize(scale);
  200. const gridPixel = gridSize * scale;
  201. const gridSize10 = gridSize * 10;
  202. const gridPixel10 = gridSize10 * scale;
  203. const startValue = Math.floor(start / gridSize) * gridSize;
  204. const startValue10 = Math.floor(start / gridSize10) * gridSize10;
  205. const offsetX = (startValue - start) / gridSize * gridPixel;
  206. const offsetX10 = (startValue10 - start) / gridSize10 * gridPixel10;
  207. const endValue = start + Math.ceil((h ? width : height) / scale);
  208. ctx.beginPath();
  209. ctx.fillStyle = fontColor;
  210. ctx.strokeStyle = longfgColor;
  211. for (let value = startValue10, count = 0; value < endValue; value += gridSize10, count++) {
  212. const x = offsetX10 + count * gridPixel10 + 0.5;
  213. h ? ctx.moveTo(x, 0) : ctx.moveTo(0, x);
  214. ctx.save();
  215. h ? ctx.translate(x, height * 0.4) : ctx.translate(width * 0.4, x);
  216. if (!h) {
  217. ctx.rotate(-Math.PI / 2);
  218. }
  219. ctx.scale(FONT_SCALE / ratio, FONT_SCALE / ratio);
  220. ctx.fillText(value.toString(), 4 * ratio, 7 * ratio);
  221. ctx.restore();
  222. h ? ctx.lineTo(x, height * 9 / 16) : ctx.lineTo(width * 9 / 16, x);
  223. }
  224. ctx.stroke();
  225. ctx.closePath();
  226. ctx.beginPath();
  227. ctx.strokeStyle = shortfgColor;
  228. for (let value = startValue, count = 0; value < endValue; value += gridSize, count++) {
  229. const x = offsetX + count * gridPixel + 0.5;
  230. h ? ctx.moveTo(x, 0) : ctx.moveTo(0, x);
  231. if (value % gridSize10 !== 0) {
  232. h ? ctx.lineTo(x, height * 1 / 4) : ctx.lineTo(width * 1 / 4, x);
  233. }
  234. }
  235. ctx.stroke();
  236. ctx.closePath();
  237. ctx.setTransform(1, 0, 0, 1, 0, 0);
  238. };
  239. var __vue2_script$2 = defineComponent({
  240. name: "CanvasRuler",
  241. props: {
  242. showIndicator: Boolean,
  243. valueNum: Number,
  244. scale: Number,
  245. ratio: Number,
  246. palette: Object,
  247. vertical: Boolean,
  248. start: Number,
  249. width: Number,
  250. height: Number,
  251. selectStart: Number,
  252. selectLength: Number
  253. },
  254. emits: ["onAddLine", "update:showIndicator", "update:valueNum"],
  255. setup(props, { emit }) {
  256. const state = reactive({
  257. canvasContext: null
  258. });
  259. let ratio = 1;
  260. const canvas = ref(null);
  261. onMounted(() => {
  262. ratio = props.ratio || window.devicePixelRatio || 1;
  263. initCanvasRef();
  264. updateCanvasContext(ratio);
  265. drawRuler(ratio);
  266. });
  267. const initCanvasRef = () => {
  268. state.canvasContext = canvas.value && canvas.value.getContext("2d");
  269. };
  270. const updateCanvasContext = (ratio2) => {
  271. if (canvas.value) {
  272. canvas.value.width = props.width * ratio2;
  273. canvas.value.height = props.height * ratio2;
  274. const ctx = state.canvasContext;
  275. if (ctx) {
  276. ctx.font = `${12 * ratio2}px -apple-system,
  277. "Helvetica Neue", ".SFNSText-Regular",
  278. "SF UI Text", Arial, "PingFang SC", "Hiragino Sans GB",
  279. "Microsoft YaHei", "WenQuanYi Zen Hei", sans-serif`;
  280. ctx.lineWidth = 1;
  281. ctx.textBaseline = "middle";
  282. }
  283. }
  284. };
  285. const drawRuler = (ratio2) => {
  286. const options = {
  287. scale: props.scale,
  288. width: props.width,
  289. height: props.height,
  290. palette: props.palette,
  291. ratio: ratio2
  292. };
  293. if (state.canvasContext) {
  294. drawCavaseRuler(state.canvasContext, props.start, props.selectStart, props.selectLength, options, !props.vertical);
  295. }
  296. };
  297. watch(() => props.start, () => drawRuler(ratio));
  298. watch([() => props.width, () => props.height], () => {
  299. updateCanvasContext(ratio);
  300. drawRuler(ratio);
  301. });
  302. const handle = (e, key) => {
  303. const getValueByOffset = (offset2, start, scale) => Math.round(start + offset2 / scale);
  304. const offset = props.vertical ? e.offsetY : e.offsetX;
  305. const value = getValueByOffset(offset, props.start, props.scale);
  306. switch (key) {
  307. case "click":
  308. emit("onAddLine", value);
  309. break;
  310. case "enter":
  311. emit("update:valueNum", value);
  312. emit("update:showIndicator", true);
  313. break;
  314. default:
  315. emit("update:valueNum", value);
  316. break;
  317. }
  318. };
  319. return {
  320. handle,
  321. canvas
  322. };
  323. }
  324. });
  325. var render$2 = function() {
  326. var _vm = this;
  327. var _h = _vm.$createElement;
  328. var _c = _vm._self._c || _h;
  329. return _c("canvas", {
  330. ref: "canvas",
  331. staticClass: "ruler",
  332. on: {
  333. "click": function($event) {
  334. return _vm.handle($event, "click");
  335. },
  336. "mouseenter": function($event) {
  337. return _vm.handle($event, "enter");
  338. },
  339. "mousemove": function($event) {
  340. return _vm.handle($event, "move");
  341. },
  342. "mouseleave": function($event) {
  343. return _vm.$emit("update:showIndicator", false);
  344. }
  345. }
  346. });
  347. };
  348. var staticRenderFns$2 = [];
  349. const __cssModules$2 = {};
  350. var __component__$2 = /* @__PURE__ */ normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, null, null, null);
  351. function __vue2_injectStyles$2(context) {
  352. for (let o in __cssModules$2) {
  353. this[o] = __cssModules$2[o];
  354. }
  355. }
  356. var CanvasRuler = /* @__PURE__ */ function() {
  357. return __component__$2.exports;
  358. }();
  359. const wrapperProps = {
  360. scale: Number,
  361. ratio: Number,
  362. thick: Number,
  363. palette: Object,
  364. vertical: {
  365. type: Boolean,
  366. default: true
  367. },
  368. width: {
  369. type: Number,
  370. default: 200
  371. },
  372. height: {
  373. type: Number,
  374. default: 200
  375. },
  376. start: {
  377. type: Number,
  378. default: 0
  379. },
  380. lines: {
  381. type: Array,
  382. default: () => []
  383. },
  384. selectStart: {
  385. type: Number
  386. },
  387. selectLength: {
  388. type: Number
  389. },
  390. isShowReferLine: {
  391. type: Boolean
  392. }
  393. };
  394. var __vue2_script$1 = defineComponent({
  395. name: "RulerWrapper",
  396. components: {
  397. CanvasRuler,
  398. RulerLine
  399. },
  400. props: wrapperProps,
  401. setup(props) {
  402. const showIndicator = ref(false);
  403. const valueNum = ref(0);
  404. const rwClassName = computed(() => {
  405. const className = props.vertical ? "v-container" : "h-container";
  406. return className;
  407. });
  408. const rwStyle = computed(() => {
  409. const hContainer = {
  410. width: `calc(100% - ${props.thick}px)`,
  411. height: `${props.thick + 1}px`,
  412. left: `${props.thick}px`
  413. };
  414. const vContainer = {
  415. width: `${props.thick && props.thick + 1}px`,
  416. height: `calc(100% - ${props.thick}px)`,
  417. top: `${props.thick}px`
  418. };
  419. return props.vertical ? vContainer : hContainer;
  420. });
  421. const indicatorStyle = computed(() => {
  422. var _a;
  423. const indicatorOffset = (valueNum.value - props.start) * props.scale;
  424. let positionKey = "top";
  425. let boderKey = "borderLeft";
  426. positionKey = props.vertical ? "top" : "left";
  427. boderKey = props.vertical ? "borderBottom" : "borderLeft";
  428. return {
  429. [positionKey]: indicatorOffset + "px",
  430. [boderKey]: `1px solid ${(_a = props.palette) == null ? void 0 : _a.lineColor}`
  431. };
  432. });
  433. const handleNewLine = (value) => {
  434. props.lines.push(value);
  435. };
  436. const handleLineRelease = (value, index) => {
  437. const offset = value - props.start;
  438. const maxOffset = (props.vertical ? props.height : props.width) / props.scale;
  439. if (offset < 0 || offset > maxOffset) {
  440. handleLineRemove(index);
  441. } else {
  442. props.lines[index] = value;
  443. }
  444. };
  445. const handleLineRemove = (index) => {
  446. props.lines.splice(index, 1);
  447. };
  448. return {
  449. showIndicator,
  450. valueNum,
  451. rwClassName,
  452. rwStyle,
  453. indicatorStyle,
  454. handleNewLine,
  455. handleLineRelease,
  456. handleLineRemove
  457. };
  458. }
  459. });
  460. var render$1 = function() {
  461. var _vm = this;
  462. var _h = _vm.$createElement;
  463. var _c = _vm._self._c || _h;
  464. return _c("div", {
  465. class: _vm.rwClassName,
  466. style: _vm.rwStyle
  467. }, [_c("CanvasRuler", {
  468. attrs: {
  469. "vertical": _vm.vertical,
  470. "scale": _vm.scale,
  471. "width": _vm.width,
  472. "height": _vm.height,
  473. "start": _vm.start,
  474. "ratio": _vm.ratio,
  475. "select-start": _vm.selectStart,
  476. "select-length": _vm.selectLength,
  477. "palette": _vm.palette
  478. },
  479. on: {
  480. "onAddLine": _vm.handleNewLine
  481. },
  482. model: {
  483. value: _vm.showIndicator,
  484. callback: function($$v) {
  485. _vm.showIndicator = $$v;
  486. },
  487. expression: "showIndicator"
  488. }
  489. }), _c("div", {
  490. directives: [{
  491. name: "show",
  492. rawName: "v-show",
  493. value: _vm.isShowReferLine,
  494. expression: "isShowReferLine"
  495. }],
  496. staticClass: "lines"
  497. }, _vm._l(_vm.lines, function(v, i) {
  498. return _c("RulerLine", {
  499. key: v + i,
  500. attrs: {
  501. "index": i,
  502. "value": v >> 0,
  503. "scale": _vm.scale,
  504. "start": _vm.start,
  505. "thick": _vm.thick,
  506. "palette": _vm.palette,
  507. "vertical": _vm.vertical,
  508. "is-show-refer-line": _vm.isShowReferLine
  509. },
  510. on: {
  511. "onRemove": _vm.handleLineRemove,
  512. "onRelease": _vm.handleLineRelease
  513. }
  514. });
  515. }), 1), _c("div", {
  516. directives: [{
  517. name: "show",
  518. rawName: "v-show",
  519. value: _vm.showIndicator,
  520. expression: "showIndicator"
  521. }],
  522. staticClass: "indicator",
  523. style: _vm.indicatorStyle
  524. }, [_c("div", {
  525. staticClass: "value"
  526. }, [_vm._v(_vm._s(_vm.valueNum))])])], 1);
  527. };
  528. var staticRenderFns$1 = [];
  529. var rulerWrapper_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".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}\n")();
  530. const __cssModules$1 = {};
  531. var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "042af537", null, null);
  532. function __vue2_injectStyles$1(context) {
  533. for (let o in __cssModules$1) {
  534. this[o] = __cssModules$1[o];
  535. }
  536. }
  537. var RulerWrapper = /* @__PURE__ */ function() {
  538. return __component__$1.exports;
  539. }();
  540. const eye64 = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAAAXNSR0IArs4c6QAAAopJREFUOE/FlE9IVEEcx7+/N9ouds1Mu0QUSFZYdIgoUqQoKPBQHsKozpXE7jbTO/U8xLJvn6usBHWQ6hBFXupSkQeVbh0KJEPp0sH+eLGTsKs77xcj78m0ax0E8cHjzZv5zef3/c33xxA24KENYGJzoEEQbNNaN4Zh2OQ4znwYhr9c1/39vwrXVDo0NNS0tLR0GYB5D64BmAMwzMyvlFKz1es10Hw+f4mZ7wHYBeA9gNdENFepVOaEEM3M3OI4Thczn41gt6WUgQ3+C+r7/h0AWQD3mXnYqPA8L9nQ0HCemduIaFpKOWoAhUJhT6VSuQXgOjP3K6W8GLwKzeVyp4jonR0QBEErM48w8zFLyayUsjX+z+VyHhHdZebTSqkxM78CHRgYOKS1/ghgVErZY214RkQ7ADyRUj72ff8qgCtmXUrZGcf5vv8CwEUhxOF0Ov1pBRpla5dSdseBhUJhpznH6tIsZb1KqacW+BGArUaUXX63UuplHJTNZjuEEONSyhozfd/n6mQ1RkXZL2itz7mu+80EDA4ONi8vL/8AcM2UbikyR2BU9cSmmTU70YqKIAj2hWFo2uenlHK/BRg3Y2aeNO5GyU8S0ZbFxcUuz/NKEXAGQKPjOCcymcyX1dIi8DSAiWQyeaavr68cbSgCuBknYubnQoj+TCYzUywWE6VS6S2ADsdx2gxw1X3L7SNENMbMnwE8qK+vf5NKpRaMaeVyeW8ikfiaSqW+R7BuZr5BRMe11p2u607U9Gk8kc/ntzPzQwCmExYATDLzVBiGE0KIowAOADDf3QA+aK2VDaxRajto3K+rq+tl5nYAzQBamHmeiOYBTGmtR6ph/1Rqg9c73pz7dD1qN0TpHyNQRCUDJXrAAAAAAElFTkSuQmCC`;
  541. const closeEye64 = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAAAXNSR0IArs4c6QAAAjtJREFUOE/NlD9oFEEUxn9v9ghC0hpRUogIAUmniGAT/5Q2FrETPSNRJILg7RwimI0ox85eQFCEBGIUO1PYpFM0jSConQoBEZGgGPsgl+w+2eM2bC57SopAFqYZ3v7m+977ZoQt+GQLmGxPaBiGgYiMWWvXBHZUGoZhH3BERPYC+4F+4Keq/urt7b1RLpf/ZEBVHa9Wq0HWyg3QKIoGVPU8cA7wgK/pUtXPQJ8xZk+pVBpuNBqXUoUiEvi+P56fzTpo6+SbwHNg1lo7WzTITGEKXFlZeeB53tVCpa3CK8AFa+1cBgvD8LKIXAQOJkkyICJDeYVBEJS6u7s/qeoLa+1o+l9TqXNuBLhmjDlbqVQ+5ICjInIfOBPH8W9jzGCR5YmJiRNxHM+papgqzqDvgSlr7VTernPuO3An3c9bBt74vv+yrdaKyLDv+/1Sq9UGPc97nY9EVuycU2AQOA7cAm4Dr4D5TvVxHB9rKo2iaEFVp621Ln96FEUngaOqGmSxabVqsh3a2h+x1h5qQjNrae/yE4+iaCwDJkky73neTuBZe129Xk+H+BS4l7ZqLVIZ2BhzuFKpvMsDVXXWGPMxFdAedOfcKeCRqj7MYrUhpz09PfXl5eXrectFWXXODQHpOq2qd/95o/JXr6ura3J1dXU6SZIfwKKIHAD2tVYMPBGRx77vN10UXtO85fTkmZmZHUtLSzUR2QXsBhaAL6r6DXhbrVYXi1yss59GqOgub/bN3Z7v6X/tb9Zmp/q/kN8s+lJb8oEAAAAASUVORK5CYII=`;
  542. const sketchRulerProps = {
  543. eyeIcon: {
  544. type: String
  545. },
  546. closeEyeIcon: {
  547. type: String
  548. },
  549. scale: {
  550. type: Number,
  551. default: 1
  552. },
  553. ratio: {
  554. type: Number
  555. },
  556. thick: {
  557. type: Number,
  558. default: 16
  559. },
  560. palette: Object,
  561. startX: {
  562. type: Number
  563. },
  564. startY: {
  565. type: Number,
  566. default: 0
  567. },
  568. width: {
  569. type: Number,
  570. default: 200
  571. },
  572. height: {
  573. type: Number,
  574. default: 200
  575. },
  576. shadow: {
  577. type: Object,
  578. default: () => {
  579. return {
  580. x: 0,
  581. y: 0,
  582. width: 0,
  583. height: 0
  584. };
  585. }
  586. },
  587. lines: {
  588. type: Object,
  589. default: () => {
  590. return {
  591. h: [],
  592. v: []
  593. };
  594. }
  595. },
  596. isShowReferLine: {
  597. type: Boolean,
  598. default: true
  599. }
  600. };
  601. var __vue2_script = defineComponent({
  602. name: "SketchRule",
  603. components: {
  604. RulerWrapper
  605. },
  606. props: sketchRulerProps,
  607. emits: ["onCornerClick"],
  608. setup(props, { emit }) {
  609. let showReferLine = ref(true);
  610. showReferLine.value = props.isShowReferLine;
  611. const paletteCpu = computed(() => {
  612. function merge(obj, o) {
  613. Object.keys(obj).forEach((key) => {
  614. if (key && obj.hasOwnProperty(key)) {
  615. if (typeof o["key"] === "object") {
  616. obj[key] = merge(obj[key], o[key]);
  617. } else if (o.hasOwnProperty(key)) {
  618. obj[key] = o[key];
  619. }
  620. }
  621. });
  622. return obj;
  623. }
  624. const finalObj = merge({
  625. bgColor: "rgba(225,225,225, 0)",
  626. longfgColor: "#BABBBC",
  627. shortfgColor: "#C8CDD0",
  628. fontColor: "#7D8694",
  629. shadowColor: "#E8E8E8",
  630. lineColor: "#EB5648",
  631. borderColor: "#DADADC",
  632. cornerActiveColor: "rgb(235, 86, 72, 0.6)",
  633. menu: {
  634. bgColor: "#fff",
  635. dividerColor: "#DBDBDB",
  636. listItem: {
  637. textColor: "#415058",
  638. hoverTextColor: "#298DF8",
  639. disabledTextColor: "rgba(65, 80, 88, 0.4)",
  640. bgColor: "#fff",
  641. hoverBgColor: "#F2F2F2"
  642. }
  643. }
  644. }, props.palette || {});
  645. return finalObj;
  646. });
  647. const cornerStyle = computed(() => {
  648. return {
  649. backgroundImage: showReferLine.value ? `url(${props.eyeIcon || eye64})` : `url(${props.closeEyeIcon || closeEye64})`,
  650. width: props.thick + "px",
  651. height: props.thick + "px",
  652. borderRight: `1px solid ${paletteCpu.value.borderColor}`,
  653. borderBottom: `1px solid ${paletteCpu.value.borderColor}`
  654. };
  655. });
  656. const onCornerClick = (e) => {
  657. showReferLine.value = !showReferLine.value;
  658. emit("onCornerClick", showReferLine.value);
  659. };
  660. watch([() => props.isShowReferLine], () => {
  661. showReferLine.value = props.isShowReferLine;
  662. });
  663. return {
  664. showReferLine,
  665. paletteCpu,
  666. cornerStyle,
  667. onCornerClick
  668. };
  669. }
  670. });
  671. var render = function() {
  672. var _vm = this;
  673. var _h = _vm.$createElement;
  674. var _c = _vm._self._c || _h;
  675. return _c("div", {
  676. staticClass: "style-ruler mb-ruler",
  677. attrs: {
  678. "id": "mb-ruler"
  679. }
  680. }, [_c("RulerWrapper", {
  681. attrs: {
  682. "vertical": false,
  683. "width": _vm.width,
  684. "height": _vm.thick,
  685. "is-show-refer-line": _vm.showReferLine,
  686. "thick": _vm.thick,
  687. "ratio": _vm.ratio,
  688. "start": _vm.startX,
  689. "lines": _vm.lines.h,
  690. "select-start": _vm.shadow.x,
  691. "select-length": _vm.shadow.width,
  692. "scale": _vm.scale,
  693. "palette": _vm.paletteCpu
  694. }
  695. }), _c("RulerWrapper", {
  696. attrs: {
  697. "vertical": true,
  698. "width": _vm.thick,
  699. "height": _vm.height,
  700. "is-show-refer-line": _vm.showReferLine,
  701. "thick": _vm.thick,
  702. "ratio": _vm.ratio,
  703. "start": _vm.startY,
  704. "lines": _vm.lines.v,
  705. "select-start": _vm.shadow.y,
  706. "select-length": _vm.shadow.height,
  707. "scale": _vm.scale,
  708. "palette": _vm.paletteCpu
  709. }
  710. }), _c("a", {
  711. staticClass: "corner",
  712. style: _vm.cornerStyle,
  713. on: {
  714. "click": _vm.onCornerClick
  715. }
  716. })], 1);
  717. };
  718. var staticRenderFns = [];
  719. var index_vue_vue_type_style_index_0_lang = /* @__PURE__ */ (() => '@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}\n')();
  720. const __cssModules = {};
  721. var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
  722. function __vue2_injectStyles(context) {
  723. for (let o in __cssModules) {
  724. this[o] = __cssModules[o];
  725. }
  726. }
  727. var SketchRule = /* @__PURE__ */ function() {
  728. return __component__.exports;
  729. }();
  730. export { SketchRule, SketchRule as default };