Welcome to TalkGraphics.com
Results 1 to 10 of 14

Threaded View

  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

 

 

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
  •