Hi all, I am replacing the text of a text element with a new text string and am trying to shift the text element, either to the left or the right based on the the difference in old and new widths(so as to maintain the center alignment). Here is a sample code. I dont seem to be visually getting the desired results. Could somebody please help me with this. Am i doing something wrong ?
SVGOMTextElement textElement ...... .................................. oldWidth = textElement.getComputedTextLength(); .................................. change the text context of the textElement .................................. newWidth = textElement.getComputedTextLength(); SVGMatrix matrix = textElement.getTransform().getBaseVal().consolidate().getMatrix(); oldX = matrix.getE(); if (oldWidth > newWidth) { newX = oldX + ((oldWidth - newWidth) / 2); } else if (oldWidth < newWidth) { newX = oldX - ((newWidth - oldWidth) / 2); } matrix.setE(newX); Is something wrong in the above code. thanks, Ananth --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]