Commit 6edd63cb authored by Romain Courteaud's avatar Romain Courteaud

erp5_svg_editor: add draft svg shapes

parent 3e6bebcc
/* /*
* ext-shapes.js * ext-shapes.js
* *
* Licensed under the Apache License, Version 2 * Licensed under the Apache License, Version 2
* *
* Copyright(c) 2010 Christian Tzurcanu * Copyright(c) 2010 Christian Tzurcanu
* Copyright(c) 2010 Alexis Deveria * Copyright(c) 2010 Alexis Deveria
* *
*/ */
methodDraw.addExtension("shapes", function() { methodDraw.addExtension("shapes", function() {
var current_d, cur_shape_id; var current_d, cur_shape_id;
var canv = methodDraw.canvas; var canv = methodDraw.canvas;
var cur_shape; var cur_shape;
var start_x, start_y; var start_x, start_y;
var svgroot = canv.getRootElem(); var svgroot = canv.getRootElem();
var lastBBox = {}; var lastBBox = {};
// This populates the category list // This populates the category list
var categories = { var categories = {
basic: 'Basic', basic: 'Basic',
object: 'Objects', nexedi: 'Nexedi Shapes',
symbol: 'Symbols', object: 'Objects',
arrow: 'Arrows', symbol: 'Symbols',
flowchart: 'Flowchart', arrow: 'Arrows',
nature: 'Nature', flowchart: 'Flowchart',
game: 'Cards & Chess', nature: 'Nature',
dialog_balloon: 'Dialog balloons', game: 'Cards & Chess',
music: 'Music', dialog_balloon: 'Dialog balloons',
weather: 'Weather & Time', music: 'Music',
ui: 'User Interface', weather: 'Weather & Time',
social: 'Social Web' ui: 'User Interface',
}; social: 'Social Web'
};
var library = {
'basic': { var library = {
data: { 'basic': {
"star_points_5": "m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z", data: {
'donut': 'm1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z', "star_points_5": "m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",
"triangle": "m1,280.375l149,-260.75l149,260.75z", 'donut': 'm1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z',
"right_triangle": "m1,299l0,-298l298,298z", "triangle": "m1,280.375l149,-260.75l149,260.75z",
"diamond": "m1,150l149,-149l149,149l-149,149l-149,-149z", "right_triangle": "m1,299l0,-298l298,298z",
"pentagon": "m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z", "diamond": "m1,150l149,-149l149,149l-149,149l-149,-149z",
"hexagon": "m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z", "pentagon": "m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",
"septagon1": "m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z", "hexagon": "m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",
"heptagon": "m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z", "septagon1": "m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",
"decagon": "m1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z", "heptagon": "m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z",
"dodecagon": "m1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z", "decagon": "m1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z",
"trapezoid": "m1,299l55.875,-298l186.25001,0l55.87498,298z", "dodecagon": "m1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z",
"dialog_balloon_1": "m0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z", "trapezoid": "m1,299l55.875,-298l186.25001,0l55.87498,298z",
'heart': 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z', "dialog_balloon_1": "m0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z",
"cylinder": "m299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z", 'heart': 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z',
"arrow_up": "m1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z", "cylinder": "m299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z",
"arrow_u_turn": "m1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z", "arrow_up": "m1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z",
"arrow_left_up": "m0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z", "arrow_u_turn": "m1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z",
"plaque": "m-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z", "arrow_left_up": "m0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z",
"page": "m249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234", "plaque": "m-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z",
"cross": "m0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z", "page": "m249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234",
"divide": "m150,0.99785l0,0c25.17819,0 45.58916,20.41097 45.58916,45.58916c0,25.17821 -20.41096,45.58916 -45.58916,45.58916c-25.17822,0 -45.58916,-20.41093 -45.58916,-45.58916c0,-25.1782 20.41093,-45.58916 45.58916,-45.58916zm0,296.25203c-25.17822,0 -45.58916,-20.41095 -45.58916,-45.58917c0,-25.17819 20.41093,-45.58916 45.58916,-45.58916c25.17819,0 45.58916,20.41096 45.58916,45.58916c0,25.17822 -20.41096,45.58917 -45.58916,45.58917zm-134.06754,-193.71518l268.13507,0l0,91.17833l-268.13507,0z", "cross": "m0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z",
"minus": "m0.99887,102.39503l297.49445,0l0,95.2112l-297.49445,0z", "divide": "m150,0.99785l0,0c25.17819,0 45.58916,20.41097 45.58916,45.58916c0,25.17821 -20.41096,45.58916 -45.58916,45.58916c-25.17822,0 -45.58916,-20.41093 -45.58916,-45.58916c0,-25.1782 20.41093,-45.58916 45.58916,-45.58916zm0,296.25203c-25.17822,0 -45.58916,-20.41095 -45.58916,-45.58917c0,-25.17819 20.41093,-45.58916 45.58916,-45.58916c25.17819,0 45.58916,20.41096 45.58916,45.58916c0,25.17822 -20.41096,45.58917 -45.58916,45.58917zm-134.06754,-193.71518l268.13507,0l0,91.17833l-268.13507,0z",
"times": "m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z" "minus": "m0.99887,102.39503l297.49445,0l0,95.2112l-297.49445,0z",
"times": "m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z"
},
buttons: [] },
} buttons: []
}; }
};
var cur_lib = library.basic;
var cur_lib = library.basic;
var mode_id = 'shapelib';
var mode_id = 'shapelib';
function loadIcons() {
$('#shape_buttons').empty(); function loadIcons() {
$('#shape_buttons').empty();
// Show lib ones
$('#shape_buttons').append(cur_lib.buttons); // Show lib ones
} $('#shape_buttons').append(cur_lib.buttons);
}
function loadLibrary(cat_id) {
function loadLibrary(cat_id) {
var lib = library[cat_id];
var lib = library[cat_id];
if(!lib) {
$('#shape_buttons').html('Loading...'); if(!lib) {
$.getJSON('extensions/shapelib/' + cat_id + '.json', function(result, textStatus) { $('#shape_buttons').html('Loading...');
cur_lib = library[cat_id] = { $.getJSON('extensions/shapelib/' + cat_id + '.json', function(result, textStatus) {
data: result.data, cur_lib = library[cat_id] = {
size: result.size, data: result.data,
fill: result.fill size: result.size,
} fill: result.fill
makeButtons(cat_id, result); }
loadIcons(); makeButtons(cat_id, result);
}); loadIcons();
return; });
} return;
}
cur_lib = lib;
if(!lib.buttons.length) makeButtons(cat_id, lib); cur_lib = lib;
loadIcons(); if(!lib.buttons.length) makeButtons(cat_id, lib);
} loadIcons();
}
function makeButtons(cat, shapes) {
var size = cur_lib.size || 300; function makeButtons(cat, shapes) {
var fill = cur_lib.fill || false; var size = cur_lib.size || 300;
var off = size * .05; var fill = cur_lib.fill || false;
var vb = [-off, -off, size + off*2, size + off*2].join(' '); var off = size * .05;
var stroke = fill ? 0: (size/30); var vb = [-off, -off, size + off*2, size + off*2].join(' ');
var stroke = fill ? 0: (size/30);
var shape_icon = new DOMParser().parseFromString(
'<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="' + vb + '"><path fill="#333" stroke="transparent" stroke-width="' + stroke + '" /><\/svg><\/svg>', var shape_icon = new DOMParser().parseFromString(
'text/xml'); '<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="' + vb + '"><path fill="#333" stroke="transparent" stroke-width="' + stroke + '" /><\/svg><\/svg>',
'text/xml');
var width = 40;
var height = 40; var width = 40;
shape_icon.documentElement.setAttribute('width', width); var height = 40;
shape_icon.documentElement.setAttribute('height', height); shape_icon.documentElement.setAttribute('width', width);
var svg_elem = $(document.importNode(shape_icon.documentElement,true)); shape_icon.documentElement.setAttribute('height', height);
var svg_elem = $(document.importNode(shape_icon.documentElement,true));
var data = shapes.data;
var data = shapes.data;
cur_lib.buttons = [];
cur_lib.buttons = [];
for(var id in data) {
var path_d = data[id]; for(var id in data) {
var icon = svg_elem.clone(); var path_d = data[id];
icon.find('path').attr('d', path_d); var icon = svg_elem.clone();
icon.find('path').attr('d', path_d);
var icon_btn = icon.wrap('<div class="tool_button">').parent().attr({
id: mode_id + '_' + id, var icon_btn = icon.wrap('<div class="tool_button">').parent().attr({
title: id id: mode_id + '_' + id,
}); title: id
});
// Store for later use
cur_lib.buttons.push(icon_btn[0]); // Store for later use
} cur_lib.buttons.push(icon_btn[0]);
}
}
}
return {
svgicons: "extensions/ext-shapes.xml", return {
buttons: [{ svgicons: "extensions/ext-shapes.xml",
id: "tool_shapelib", buttons: [{
type: "mode_flyout", // _flyout id: "tool_shapelib",
position: 6, type: "mode_flyout", // _flyout
title: "Shape library", position: 6,
icon: "extensions/ext-shapes.png", title: "Shape library",
events: { icon: "extensions/ext-shapes.png",
"click": function() { events: {
canv.setMode(mode_id); "click": function() {
} canv.setMode(mode_id);
} }
}], }
callback: function() { }],
callback: function() {
var btn_div = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btn_div); var btn_div = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btn_div);
var shower = $('#tools_shapelib_show');
var shower = $('#tools_shapelib_show');
loadLibrary('basic');
loadLibrary('basic');
// Do mouseup on parent element rather than each button
$('#shape_buttons').mouseup(function(evt) { // Do mouseup on parent element rather than each button
var btn = $(evt.target).closest('div.tool_button'); $('#shape_buttons').mouseup(function(evt) {
var btn = $(evt.target).closest('div.tool_button');
if(!btn.length) return;
if(!btn.length) return;
var copy = btn.children().clone().attr({width: 24, height: 24});
shower.children(':not(.flyout_arrow_horiz)').remove(); var copy = btn.children().clone().attr({width: 24, height: 24});
shower shower.children(':not(.flyout_arrow_horiz)').remove();
.append(copy) shower
.attr('data-curopt', '#' + btn[0].id) // This sets the current mode .append(copy)
.mouseup(); .attr('data-curopt', '#' + btn[0].id) // This sets the current mode
canv.setMode(mode_id); .mouseup();
canv.setMode(mode_id);
cur_shape_id = btn[0].id.substr((mode_id+'_').length);
current_d = cur_lib.data[cur_shape_id]; cur_shape_id = btn[0].id.substr((mode_id+'_').length);
current_d = cur_lib.data[cur_shape_id];
$('.tools_flyout').fadeOut();
$('.tools_flyout').fadeOut();
});
});
//
var shape_cats = $('<div id="shape_cats">'); //
var cat_str = ''; var shape_cats = $('<div id="shape_cats">');
var cat_str = '';
$.each(categories, function(id, label) {
cat_str += '<div data-cat=' + id + '>' + label + '</div>'; $.each(categories, function(id, label) {
}); cat_str += '<div data-cat=' + id + '>' + label + '</div>';
});
shape_cats.html(cat_str).children().bind('mouseup', function() {
var catlink = $(this); shape_cats.html(cat_str).children().bind('mouseup', function() {
catlink.siblings().removeClass('current'); var catlink = $(this);
catlink.addClass('current'); catlink.siblings().removeClass('current');
catlink.addClass('current');
loadLibrary(catlink.attr('data-cat'));
// Get stuff loadLibrary(catlink.attr('data-cat'));
// Get stuff
return false;
}); return false;
});
shape_cats.children().eq(0).addClass('current');
shape_cats.children().eq(0).addClass('current');
$('#tools_shapelib').prepend(shape_cats);
$('#tools_shapelib').prepend(shape_cats);
shower.mouseup(function() {
canv.setMode(current_d ? mode_id : 'select'); shower.mouseup(function() {
}); canv.setMode(current_d ? mode_id : 'select');
});
$('#tool_shapelib').remove();
$('#tool_shapelib').remove();
var h = $('#tools_shapelib').height();
$('#tools_shapelib').css({ var h = $('#tools_shapelib').height();
'margin-top': -(h/2), $('#tools_shapelib').css({
'margin-left': 3 'margin-top': -(h/2),
}); 'margin-left': 3
});
},
mouseDown: function(opts) { },
var mode = canv.getMode(); mouseDown: function(opts) {
if(mode !== mode_id) return; var mode = canv.getMode();
if(mode !== mode_id) return;
var e = opts.event;
var x = start_x = opts.start_x; var e = opts.event;
var y = start_y = opts.start_y; var x = start_x = opts.start_x;
var cur_style = canv.getStyle(); var y = start_y = opts.start_y;
cur_shape = canv.addSvgElementFromJson({ var cur_style = canv.getStyle();
"element": "path", cur_shape = canv.addSvgElementFromJson({
"curStyles": true, "element": "path",
"attr": { "curStyles": true,
"d": current_d, "attr": {
"id": canv.getNextId(), "d": current_d,
"opacity": cur_style.opacity / 2, "id": canv.getNextId(),
"style": "pointer-events:none" "opacity": cur_style.opacity / 2,
} "style": "pointer-events:none"
}); }
cur_shape.setAttribute("d", current_d); });
// Make sure shape uses absolute values cur_shape.setAttribute("d", current_d);
if(/[a-z]/.test(current_d)) { // Make sure shape uses absolute values
current_d = cur_lib.data[cur_shape_id] = canv.pathActions.convertPath(cur_shape); if(/[a-z]/.test(current_d)) {
cur_shape.setAttribute('d', current_d); current_d = cur_lib.data[cur_shape_id] = canv.pathActions.convertPath(cur_shape);
canv.pathActions.fixEnd(cur_shape); cur_shape.setAttribute('d', current_d);
} canv.pathActions.fixEnd(cur_shape);
}
cur_shape.setAttribute('transform', "translate(" + x + "," + y + ") scale(0.005) translate(" + -x + "," + -y + ")");
// console.time('b'); cur_shape.setAttribute('transform', "translate(" + x + "," + y + ") scale(0.005) translate(" + -x + "," + -y + ")");
canv.recalculateDimensions(cur_shape); // console.time('b');
var tlist = canv.getTransformList(cur_shape); canv.recalculateDimensions(cur_shape);
lastBBox = cur_shape.getBBox(); var tlist = canv.getTransformList(cur_shape);
totalScale = { lastBBox = cur_shape.getBBox();
sx: 1, totalScale = {
sy: 1 sx: 1,
}; sy: 1
return { };
started: true return {
} started: true
// current_d }
}, // current_d
mouseMove: function(opts) { },
var mode = canv.getMode(); mouseMove: function(opts) {
if(mode !== mode_id) return; var mode = canv.getMode();
if(mode !== mode_id) return;
var zoom = canv.getZoom();
var evt = opts.event var zoom = canv.getZoom();
var evt = opts.event
var x = opts.mouse_x/zoom;
var y = opts.mouse_y/zoom; var x = opts.mouse_x/zoom;
var y = opts.mouse_y/zoom;
var tlist = canv.getTransformList(cur_shape),
box = cur_shape.getBBox(), var tlist = canv.getTransformList(cur_shape),
left = box.x, top = box.y, width = box.width, box = cur_shape.getBBox(),
height = box.height; left = box.x, top = box.y, width = box.width,
var dx = (x-start_x), dy = (y-start_y); height = box.height;
var dx = (x-start_x), dy = (y-start_y);
var newbox = {
'x': Math.min(start_x,x), var newbox = {
'y': Math.min(start_y,y), 'x': Math.min(start_x,x),
'width': Math.abs(x-start_x), 'y': Math.min(start_y,y),
'height': Math.abs(y-start_y) 'width': Math.abs(x-start_x),
}; 'height': Math.abs(y-start_y)
};
var ts = null,
tx = 0, ty = 0, var ts = null,
sy = height ? (height+dy)/height : 1, tx = 0, ty = 0,
sx = width ? (width+dx)/width : 1; sy = height ? (height+dy)/height : 1,
sx = width ? (width+dx)/width : 1;
var sx = newbox.width / lastBBox.width;
var sy = newbox.height / lastBBox.height; var sx = newbox.width / lastBBox.width;
var sy = newbox.height / lastBBox.height;
sx = sx || 1;
sy = sy || 1; sx = sx || 1;
sy = sy || 1;
// Not perfect, but mostly works...
// Not perfect, but mostly works...
if(x < start_x) {
tx = lastBBox.width; if(x < start_x) {
} tx = lastBBox.width;
if(y < start_y) ty = lastBBox.height; }
if(y < start_y) ty = lastBBox.height;
// update the transform list with translate,scale,translate
var translateOrigin = svgroot.createSVGTransform(), // update the transform list with translate,scale,translate
scale = svgroot.createSVGTransform(), var translateOrigin = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform(); scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(-(left+tx), -(top+ty));
if(evt.shiftKey) { translateOrigin.setTranslate(-(left+tx), -(top+ty));
replaced = true if(evt.shiftKey) {
var max = Math.min(Math.abs(sx), Math.abs(sy)); replaced = true
sx = max * (sx < 0 ? -1 : 1); var max = Math.min(Math.abs(sx), Math.abs(sy));
sy = max * (sy < 0 ? -1 : 1); sx = max * (sx < 0 ? -1 : 1);
if (totalScale.sx != totalScale.sy) { sy = max * (sy < 0 ? -1 : 1);
var multiplierX = (totalScale.sx > totalScale.sy) ? 1 : totalScale.sx/totalScale.sy; if (totalScale.sx != totalScale.sy) {
var multiplierY = (totalScale.sy > totalScale.sx) ? 1 : totalScale.sy/totalScale.sx; var multiplierX = (totalScale.sx > totalScale.sy) ? 1 : totalScale.sx/totalScale.sy;
sx *= multiplierY var multiplierY = (totalScale.sy > totalScale.sx) ? 1 : totalScale.sy/totalScale.sx;
sy *= multiplierX sx *= multiplierY
} sy *= multiplierX
} }
totalScale.sx *= sx; }
totalScale.sy *= sy; totalScale.sx *= sx;
scale.setScale(sx,sy); totalScale.sy *= sy;
translateBack.setTranslate(left+tx, top+ty); scale.setScale(sx,sy);
var N = tlist.numberOfItems; translateBack.setTranslate(left+tx, top+ty);
tlist.appendItem(translateBack); var N = tlist.numberOfItems;
tlist.appendItem(scale); tlist.appendItem(translateBack);
tlist.appendItem(translateOrigin); tlist.appendItem(scale);
tlist.appendItem(translateOrigin);
canv.recalculateDimensions(cur_shape);
lastBBox = cur_shape.getBBox(); canv.recalculateDimensions(cur_shape);
}, lastBBox = cur_shape.getBBox();
mouseUp: function(opts) { },
var mode = canv.getMode(); mouseUp: function(opts) {
if(mode !== mode_id) return; var mode = canv.getMode();
if(mode !== mode_id) return;
if(opts.mouse_x == start_x && opts.mouse_y == start_y) {
return { if(opts.mouse_x == start_x && opts.mouse_y == start_y) {
keep: false, return {
element: cur_shape, keep: false,
started: false element: cur_shape,
} started: false
} }
canv.setMode("select") }
return { canv.setMode("select")
keep: true, return {
element: cur_shape, keep: true,
started: false element: cur_shape,
} started: false
} }
} }
}); }
});
{"data": {
"cards_clubs": "m107.57338,275.50809c15.10838,-15.77673 27.93053,-34.56763 33.34637,-55.90254c-16.19595,12.31328 -31.05006,32.11845 -53.64258,31.36813c-17.05595,0.97891 -37.37346,0.99548 -49.37947,-13.26945c-26.83,-21.5751 -34.03729,-64.69673 -12.00568,-92.15404c15.07669,-19.82526 41.4039,-28.23172 65.56467,-25.25816c15.22319,-6.45935 -2.97749,-22.81502 -4.80785,-33.02267c-11.33012,-37.02704 15.36169,-81.44029 54.60988,-85.70572c28.15103,-4.0415 55.67099,14.18231 69.44571,37.83293c7.4856,16.54877 3.58533,35.33045 1.83887,52.49866c-5.88113,8.62766 -20.94342,29.50022 0.55099,27.85616c21.2518,-0.33633 43.69397,5.90277 57.70761,22.8026c20.49747,22.76067 22.37766,60.37286 1.7551,83.63007c-10.90869,14.16582 -27.2782,25.50356 -45.80551,24.87234c-18.13391,1.83067 -37.77023,-2.10338 -50.62924,-15.92061c-5.48438,-3.84309 -18.92297,-18.36311 -18.91833,-15.17883c13.43222,27.98354 28.62112,57.04413 55.49167,74.38477c9.60062,7.71954 -14.62323,2.41226 -20.4874,3.98563c-35.53012,0.0314 -71.06009,0.06342 -106.59021,0.09497c7.31842,-7.63818 14.6373,-15.27603 21.9554,-22.91422z",
"cards_diamonds": "m34.92883,153.9321c25.56111,-56.62673 71.64644,-104.95768 110.85236,-152.92286c45.60773,30.78102 85.01025,98.49872 119.29071,145.66264c-30.57587,54.55344 -74.58923,104.23671 -114.23947,153.1615c-42.74368,-44.7616 -79.29648,-95.90262 -115.90359,-145.90128z",
"cards_hearts": "m106.76112,245.09012c-77.74644,-57.80281 -105.54389,-94.36783 -105.76917,-139.13003c-0.20544,-40.80623 34.10907,-80.19025 69.67002,-79.96313c17.75755,0.11364 55.84863,15.13257 69.33681,27.33919c6.79614,6.1504 10.01512,5.54391 25.146,-4.73779c41.17987,-27.98239 81.39243,-28.56973 107.43585,-1.56907c41.62292,43.15273 34.04501,94.68497 -21.78392,148.13782c-29.68187,28.41864 -94.50056,78.8349 -101.35565,78.8349c-2.08591,0 -21.29187,-13.01038 -42.67994,-28.9119z",
"cards_spades": "m92.84135,287.13989c18.3756,-17.73279 31.81261,-40.18849 43.07161,-62.94162c6.87787,-9.075 0.36623,-17.01425 -9.00183,-9.3188c-24.07579,16.07495 -56.84848,21.58751 -82.91551,6.92194c-29.46779,-15.23779 -42.75618,-51.47162 -36.07021,-83.04361c4.23415,-31.99545 27.52112,-57.07481 52.80524,-75.08997c29.04437,-20.7771 60.40868,-38.61331 86.95355,-62.67224c11.08365,0.22219 19.42508,17.61496 31.35349,22.21747c31.67316,23.59131 69.20874,40.95643 94.15042,72.50237c12.60098,17.9752 19.78281,40.10946 20.58459,61.98948c-3.83926,29.67093 -21.5314,60.96272 -52.04169,69.41241c-26.37521,7.98038 -53.51129,-2.14038 -76.49545,-15.01619c-2.80743,-0.60251 -13.10471,-8.7151 -9.02362,-2.41039c13.74066,28.19803 28.79581,56.19804 50.59952,79.09325c1.28156,2.89285 11.33243,9.75613 5.98334,9.64709c-44.76935,0 -89.53856,0 -134.30794,0c4.78471,-3.7637 9.5696,-7.5275 14.35449,-11.2912z",
"chess_bishop": "m61.92021,296.91153c0.43627,-9.82327 20.22808,-4.98053 9.33225,-14.55078c3.63447,-11.80536 14.91982,-19.66748 21.741,-29.79436c5.22913,-8.62125 17.00826,-19.01086 11.31252,-29.67047c-10.46021,-5.58662 -7.49181,-18.00824 5.30239,-15.28014c8.2272,-7.58801 8.79371,-20.26302 11.57766,-30.59467c2.52694,-12.36574 4.07327,-24.95554 3.66998,-37.5896c-14.99698,0.03661 -30.27584,-0.68196 -44.73978,-4.74928c2.8019,-11.20453 20.86148,-8.79659 28.26084,-15.67982c-6.87532,-6.18329 13.89957,-5.56496 8.46355,-15.34472c-0.37302,-11.20033 -9.19685,-14.44135 -16.26585,-22.60765c-9.44371,-12.76132 5.36173,-25.51221 13.58463,-34.13964c9.16566,-9.37672 19.64847,-19.36716 22.45389,-32.62941c-3.77451,-3.10155 -12.3967,-7.54239 -3.59866,-11.78228c12.01596,-2.03703 24.83499,-2.28521 36.61118,1.05654c7.81644,7.61585 -11.93045,8.03119 -3.43417,17.63365c10.07373,12.07176 -3.50795,18.30174 -11.52704,25.27969c-4.66763,5.89621 -18.59915,13.67189 -16.20224,19.78346c13.63968,-0.47554 21.5871,-13.67976 31.31615,-21.49704c10.67101,-13.68708 20.99446,8.43092 27.81822,15.94714c8.40642,11.39094 2.60674,26.70086 -10.05556,31.59287c-6.28001,6.46729 -10.44972,24.88914 4.57674,22.14657c8.72636,3.17196 -8.52979,3.51371 1.37608,6.446c6.58298,2.52787 32.25821,8.30554 18.1142,16.0547c-12.00471,2.71368 -24.40523,2.6017 -36.6002,1.50584c-0.75204,18.52477 1.89484,36.97644 7.35446,54.6958c1.35513,5.04123 2.71027,10.08244 4.06541,15.12361c6.52129,-0.129 19.98573,-1.55484 13.76321,9.18311c-13.08994,7.21928 -5.0789,22.41203 2.17738,31.05447c8.99446,11.37192 22.40833,22.01788 22.98288,37.58719c3.59734,2.14404 15.56946,8.03415 12.10645,12.64545c-57.30759,-0.2937 -114.6481,0.84897 -171.9265,-1.25046l-1.98901,-0.18246l-1.62205,-0.39337l0,0z",
"chess_king": "m75.6993,294.60599c-8.08068,-9.43317 12.65705,-9.68567 9.39906,-20.14252c5.95673,-13.85672 21.44485,-22.24414 23.72572,-37.99019c-6.28166,-4.37628 -9.89445,-14.96013 2.0899,-13.70361c8.78859,-6.61539 7.6902,-20.15297 10.33321,-30.0876c2.47588,-16.03471 3.03656,-32.26408 4.10001,-48.43053c-10.16894,-0.78108 -20.58942,-0.23701 -30.49778,-2.84268c0.28501,-10.75136 20.44619,-6.62604 21.3638,-16.77121c14.65907,-0.2649 0.81196,-22.15992 -5.15776,-27.38371c-7.64118,-8.81222 -12.7306,-22.72323 -6.92168,-33.60618c8.30865,-5.52043 27.09519,-2.1601 26.24604,-16.66769c-5.65058,-3.22095 -12.82484,-1.17552 -19.15805,-1.74514c0.38948,-6.7649 0.77895,-13.52979 1.16843,-20.29469c8.37558,-0.64424 16.75118,-1.28853 25.12676,-1.93283c-4.25133,-4.41846 -10.61392,-7.6702 -12.20608,-13.92034c5.41558,-8.90246 18.46751,-8.1166 27.81776,-8.03243c9.09207,-0.62713 25.66919,5.43749 13.27614,15.20592c-1.00447,2.39887 -10.78024,8.36352 -4.73895,7.71326c7.73515,0 15.47028,0 23.20541,0c-0.02223,6.6133 -0.20001,13.29232 1.35312,19.76423c-5.90448,4.39723 -25.05112,-3.75612 -19.59946,9.81149c6.13853,5.67249 15.53992,5.52279 23.32581,8.02098c4.54138,0.45371 8.15405,1.63713 6.5175,6.94557c0.85359,9.85596 -1.63307,19.77049 -8.40776,27.25217c-4.79567,7.80693 -15.56667,17.58031 -12.3781,26.61691c6.03265,-0.98199 10.87871,2.97905 6.06032,7.43356c4.94479,3.66121 22.35728,2.82278 18.59119,11.98875c-8.82205,2.92029 -18.29916,1.70366 -27.45192,2.00166c2.43703,25.01987 5.80666,50.04211 11.43709,74.54305c3.28979,5.43672 16.35808,9.61523 5.63309,16.70296c-4.00256,13.19919 8.78183,23.08223 16.81097,31.55379c8.82797,6.61176 4.54482,19.91519 17.0338,22.03693c9.83562,9.52774 -13.5036,9.27408 -19.49568,9.29486c-39.66827,0.42773 -79.37933,1.02615 -119.03208,-0.25211c-3.24605,-0.40967 -7.25645,-0.31595 -9.56982,-3.08264z",
"chess_knight": "m100.17753,299.2356c-10.0382,0.34137 -24.72987,-4.84531 -14.46609,-16.41525c11.17445,-4.40472 -1.98608,-19.00409 9.21265,-25.88123c8.98889,-12.79953 21.20518,-24.48807 24.89179,-40.11865c-0.57252,-10.60066 -13.22608,-16.87427 -7.18922,-28.60765c-5.92265,-18.77635 -4.55389,-40.38806 6.25748,-57.26643c9.18032,-15.67659 20.32635,-32.28713 19.15084,-51.25797c-11.5139,4.80804 -23.70148,9.0206 -36.37307,6.83708c-11.91311,-1.1064 -22.59742,8.54017 -34.74928,3.29494c-12.31807,-2.55921 -19.64501,-19.02957 -10.4606,-28.65753c10.03679,-8.57325 24.78339,-8.84916 34.35549,-18.41713c12.62932,-10.46186 24.31081,-24.61204 41.71716,-26.46155c7.69322,-1.76131 10.99294,-9.49197 15.25148,-15.2854c3.53894,9.18849 9.69408,17.31353 18.95801,21.387c18.83824,10.9118 23.5276,33.98066 30.47462,52.94444c5.13654,14.85179 9.41592,30.35814 18.01733,43.6171c0.09145,6.36343 -9.56343,9.05308 -3.04225,16.51302c3.39153,20.2325 3.53752,40.95071 3.23686,61.41966c-5.72005,10.01691 -10.93028,21.19722 -3.29993,32.69295c5.09689,14.05096 17.7905,23.26645 24.03563,36.52565c3.53024,6.8656 -6.88226,16.83319 6.09091,15.10654c11.84755,6.2681 2.28101,21.56821 -9.50232,17.11713c-44.15834,1.12289 -88.41394,2.24417 -132.5675,0.9133z",
"chess_pawn": "m76.17518,297.98557c-10.50418,1.59836 -25.59558,-8.37918 -12.29734,-17.44669c11.25366,-5.8967 0.45475,-21.25174 12.35514,-28.71019c12.10069,-16.52 24.98341,-33.40712 31.01369,-53.22789c-0.84142,-9.49573 -19.64921,-25.21422 -0.595,-28.29408c15.7114,1.82648 9.96503,-21.69583 15.39529,-31.88779c3.26528,-15.46995 5.63882,-31.19783 5.05293,-47.04268c-10.94164,-0.30554 -22.10724,0.96841 -32.83411,-1.63306c-6.84238,-8.98132 15.45903,-13.45317 19.13895,-21.55999c7.72121,-11.65172 -11.3031,-24.52544 -3.15941,-38.29919c5.20168,-20.85055 29.26575,-34.36854 49.62741,-26.73076c21.08499,5.46792 36.67119,30.37529 26.64961,51.09357c-0.80009,3.99703 -7.062,9.17959 -4.97066,12.36269c9.12987,6.33601 19.70087,11.85771 25.48528,21.64108c-8.18987,5.93826 -21.89375,1.4159 -32.1122,4.23674c-9.29645,8.24593 -0.11353,25.10609 0.36266,36.41936c2.90009,12.9261 5.46037,25.96617 8.78381,38.77452c6.98657,2.72525 21.33679,5.88095 13.4649,17.20207c-11.22217,9.11032 -5.7289,23.62137 0.60231,33.84465c7.87996,15.78793 21.40668,27.84862 29.69345,43.27188c3.07736,7.12057 -7.92374,19.7316 5.78708,16.78259c14.86404,3.15744 5.96938,23.76761 -7.3875,18.8981c-49.21407,1.73288 -98.52922,2.43631 -147.74446,0.51953l-2.31185,-0.21448l0,0z",
"chess_queen": "m59.54884,298.46313c-11.18457,2.51251 -19.80814,-14.30008 -5.94004,-16.129c12.20336,0.23074 -3.0349,-11.94995 7.98012,-16.05304c12.67021,-12.36537 25.23749,-25.26018 33.3575,-41.17609c-4.09126,-5.42482 -10.84344,-10.60782 -9.96117,-18.03085c7.964,-2.71161 19.82806,-0.87375 20.29981,-13.44502c7.24239,-22.68985 9.1741,-46.67986 10.76167,-70.3136c-7.99255,-6.33596 -24.45116,-0.33371 -35.62089,-3.56097c-16.94488,-4.5746 6.31873,-13.33291 13.78075,-12.6113c6.70493,0.01006 16.63324,-4.12222 5.41084,-7.2804c9.46686,-0.43687 23.08297,-12.44518 7.51486,-16.77373c11.54188,-8.28655 2.64816,-26.31929 -2.17102,-36.68976c-7.265,-12.52285 -19.21146,-21.59242 -32.71435,-26.42871c-2.18616,-12.77 18.63421,-8.99565 27.07909,-9.65835c12.78728,0.48775 25.82639,-0.15282 36.96732,-7.11507c15.05278,-6.96464 27.8495,4.65901 41.61934,7.11611c13.92807,0.89699 28.41634,-2.50577 41.97807,1.44028c4.20209,2.98911 11.18788,7.71034 2.77457,9.97613c-16.06789,8.94404 -31.07338,22.15693 -35.10127,40.92605c-6.0766,10.44077 4.6955,19.50048 -5.15381,26.98807c-0.10249,8.80961 22.85634,10.04067 10.00395,14.37878c8.80815,4.77542 27.69864,1.76332 29.62625,12.3696c-7.99612,6.2903 -19.2092,3.80788 -28.79007,4.39512c-3.2489,1.10706 -11.41316,-2.70125 -10.17032,2.89742c-0.6366,25.08775 5.87923,49.75521 12.1806,73.83221c0.00804,11.79608 29.09497,5.10777 12.92737,18.49597c-11.94247,10.28146 5.56685,24.68452 11.63272,33.82986c8.25099,10.03221 22.89711,15.11021 21.67468,29.8362c8.40468,0.60507 18.40166,13.69095 6.78131,16.95151c-62.8902,1.31946 -125.82766,2.22778 -188.72791,1.83258z",
"chess_rock": "m70.40736,299.11804c-15.60727,2.87628 -15.90823,-19.81082 -1.8931,-20.53482c-4.2011,-9.73361 -0.98556,-21.67557 5.22356,-30.68398c8.90442,-15.05035 22.29623,-30.00999 19.52936,-48.8515c-0.95786,-9.8022 -13.10349,-27.37677 5.72565,-24.85997c5.09087,-9.77498 2.13017,-24.16621 5.9483,-35.39389c3.33424,-21.28385 10.75552,-43.9948 2.86147,-65.09612c-4.97705,-11.23243 -17.62387,-18.62589 -16.26645,-32.35733c-1.42947,-13.39034 -0.95647,-26.88279 0.60455,-40.23392c6.07738,0.50975 12.84039,-1.27954 18.38155,1.475c-0.04153,12.96106 12.26991,10.08973 10.7935,-0.92486c3.23881,-1.28251 8.60017,-0.18413 12.6562,-0.55014c18.03256,0 36.06522,0 54.09778,0c-2.06311,7.51434 3.5195,17.19948 10.5887,8.35272c-1.93379,-11.75267 14.25911,-7.86334 10.37854,2.24694c0.22855,13.39515 1.87041,27.25403 -1.89201,40.29753c-6.12787,5.2086 -6.22449,15.45995 -13.90137,21.60233c-6.16908,11.51656 -3.45045,25.43306 -2.7644,37.9428c2.61279,18.51363 6.92676,36.79671 8.00221,55.52328c-0.76923,10.18126 20.18948,7.18474 11.15244,19.71645c-9.87662,8.41151 -4.0954,22.61668 -0.18413,32.66171c7.71916,17.36203 23.99019,32.95758 21.5343,53.32025c-1.94743,8.89606 14.16618,5.88821 9.97758,17.34372c-0.12151,14.11871 -21.10172,5.04239 -30.39526,8.00793c-46.7146,0.56656 -93.44374,1.44144 -140.159,0.99585z"
}
}
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>anonymous_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>nexedi.json</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/octet-stream</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -733,7 +733,7 @@ w.beginPath();w.globalAlpha=0.5;w.moveTo(0.5,C);w.lineTo(0.5,0);w.moveTo(C,0.5); ...@@ -733,7 +733,7 @@ w.beginPath();w.globalAlpha=0.5;w.moveTo(0.5,C);w.lineTo(0.5,0);w.moveTo(C,0.5);
"g");a(c,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var g=$("#canvas_background");g.after(c);c=e.createElementNS("http://www.w3.org/2000/svg","pattern");a(c,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var d=e.createElementNS("http://www.w3.org/2000/svg","image");a(d,{x:0,y:0,width:100,height:100});c.appendChild(d);$("#svgroot defs").append(c);e=e.createElementNS("http://www.w3.org/2000/svg","rect");a(e,{width:"100%",height:"100%", "g");a(c,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var g=$("#canvas_background");g.after(c);c=e.createElementNS("http://www.w3.org/2000/svg","pattern");a(c,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var d=e.createElementNS("http://www.w3.org/2000/svg","image");a(d,{x:0,y:0,width:100,height:100});c.appendChild(d);$("#svgroot defs").append(c);e=e.createElementNS("http://www.w3.org/2000/svg","rect");a(e,{width:"100%",height:"100%",
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(e)}return{name:"view_grid",zoomChanged:function(p){l&&o(p)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){methodDraw.curConfig.showGrid=l=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{methodDraw.curConfig.showGrid= x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(e)}return{name:"view_grid",zoomChanged:function(p){l&&o(p)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){methodDraw.curConfig.showGrid=l=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{methodDraw.curConfig.showGrid=
l=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","inline");o(b.getZoom())}}}}]}});methodDraw.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(L.buttons)}function o(J){var H=v[J];if(H){L=H;H.buttons.length||e(J,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+J+".json",function(U){L=v[J]={data:U.data,size:U.size,fill:U.fill};e(J,U);a()})}}function e(J,H){var U=L.size||300,R=L.fill||false,N=U*0.05;N=[-N,-N,U+N*2,U+N*2].join(" ");U=R?0:U/30;U=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+ l=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","inline");o(b.getZoom())}}}}]}});methodDraw.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(L.buttons)}function o(J){var H=v[J];if(H){L=H;H.buttons.length||e(J,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+J+".json",function(U){L=v[J]={data:U.data,size:U.size,fill:U.fill};e(J,U);a()})}}function e(J,H){var U=L.size||300,R=L.fill||false,N=U*0.05;N=[-N,-N,U+N*2,U+N*2].join(" ");U=R?0:U/30;U=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
N+'"><path fill="#333" stroke="transparent" stroke-width="'+U+'" /></svg></svg>',"text/xml");U.documentElement.setAttribute("width",40);U.documentElement.setAttribute("height",40);U=$(document.importNode(U.documentElement,true));R=H.data;L.buttons=[];for(var ca in R){N=R[ca];var la=U.clone();la.find("path").attr("d",N);N=la.wrap('<div class="tool_button">').parent().attr({id:Q+"_"+ca,title:ca});L.buttons.push(N[0])}}var b,l,s=methodDraw.canvas,c,g,d,p=s.getRootElem(),w={},C={basic:"Basic",object:"Objects", N+'"><path fill="#333" stroke="transparent" stroke-width="'+U+'" /></svg></svg>',"text/xml");U.documentElement.setAttribute("width",40);U.documentElement.setAttribute("height",40);U=$(document.importNode(U.documentElement,true));R=H.data;L.buttons=[];for(var ca in R){N=R[ca];var la=U.clone();la.find("path").attr("d",N);N=la.wrap('<div class="tool_button">').parent().attr({id:Q+"_"+ca,title:ca});L.buttons.push(N[0])}}var b,l,s=methodDraw.canvas,c,g,d,p=s.getRootElem(),w={},C={basic:"Basic",nexedi:"Nexedi Shapes",object:"Objects",
symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},v={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z", symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},v={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z",
triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z", triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",
heptagon:"m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z",decagon:"m1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z",dodecagon:"m1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z", heptagon:"m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z",decagon:"m1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z",dodecagon:"m1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment