2 Attachment(s)
Manipulating XAR files - animation
For those who are interested here is explanation of methods and tools used to create this animation: http://www.talkgraphics.com/showthread.php?t=31638. It might be also useful to anyone who is interested in manipulating XAR files with own scripts.
What tools do we need? Well Xtreme of course :), inteligent GIF animation editor is useful (to optimize final animation), couple of my toys and scripts for xar files manipulation (attached) and PHP to run these scripts. Minimal PHP is packed in second attachment.
Whats our goal? We have XAR file containing line drawing - sequence of path objects - and we want to create XAR animation with these lines distributed in separate frames. First frame should contain the first line of our drawing, second should contain first and second line together etc... last frame shows whole drawing.
Notes on input file:
Don't use big files at first, rendering of final animation may take a while.
Don't use closed or filled paths, these won't appear in final animation (howewer their presence in input file should'nt cause trouble). Script works only with simple lines (nonfilled nonclosed paths) and ignores all formatting (dont expect it will preserve any colours :).
How to achieve this? Well we can do it by hand :D but using automatic script makes whole thing a lot easier. First attachement contains the script that can do the job - xml_draw.php. Problem is it doesnt work directly with XAR files, it works with its XML represantation instead. Why XML? It's human readable so testing is easier, one can manipulate it by hand if necessary, scripting languages usualy incorporate DOM or other methods to work with XML documents... Also XML tree structure is very similar to internal tree structure of XAR files.
It means we need to create XML represantation of our drawing first. Attached commandline tool - xar2xml.exe - will perform conversion.
xar2xml mydrawing.xar mydrawing.xar.xml
will produce file mydrawing.xar.xml representing mydrawing.xar
The conversion tool cant understand most of XAR files yet so the XML contains a lot of hex strings representing original binary data like:
<linewidth data="f4010000"/>
But it can translate paths, thats important:
<path_relative_stroked d="M 19764 136479 C 23967 137625 C 27585 137903 C 32037 137161">
Now we can run xml_draw.php
php-cgi xml_draw.php mydrawing.xar.xml my_animation.xar.xml
... we have XML represantation of the animation in my_animation.xar.xml. Next its neccessary to convert animation back to XAR format so Xtreme can render it. Theres no xml2xar.exe tool yet (work in progress :) - we can use temporary solution in form of xml2xar.php script.
Nothing suprising about the command
php-cgi xml2xar.php my_animation.xar.xml my_animation.xar
If nothing went wrong you should be able to open my_animation.xar in Xtreme and the file should contain required "line by line" animation. Make necessary changes to this file - like applaying width, colour and profile to lines - and export GIF animation.
In case of bigger drawings the GIF file can be big for web presentation ( 500kB for 450x700px animation with 450 lines) so some kind of optimization should be applied. Xtreme won't do this for you. Gif movie gear shrinked my animation from 500 to 75. After that... well nothing :)
Thats all, really :) We're done.
Re: Manipulating XAR files - animation
Oooo... That is what I have been waiting for... Gotta try this. As soo as I finish my other work.:)
Re: Manipulating XAR files - animation
Ya John, now you can animate your train.
Re: Manipulating XAR files - animation
Re: Manipulating XAR files - animation
Will this work with Flash?
Re: Manipulating XAR files - animation
The K4 would be neat to see animated like this... The train itself is only 19 objects with the smoke and the steam there is a total of 505 objects... so I doubt it would look that cool. I do not know if xpro would react well if I broke up the main shapes.:)
1 Attachment(s)
Re: Manipulating XAR files - animation
Quote:
Originally Posted by
gwpriester
Will this work with Flash?
It should work but Im using Xtreme 2 so i cant test it.
Edit: Yes, flash export is OK :)
Re: Manipulating XAR files - animation
Hi Suvek,
Warmest regards for your work!
You are an artist and software developer too.
Great! :)
This animation remember me the application OpenCanvas.
Hopefully Xara developers will offer a
built-in way to create this kind of animation
using only Xara Xtreme.
Lately, i have been working with Animated Gif
and your mention of Gif Movie Gear is really useful.
Thanks!
By the way, for some time, i have been considering
to add a Xara Export option to my hobby project
named "penTool" that you could see here:
http://geocities.com/capellan2000/
Would you share with me some hints to
write the Xara binary file format?
Thanks in advance!
alejandro
Re: Manipulating XAR files - animation
Hi,
I really like the direction of this thread: Adding some code manipulating files from Xara drawing packages! :)
As Xara Extreme Pro is offering SVG export now, it might be a litle easier to use that as input to such code manipulating a drawing into say an animation. But it seems that you have a good grip on your PHP code! :)
I myself is more to .NET programming, but have yet to come up with some cool code like yours! :)
It would be nice if we could see some examples done by the Xara programmers as to how to work with either the native XAR format or for instance the (XML based) SVG versions! Perhaps in it's own "developer discussion group"
Thank you for this thread - please send more!
Re: Manipulating XAR files - animation
I wonder if we could make this post sticky for a while... At least until I am a little less busy. I would hate to have this buried before I get a free evening or so to play with it. Just really busy at the moment.:)
Re: Manipulating XAR files - animation
John if you add the URL to your favorites you can access it anytime without it being a sticky thread.
Re: Manipulating XAR files - animation
Oh yea... forgot about that... Don't use it much here at home...:rolleyes: :)
Re: Manipulating XAR files - animation
Quote:
Originally Posted by
capellan
"penTool" seems interesting, i'll take a closer look at it :)
I can share... useful hint to begin with can be to take look at latest docs on xar format but youve probably done that already :) http://www.xara.com/support/docs/web...atDocument.pdf Definitely better than older version(s) that was inarcurrate and confusing in some parts. XarLib may be also pretty helpful
Netsi> SVG export can help but it has its disadvantages. Conversion is lossy and theres no svg import in Xtreme (or is it? :rolleyes: i don't have PRO version ) Native format is native format :)
If nothing terrible happens (harddisk failure :), small update (graphical frontend for easier use) and script for simple interpolated animation should appear soon.
Re: Manipulating XAR files - animation
Very impressive Suvek!
Thanks for sharing:)