Jump to content

Graphics objects and manipulation


adamk33n3r
 Share

Recommended Posts

Graphics objects have a rotation property which affects everything drawn with that object. In order to only rotate certain things I create multiple Graphics objects. I used to accomplish this with normal canvas by using save and restore. Is that what Graphics is doing behind the scenes? Like is each one a "state"? Or is it something else?

 

The real question is this: what is the best way of drawing multiple shapes? Is it fine to create multiple Graphics objects or is there a better way?

Link to comment
Share on other sites

Creating multiple graphics objects is OK, but lots of them will not perform very well.

 

I used to accomplish this with normal canvas by using save and restore. Is that what Graphics is doing behind the scenes?

 

No, Graphics is just a display object container like anything else in pixi (sprites for example). When you rotate it we add the rotation to the matrix transformation calculation. How this is interpreted is dependent upon which renderer you use. You could also rotate the verts of the polyogn you want to draw, and have each shape in a single graphics object.

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...