Shortened some of the attribute setting code

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@40 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Vidar Hokstad 2009-06-06 17:06:44 +00:00
parent 09fb1d6c5c
commit 3aa51e81c3
1 changed files with 6 additions and 24 deletions

View File

@ -266,33 +266,15 @@ function SvgCanvas(doc)
var size = Math.max( Math.abs(x - start_x), Math.abs(y - start_y) ); var size = Math.max( Math.abs(x - start_x), Math.abs(y - start_y) );
shape.setAttributeNS(null, "width", size); shape.setAttributeNS(null, "width", size);
shape.setAttributeNS(null, "height", size); shape.setAttributeNS(null, "height", size);
if(start_x < x) { shape.setAttributeNS(null, "x", start_x < x ? start_x : start_x - size);
shape.setAttributeNS(null, "x", start_x); shape.setAttributeNS(null, "y", start_y < y ? start_y : start_y - size);
} else {
shape.setAttributeNS(null, "x", start_x - size);
}
if(start_y < y) {
shape.setAttributeNS(null, "y", start_y);
} else {
shape.setAttributeNS(null, "y", start_y - size);
}
break; break;
case "select": case "select":
case "rect": case "rect":
if (start_x < x) { shape.setAttributeNS(null, "x", Math.min(start_x,x));
shape.setAttributeNS(null, "x", start_x); shape.setAttributeNS(null, "y", Math.min(start_y,y));
shape.setAttributeNS(null, "width", x - start_x); shape.setAttributeNS(null, "width", Math.abs(x-start_x));
} else { shape.setAttributeNS(null, "height", Math.abs(y-start_y));
shape.setAttributeNS(null, "x", x);
shape.setAttributeNS(null, "width", start_x - x);
}
if (start_y < y) {
shape.setAttributeNS(null, "y", start_y);
shape.setAttributeNS(null, "height", y - start_y);
} else {
shape.setAttributeNS(null, "y", y);
shape.setAttributeNS(null, "height", start_y - y);
}
break; break;
case "circle": case "circle":
var cx = shape.getAttributeNS(null, "cx"); var cx = shape.getAttributeNS(null, "cx");