Fun with code (since 2006)

Query Graphics Data – getGraphicsData()


11.08.12 Posted in Actionscript 3, Flash Player by

If you guys have been reading this blog for a while, you may remember that post about querying graphics data. I really wanted this back in the days for AlivePDF to query any DisplayObject to export vector based PDF instead of rasterized vectors in the PDF. But this features gives much more, you can represent anything as a GraphicsData object and serialize that into XML if you need to store a DisplayObject anywhere.

If you need to generate spritesheets at runtime, export to any kind of format, like SVG, you can get that level of granularity, so much stuff to do with it. Some things are not entirely supported yet like some gradients, but we will keep improving it. Here is a little video about it, explaining how it works and a simple demo. As always, thanks Chris for the cute assets:

Query Graphics Data - getGraphicsData() from Thibault Imbert on Vimeo.



31 Responses to “Query Graphics Data – getGraphicsData()”

  1. Elliot Geno says:

    It doesn’t look like it kept gradients or fills intact.

    Will those be maintained in the final release of this feature?

  2. Elliot Geno says:

    Also filters are apparently dismissed on the recursive version.

  3. Tony Downey says:

    This looks *amazing* – I would love to integrate this into Box2D (artist draws, programmer implements by simply throwing it on the stage!)

    I made a few functions to round corners on simple shapes too – providing it a graphics objects instead of a Vector of co-ordinates would be a far faster workflow.

    Very excited, good to see that non-Stage3D stuff still has improvements left in it!

  4. Jerome says:

    méthode classe et MovieClip sympa ;)

  5. Horidream says:

    Very nice feature I wanted for years.

  6. daklab says:

    Very cool! Storing display objects as XML files and then reconstructing them at runtime could be very handy. Awesome potential for having a massive library of DisplayObjects that can be loaded quickly (as XML) and then created at will based on the XML definitions. Dig it!

  7. Antoine says:

    Nice feature!
    I love the idea of xml storage

  8. Oldes says:

    I’m a little bit sceptical here. I’m sure a lot of people will find it cool, but I was already able to parse SWF sturctures to get the graphics data. But without fast natice support how to deal with these on GPU it’s usage is limited. It’s not so cool to draw these data as a classic diplay list. On GPU you need to tessellate the data and draw as triangles. The tessellation is possible for example in the Starling’s graphics extension, but I reached very quickly vertex buffer limits with more complicated animations, which are still easy to run in the CPU mode:/

  9. SasMaster says:

    Nice!But when will it be available ?

  10. ElliotGeno says:

    @oldes I think a true breakthrough won’t come from tesselating these shapes. I hope to see vector shaders replicate all the drawing commands. That would be killer!

  11. Michal Czaicki says:

    I absolutely love it!
    Hope it will be available soon!

  12. Ohhh yeah baby! Just can`t wait for this in alivePDF

  13. miels says:

    Will this be set-/get-able in a similar way to a BitmapData from a Bitmap object?

    say myShape.graphicsData = …

  14. ozgur says:

    where can I download the updated “introducing starling” book please? I see that the latest update was in the 7th of september 2012, but the oreilly download version was revised on april 2012.

  15. Thibault Imbert says:

    Hi Elliot,

    For info, we just fixed the gradients this morning. They will now work nicely! ;)

    Thibault

  16. Hello Thibault !

    I’m not sure to understand exactly what I can do with this.

    Is it possible to access to the points of each path and modify their positions ?

    I’m waiting for this since Flash 5…

    Thanks !

  17. will we get this for Christmas?

  18. Thibault Imbert says:

    Hi Thomas,

    Yes, you could :)

    You can also write an SVG exporter at runtime, you could write an XML exporter to allow you to serialize/deserialize and store display objects, you could generate spritesheets at runtime and much more! :)

    Thibault

  19. Thibault Imbert says:

    Hi Radu,

    Yes, I think we will have a public beta very soon ;)

    Thibault

  20. David Barlia says:

    Hi Thibault,

    One thing I’d find helpful to go along with this would be a some way of querying whether the graphics data contains elements that can not (yet!) be represented by getGraphicsData()

    In any case, I’m looking forward to experimenting with this in combination with Starling’s graphics api. :)

    David

  21. Salut Thibault
    Excuse moi d’intervenir ici pour ça , je sais que ce n’est pas le bon endroit mais j’aimerais signaler un bug récent et tout les forums adobe sont actuellement cassés.
    Rien ne presse de mon coté, je travaillais sur un expérience perso, mais je viens d’essayer de trouver une solution pendant plusieurs jours et je pense que je vais passer à autre chose ; donc si je dois signaler ce bug c’est maintenant ou jamais :)

    La fonction SoundMixer.computeSpectrum bug online, sur tout les navigateurs (IE/chrome/firefox du moins). Tout fonctionne sans problème offline.

    Je pensais que ça venait de mon code, peut être un problème stupide dans le html mais je viens de regarder plusieurs anciennes démos (utilisant stage3D + computeSpectrum) et toutes sont cassées.

    Il n’y a pas de message d’erreur, mais c’est comme si le framerate de computeSpectrum était beaucoup plus lent que le framerate de l’animation.

    J’ai fait plusieurs tests sur 3-4 PC/Mac différents et j’en suis certain : cette fonction bug

    Voila un exemple que tu as sans doute déjà vu quand il tournait bien
    http://blog.norbz.net/wp-content/custom/rainbow.html

    La démo fonctionne toujours, mais le niveau de détail du spectre est casi nul, ce qui enlève tout l’intérêt.

    Merci d’avance !

  22. (la beta du player 11.5 corrige le problème ! Quelle réactivité ! )

  23. [...] In den ReleaseNotes finden sich einige interessante Neuerungen u.a. Multiple SWF support und Graphics Data Query. Aber auch Stage3D wird in Zukunft ausgebaut. Features wie zum Beispiel Multiple Render Targets, [...]

     
  24. Vincent says:

    Salut Thibault, j’ai pas eu le temps de tout lire, mais je pense que cette feature est l’une des plus importantes jamais créées pour Flash,et j’ai une seule concern.

    Please Flash god, make it available on both AIR and Flash Player…

    Is it available on both AIR and Flash Player? ;-P

    - Vincent.

  25. [...] – Live demo by Thibault Imbert I wanted to post the demo of the example I posted the other day as a video. It is using the new Query Graphics API we are introducing in Flash Player 11.6/AIR 3.6. Make sure [...]

     
  26. Jeff Ward says:

    Thibault,

    Now that getGraphicsData is available on labs in Flash 11.6 / Air 3.6, any chance we can get:

    - API docs
    - Your sample code in the video

    Reading your code in the video is doable, but a little painful. =D

    Thanks for this awesome API!

  27. Jeff Ward says:

    BTW, if anyone else is looking, it’s readGraphicsData(recursive:Boolean) now, and as mentioned, requires –target-player=11.6 and –swf-version=19

  28. Thibault Imbert says:

    Hi Jeff,

    Thanks! It is all here:

    http://www.bytearray.org/?p=5013

    Hope it helps!

    Thibault

  29. Hi Thibault,

    This functionality is really helpful. Thanks to you and the team for making it happen.

    However, I have to echo an earlier post’s comments that fills are not being faithfully replicated.

    I’m also seeing strange effects where a swf drawn in Flash Builder with a single path shows up as drawn with two lines when using getGraphicsData().

    Is more work being done on this method to make it more accurate?

    Thanks for your thoughts,

    Daniel

  30. Thibault Imbert says:

    Hi Daniel,

    Yes. First, the feature has been improved since I shot this video. Gradients are now supported and some other improvements got done. We are actually doing some other right now and the next beta of 11.6 should have these enhancements. Please if you have some examples and improvements you need, just send me some examples, I will be happy having a look to make it happen.

    Thanks again for the interest!

    Thibault

Leave a Reply

Open Sort Options

Sort comments by:
  • * Applied after refresh

ByteArray.org
Fun with code since 2006.