Open GoogleCodeExporter opened 9 years ago
Select an element
Grab height,width of bounding box of selected element
User is prompted for new values
current height is divided by the new height and this gives us a coefficient to
use in the transformation matrix
current width is divided by the new width and this give us a coefficient to use
in the transformation matrix
selected item is transformed using the transformation matrix and the
height/width coefficients calculated in the previous step
svgCanvas.recalculateAllSelectedDimensions(); is called to update the
dimensions and nodes
Original comment by nicholas.kyriakides@my.westminster.ac.uk
on 17 Feb 2013 at 11:10
function changeDimensions()
{
svgNode = svgCanvas.getSelectedElems()[0];
var transformw=prompt("Enter your new width");
var transformh=prompt("Enter your new height");
var lastw = svgNode.getBoundingClientRect().width;
var lasth = svgNode.getBoundingClientRect().height;
newW=transformw/lastw;
newH=transformh/lasth;
svgCanvas.changeSelectedAttribute("transform", "matrix(" + newW + ", 0, 0, " +
newH + ", 0, 0)");
svgCanvas.recalculateAllSelectedDimensions();
}
Original comment by nicholas.kyriakides@my.westminster.ac.uk
on 18 Feb 2013 at 10:42
wrong. The bbox calculations are highly unrealiable cross browser speaking.
Alexis ussed a bug against webkit couple of years ago however still the bbox
calculations are highly unrealiable to use as a reference value within
functions.
The coding above might work but it is unreliable. I suggest not accepting this
enhancement.
Nicholas
Original comment by nicholas.kyriakides@my.westminster.ac.uk
on 19 Feb 2013 at 3:30
I've been spamming this issue like a newsletter but is important IMHO. Raphael
implements a function that uses algebraic methods to calculate the paths width,
height, x, y. It can be substituted in place of the browsers bbox API in the
example above and produce accurate results. I will post a solution as soon as i
have one. I suggest accepting the enhancement now.
Original comment by nicholas.kyriakides@my.westminster.ac.uk
on 19 Feb 2013 at 3:24
Original issue reported on code.google.com by
nicholas.kyriakides@my.westminster.ac.uk
on 16 Feb 2013 at 4:10