} data
- * @property {Integer} [size]
- * @property {boolean} [fill]
- */
-
- /**
- * @param {string|"basic"} cat Category ID
- * @param {module:Extension.Shapes.Shapes} shapes
- * @returns {void}
- */
- function makeButtons (cat, shapes) {
- const size = curLib.size || 300;
- const fill = curLib.fill || false;
- const off = size * 0.05;
- const vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
- const stroke = fill ? 0 : (size / 30);
- const shapeIcon = new DOMParser().parseFromString(
- '',
- 'text/xml'
- );
-
- const width = 24;
- const height = 24;
- shapeIcon.documentElement.setAttribute('width', width);
- shapeIcon.documentElement.setAttribute('height', height);
- const svgElem = $(document.importNode(shapeIcon.documentElement, true));
-
- const {data} = shapes;
-
- curLib.buttons = Object.entries(data).map(([id, pathD]) => {
- const icon = svgElem.clone();
- icon.find('path').attr('d', pathD);
-
- const iconBtn = icon.wrap('').parent().attr({
- id: modeId + '_' + id,
- title: id
- });
- // Store for later use
- return iconBtn[0];
- });
- }
-
- /**
- * @param {string|"basic"} catId
- * @returns {void}
- */
- function loadLibrary (catId) {
- const lib = library[catId];
-
- if (!lib) {
- $('#shape_buttons').html(strings.loading);
- $.getJSON('./shapelib/' + catId + '.json', function (result) {
- curLib = library[catId] = {
- data: result.data,
- size: result.size,
- fill: result.fill
- };
- makeButtons(catId, result);
- loadIcons();
- });
- return;
- }
- curLib = lib;
- if (!lib.buttons.length) { makeButtons(catId, lib); }
- loadIcons();
- }
const buttons = [{
id: 'tool_shapelib_show',
type: 'mode_flyout',
@@ -136,101 +51,13 @@ export default {
return Object.assign(buttons[i], button);
}),
callback () {
- $('