Corrected bbox problem for <metadata> elements.
Imported SVG now inserted into a new <g> element instead of child <svg> element. Sizing of imported SVG will still be wrong. Added three example clipart images. git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1422 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
cc20d81633
commit
5b0f6e480c
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="205.5" xmlns="http://www.w3.org/2000/svg" height="255.87">
|
||||
<g display="inline">
|
||||
<title>Layer 1</title>
|
||||
<path id="svg_1" d="m10.671,231.42c89.543,56.086,188.11-10.029,193.33-94.559-1.7286-101.53-92.171-150.4-160.16-128.01,35.129,15.844,73.4,62.729,73.871,88.013-3.4428,7.5157-5.8714,16.373,1.5286,18.844-2,12.857-18.486,33.571-21.043,40.643-2.5571,7.0714,2.2143,9.8443,5.4429,10.357,0.2,6.0586-4.4429,8.3572-5.3572,12.156-7.9,3.13-8.4714,9.9872-7.3286,14.844-19.714,18.571-20.571,27.143-80.286,37.714z" stroke="#000" stroke-width="5" fill="#f6c700"/>
|
||||
<path id="svg_3" d="m98.193,180.83c2.5851-3.421,7.4852,2.5632,7.1642,5.1572-0.32201,2.594-0.67928,4.0227-3.7143,5.2857" stroke="#000" stroke-width="5" fill="none"/>
|
||||
<path id="svg_4" d="m104.11,166.92c5.5357-0.49998,14.643,3.8472,17.75,2.37,3.1072-1.4771,3.3929-4.6686,2.3572-6.5129" stroke="#000" stroke-width="5" fill="none"/>
|
||||
<path id="svg_5" d="m125.64,171.49c-3.9286,8.2143-3.8572,18.987,4.2143,33.286" stroke="#000" stroke-width="2" fill="none"/>
|
||||
<path id="svg_6" d="m117.91,97.816c9.572,1.8,16.143-9.0571,20.8-10.101,3.057-1.0986,14.057,27.473,21.057,35.616" stroke="#000" stroke-width="5" fill="none"/>
|
||||
<path id="svg_7" d="m129.49,105.78c7.6428-3.6429,11.179,6.5357,12.607,10.929,1.4286,4.3928,7.1428,5.1071,10.857,5.5" stroke="#000" stroke-width="2" fill="none"/>
|
||||
<path id="svg_8" d="m133.91,114.75c0.87856-0.13215,1.6214,4.3107,2.5143,6.8236,1.2857-0.90571,0.82143-1.5129,1.3928-1.9771,0.96429-0.82143,1.6071,3.6657,2.3572,5.1429,4.8572-0.00001,5.4643,0.89286,5.4286,1.9286-3.25,0.21429-5.1786,0.67857-7.5,1.6071-3.7857,2.3214-6.0357,6.6072-7,5.4286-0.32143-1.5,3.3571-4.5357,4-5.4286-3.0714-5.1428-2.0714-13.393-1.1929-13.525z" stroke="#000" fill="#000"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="100" width="100">
|
||||
<path stroke-linejoin="round" d="M36.536,32.822c12.699-31.856,13.17-31.734,26.356-1.061,34.15,2.198,39.388,9.622,6.513,23.932,19.821,46.047-0.792,28.383-19.842,13.178-22.358,25.013-29.541,22.639-18.782-12.118-7.282-8.501-45.095-18.741,5.755-23.931z" fill-rule="evenodd" stroke="#000" stroke-linecap="round" stroke-miterlimit="4" stroke-width="5" fill="#FF0"/>
|
||||
</svg>
|
After Width: | Height: | Size: 489 B |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 9.2 KiB |
|
@ -5694,7 +5694,6 @@ function BatchCommand(text) {
|
|||
// This function returns false if the import was unsuccessful, true otherwise.
|
||||
|
||||
// TODO: create a new layer for the imported SVG
|
||||
// TODO: create a group and add all <svg> children to the group
|
||||
// TODO: properly size the new group
|
||||
this.importSvgString = function(xmlString) {
|
||||
try {
|
||||
|
@ -5705,15 +5704,16 @@ function BatchCommand(text) {
|
|||
|
||||
var batchCmd = new BatchCommand("Change Source");
|
||||
|
||||
// remove old svg document
|
||||
// var oldzoom = svgroot.removeChild(svgcontent);
|
||||
// batchCmd.addSubCommand(new RemoveElementCommand(oldzoom, svgroot));
|
||||
// import new svg document into our document
|
||||
var importedNode = svgdoc.importNode(newDoc.documentElement, true);
|
||||
|
||||
// import new svg document
|
||||
if (current_layer) {
|
||||
current_layer.appendChild(svgdoc.importNode(newDoc.documentElement, true));
|
||||
// add all children of the imported <svg> to the <g> we create
|
||||
var g = svgdoc.createElementNS(svgns, "g");
|
||||
while (importedNode.hasChildNodes()) { g.appendChild(importedNode.firstChild); }
|
||||
current_layer.appendChild(g);
|
||||
}
|
||||
// svgcontent = svgroot.appendChild(svgdoc.importNode(newDoc.documentElement, true));
|
||||
|
||||
// change image href vals if possible
|
||||
// $(svgcontent).find('image').each(function() {
|
||||
// var image = this;
|
||||
|
@ -5734,23 +5734,23 @@ function BatchCommand(text) {
|
|||
// });
|
||||
|
||||
// Fix XML for Opera/Win/Non-EN
|
||||
// if(!support.goodDecimals) {
|
||||
// canvas.fixOperaXML(svgcontent, newDoc.documentElement);
|
||||
// }
|
||||
if(!support.goodDecimals) {
|
||||
canvas.fixOperaXML(svgcontent, importedNode);
|
||||
}
|
||||
|
||||
// recalculate dimensions on the top-level children so that unnecessary transforms
|
||||
// are removed
|
||||
// var deepdive = function(node) {
|
||||
// if (node.nodeType == 1) {
|
||||
// var children = node.childNodes;
|
||||
// var i = children.length;
|
||||
// while (i--) { deepdive(children.item(i)); }
|
||||
// try {
|
||||
// recalculateDimensions(node);
|
||||
// } catch(e) { console.log(e); }
|
||||
// }
|
||||
// }
|
||||
// deepdive(svgcontent);
|
||||
var deepdive = function(node) {
|
||||
if (node.nodeType == 1) {
|
||||
var children = node.childNodes;
|
||||
var i = children.length;
|
||||
while (i--) { deepdive(children.item(i)); }
|
||||
try {
|
||||
recalculateDimensions(node);
|
||||
} catch(e) { console.log(e); }
|
||||
}
|
||||
}
|
||||
deepdive(importedNode);
|
||||
|
||||
// var content = $(svgcontent);
|
||||
|
||||
|
@ -5793,9 +5793,8 @@ function BatchCommand(text) {
|
|||
// identifyLayers();
|
||||
|
||||
// reset transform lists
|
||||
// svgTransformLists = {};
|
||||
// canvas.clearSelection();
|
||||
// svgroot.appendChild(selectorManager.selectorParentGroup);
|
||||
svgTransformLists = {};
|
||||
canvas.clearSelection();
|
||||
|
||||
addCommandToHistory(batchCmd);
|
||||
call("changed", [svgcontent]);
|
||||
|
@ -7601,9 +7600,11 @@ function BatchCommand(text) {
|
|||
|
||||
$.each(elems, function(i, elem) {
|
||||
var cur_bb = bboxes[i];
|
||||
var offset = getOffset(elem);
|
||||
max_x = Math.max(max_x, cur_bb.x + cur_bb.width + offset);
|
||||
max_y = Math.max(max_y, cur_bb.y + cur_bb.height + offset);
|
||||
if (cur_bb) {
|
||||
var offset = getOffset(elem);
|
||||
max_x = Math.max(max_x, cur_bb.x + cur_bb.width + offset);
|
||||
max_y = Math.max(max_y, cur_bb.y + cur_bb.height + offset);
|
||||
}
|
||||
});
|
||||
|
||||
full_bb.width = max_x - min_x;
|
||||
|
|
Loading…
Reference in New Issue