Jump to content

What is GraphicsData and how do I use it?


Azamantes
 Share

Recommended Posts

I am new to Pixi.js and I can't figure out what is this GraphicsData and how could I possibly make use of it.

I noticed PIXI.Graphics() method called drawShape and that it returns PIXI.GraphicsData thing.

I cannot draw it to a Graphics container, I cannot add it to the Stage with addChild() method. ParticleContainer also doesn't seem to work with it.

 

What's the purpose of GraphicsData and how do I use it? Looks like a way to reuse once drawn graphics thus important.

Link to comment
Share on other sites

I just had a 5 minute poke through the code and they all get added to an array of graphics data, I bet if I poked through the renderer code I'd find something that handles graphics objects in the pipeline and that it would take all the graphics data (maybe optimise it if possible?) and then batch all the drawing together.

 

Not sure what you could do with it, you could probably cache it somewhere, then if you altered your graphics data by drawing new stuff you could retrieve previous state. You could try adding it to the existing graphics data array but it would already be in there.

 

edit: I did have a poke through the renderer, the main optimisation seems to be that it diffs state (kind of) so it'll only redraw when necessary (via the dirty flag).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...