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