XML Elves

XML Elves

<community>of XML and SVG Developers</community>


How to locate a g element

This is a discussion on How to locate a g element within the SVG Questions forums, part of the SVG Forums category; Howdy y'all this is my first post so forgive me if this has been asked before. I have a project ...


Go Back   XML Elves > SVG Forums > SVG Questions

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2009, 01:04 PM
Junior Member
 
Join Date: Jun 2009
Posts: 2
Default How to locate a g element

Howdy y'all
this is my first post so forgive me if this has been asked before. I have a project where I am receiving svg files with nested g elements. I need to be able to scale those elements programatically with ECMA. The end result is an html page with an embedded svg object with the g element scaled up or down as needed. There is also a top level viewport defined on the SVG that encompasses the entire SVG for screen scaling in the browser. My problem comes when I try to scale the g element in place.

I think I undstand the concept to make this happen, but the implementation is proving a little more difficult. So below is how I am going about it.

find x y coordinates of g element by calling g.getCTM() and using .e and .f as X and Y respectively
so

matrix=g.getCTM()
x=matrix.e
y=matrix.f

find x y coordinates of the viewport element by calling
farthestviewportelement= g.GetFarthestViewportElement

(tried this with svgroot element as well with identical results)

and then calling
matrix = farthestviewportelement.getCTM()
x1=matrix.e
y1=matrix.f

so I end up with

xlocation of g element I'm trying to find = (x+x1)
ylocation of g element I'm trying to find = (y+y1)

create the offset for my transform to the origin as follows
offset.x= xlocation - (xlocation*scalefactor)
offset.y= ylocation -(ylocation*scalefactor)

and then set the new transform on the g element

newtransform= transform(offset.x offset.y) scale(scalefactor) transform(-offset.x -offset.y)

The problem is that this works out to be close to correct, but not exactly right. Each time the g element ends up slightly out of place when scaled. In that it doesn't scale exactly around the center of the object. and of course when I reset the scale to its original value it's also out of place.

Does anyone have any ideas or examples I can look at to get this to work accurately . Close isn't good enough in this situation.

Thanks in advance for any advice.

Mr Johnathan Bravo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-31-2009, 01:43 AM
Junior Member
 
Join Date: Aug 2009
Posts: 2
Default

Thanks a lot.



___________________
NCIS dvd
House m.d dvd
Entourage Seasons 1-5 DVD Boxset
24 Hours Seasons 1-7 DVD Boxset
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-09-2009, 07:26 AM
Junior Member
 
Join Date: Jun 2009
Posts: 2
Default

Quote:
Thanks a lot.
umm... for what?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
element, locate


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -6. The time now is 06:26 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2

Emergency Data Recovery
Need emergency data recovery? Data Clinic have your solutions! Click here!


1 2 3 4 5 6 7 8 9 10 11