Re: SVG animations without SMIL


I spend a lot of time animating objects that have different path
descriptions. The problems vary:

(1) The major one is that SVG allows various bezier curves to be
interpolated to other bezier curves (eg Q to C) but insists that lines get
interpolated to lines (or at least that happens in the implementations). If
it was realised that lines are just shorthand for cubic beziers that would
eliminate that problem. That would solve many problems.

(2) Arcs are a pain. The best solution is to convert them into cubic
beziers. Short arcs you can do accurately with a single cubic but long arcs
need three. The real improvement would be to get rid of them ;-)

(3) Once you have done that converting the basic shapes is relatively
straightforward as long as you choose the starting point of ellipses and
circles OK

(4) Once you have them all as cubic beziers by suitable splitting or
merging you can get them to be the same number.

Doing this in a browser is relatively easy. Doing it in path descriptions
less so. My solution is really crude. I convert the path descriptions to
XML, transform them with XSLT, probably do some tinkering to get the number
of segments the same and convert the XML back to path descriptions.

One minor problem that I get occasionally is that I have a very long closed
path ending in Z. If the rounding along the way is significant you can get
an additional L added at the end during all my processing. Reading the spec
I am never sure whether that is a feature. Is the line that joins the final
point to the first always there or just occasionally. I could read the spec
either way.

On a separate point, I see there are plans to add other curve descriptions
to the path description. If that is done then it would be good to define a
canonical form for all path descriptions. I would obviously prefer to see
cubic beziers being that canonical form but you could choose lines or
something else, how about NURBS, that is what the previous ISO standards
(PHIGS etc) chose).


Received on Thursday, 4 June 2015 08:13:25 UTC