Title Image

Don Xml's Grok This

The home of Don Demsak
Welcome to Don Xml's Grok This Sign in | Help
in Search

This Blog

Syndication

Site Sponsors

DonXml's All Things Techie

Relative Coordinates in Path Declarations and Animation

Joe Beda had asked for some of my thoughts on the importance of relative coordinates in declaring path segments and I started to create a long article describing the pro and cons of using relative coordinates, and explaining the difference between the XAML model and the SVG model, but it was taking so long to write, and it was delving into areas that I think most people don’t really care about.  So instead of the long post I’ll just put up my final analysis, and if there seems to be a need, I’ll delve deeper.


Relative coordinates are a godsend when coding vectors by hand.  In SVG relative coordinates are relative to the last reference point (which is typically the last point in the path declaration).  XAML’s relative coordinate declarations are relative to the starting point for the path.  SVG’s relative coordinate method is much easier to code by hand, since it is relative the last point.  XAML’s relative coordinate method is a bit harder, but still easier that absolute paths.  The other benefit of relative coordinates is the ability to clone the path (by using copy and paste).  You don’t need to recalc all the points along the path.  That being said, you probably shouldn’t copy and paste a path, and create a reusable canvas class (or Symbol in SVG).  But once you start using a development environment for creating vector graphics, the DE handles all the calculations for you, so relative coordinates are not really as important when compared with coding by hand.


The other major issue with relative coordinates is with animation.  In SVG the path data is buried within an attribute, and makes it almost impossible to animate using declarative methods like SMIL.  XAML, on the other hand, can be written to expose the path segments to declarative animation.  The problem comes when you animate a point that is used a reference point for relative coordinates.  By animating the reference point you create a nasty side effect of also animating all points that are relatively positioned according to the reference point.  Depending on how complex your path segments are, you can setup a cascading effect.  You basically create a bunch of implicit animations based on your explicit animation.  SVG doesn’t have this problem, because if you animate one point in the path data, the whole path is reparsed, but since XAML can be written to expose the path segments, it has to be processed differently.  In my opinion, although potentially useful, I don’t like implicit side effects, and would prefer that you couldn’t animate relative coordinates. 

Anyone else have an opinion on this?

DonXML Demsak

Published Tuesday, December 16, 2003 7:58 AM by donxml
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

TrackBack said:

December 16, 2003 7:59 AM

Chris Hanson said:

Fully relative coordinates aren't just "a godsend when coding vectors by hand." They're very good generically, because they reduce the amount of state that needs to be managed by your graphics architecture. With fully relative coordinates you only need to know the current transformation matrix; you're effectively drawing from the origin. This also makes mathematical operations on the whole path pretty easy.

Rather than going its own way, XAML and the WinFX imaging architecture should use the PostScript/PDF model just like Mac OS X and SVG do. It's widely-deployed, it's very well understood both in industry and in academia, and it has a number of properties (like fully relative coordinates) that make it sufficiently powerful for even the most advanced uses.

XAML and WinFX already represent a huge break with the past for Microsoft. Why not adopt industry best practices when making that break?
December 16, 2003 7:56 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

About donxml

I’m an independent consultant, specializing in .Net solutions architecture, based out of New Jersey who also doubles as an evangelist for XML, Domain Driven Design, enterprise architecture and .Net. I do not work for Microsoft, the W3C or any other big company that you may know of (at least not yet). I’ve been an indie for over ten years, and although I’ve been tempted a couple times to take a job with companies like Microsoft, I’ve haven’t found something better than my current situation. I work mostly with the large pharmaceuticals that are based here in New Jersey, and usually find myself on long term contracts. Definitely not the prototypical indie consultant, but it lets me dedicate time to my non-income generating activities like the developer community stuff, plus financing open source projects like XPathmania and MVP-XML. If you would like to talk to me about doing some contract work, just contact me via the contact page. My rates vary widely, depending on lots of different variables, but mostly distance from Jersey, and type of work. Plus, I’ve been known to donate some of my code for various projects.
Powered by Community Server, by Telligent Systems