Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Oct 2005
    Location
    Prague, Czech Republic
    Posts
    231

    Smile 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 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.
    Attached Files Attached Files

  2. #2
    Join Date
    May 2003
    Location
    Box Elder, SD, USA
    Posts
    4,034

    Default 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.
    John Rayner
    For my Photography see:
    http://www.draginet.com
    Facebook

  3. #3
    Join Date
    Apr 2004
    Location
    Minnesota, U.S.A.
    Posts
    468

    Default Re: Manipulating XAR files - animation

    Ya John, now you can animate your train.

  4. #4
    Join Date
    Feb 2007
    Location
    UK
    Posts
    21,313

    Default Re: Manipulating XAR files - animation

    Thanks Suvek
    -------------------------------
    Nothing lasts forever...

  5. #5
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,508

    Default Re: Manipulating XAR files - animation

    Will this work with Flash?

  6. #6
    Join Date
    May 2003
    Location
    Box Elder, SD, USA
    Posts
    4,034

    Default 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.
    John Rayner
    For my Photography see:
    http://www.draginet.com
    Facebook

  7. #7
    Join Date
    Oct 2005
    Location
    Prague, Czech Republic
    Posts
    231

    Default Re: Manipulating XAR files - animation

    Quote Originally Posted by gwpriester View Post
    Will this work with Flash?
    It should work but Im using Xtreme 2 so i cant test it.

    Edit: Yes, flash export is OK
    Attached Files Attached Files
    Last edited by Suvek; 13 March 2008 at 02:01 PM.

  8. #8

    Default 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

  9. #9
    Join Date
    Aug 2000
    Location
    Skødstrup, Denmark
    Posts
    251

    Default 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!
    Cheers,

    Sten
    "Everything has two sides"

  10. #10
    Join Date
    May 2003
    Location
    Box Elder, SD, USA
    Posts
    4,034

    Default 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.
    John Rayner
    For my Photography see:
    http://www.draginet.com
    Facebook

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •