svgedit/dist/editor/extensions/ext-star/ext-star.js.map

1 line
11 KiB
Plaintext
Raw Normal View History

2020-09-06 06:32:10 +00:00
{"version":3,"file":"ext-star.js","sources":["../../../../src/editor/extensions/ext-star/ext-star.js"],"sourcesContent":["/**\n * @file ext-star.js\n *\n *\n * @copyright 2010 CloudCanvas, Inc. All rights reserved\n *\n */\n\nexport default {\n name: 'star',\n async init (S) {\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n\n const {$} = S; // {svgcontent},\n let\n selElems,\n // editingitex = false,\n // svgdoc = S.svgroot.parentNode.ownerDocument,\n started,\n newFO;\n // edg = 0,\n // newFOG, newFOGParent, newDef, newImageName, newMaskID,\n // undoCommand = 'Not image',\n // modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);\n\n /**\n *\n * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n let fcRules = $('#fc_rules');\n if (!fcRules.length) {\n fcRules = $('<style id=\"fc_rules\"></style>').appendTo('head');\n }\n fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');\n $('#star_panel').toggle(on);\n }\n\n /*\n function toggleSourceButtons(on){\n $('#star_save, #star_cancel').toggle(on);\n }\n */\n\n /**\n *\n * @param {string} attr\n * @param {string|Float} val\n * @returns {void}\n */\n function setAttr (attr, val) {\n svgCanvas.changeSelectedAttribute(attr, val);\n svgCanvas.call('changed', selElems);\n }\n\n /*\n function cot(n){\n return 1 / Math.tan(n);\n }\n\n function sec(n){\n return 1 / Math.cos(n);\n }\n */\n const buttons = [{\n id: 'tool_star',\n icon: 'star.png',\n type: 'mode',\n position: 12,\n events: {\n click () {\n showPanel(true);\n svgCanvas.setMode('star');\n }\n }\n }];\n const contextTools = [{\n type: 'input',\n panel: 'star_panel',\n id: 'starNumPoints',\n size: 3,\n defval: 5,\n events: {\n change () {\n setAttr('point', this.value);\n }\n }\n }, {\n type: 'input',\n panel: 'star_panel',\n id: 'starRadiusMulitplier',\n size: 3,\n defval: 2.5\n }, {\n type: 'input',\n panel: 'star_panel',\n id: 'radialShift',\n size: 3,\n defval: 0,\n events: {\n change () {\n setAttr('radialshift', this.value);\n }\n }\n }];\n\n return {\n name: strings.name,\n svgicons: 'star-icons.svg',\n buttons: strings.buttons.map((button, i) => {\n return Object.assign(buttons[i], button);\n }),\n context_tools: strings.contextTools.map((contextTool, i) => {\n return Object.assign(contextTools[i], contextTool);\n }),\n callback () {\n $('#star_panel').hide();\n // const endChanges = function(){};\n },\n mouseDown (opts) {\n const rgb = svgCanvas.getColor('fill');\n // const ccRgbEl = rgb.substring(1, rgb.length);\n const sRgb = svgCanvas.getColor('stroke');\n // const ccSRgbEl = sRgb.substring(1, rgb.length);\n const sWidth = svgCanvas.getStrokeWidth();\n\n if (svgCanvas.getMode() === 'star') {\n started = true;\n\n newFO = svgCanvas.addSVGElementFromJson({\n element: 'polygon',\n attr: {\n cx: opts.start_x,\n cy: opts.start_y,\n id: svgCanvas.getNextId(),\n shape: 'star',\n point: document.getElementById('starNumPoints').value,\n r: 0,\n radialshift: document.getElementById('radialShift').value,\n r2: 0,\n orient: 'point',\n fill: rgb,\n strokecolor: sRgb,\n strokeWidth: sWidth\n }\n });\n return {\n started: true\n