Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs - Add warning (to use clear method) for Graphics component when updating draw #28

Closed
bichotll opened this issue Aug 14, 2018 · 6 comments

Comments

@bichotll
Copy link
Contributor

Description

We should add a warning in the Graphics component to warn the user that he may want to clear the canvas if new properties have received.

I can work on that and create a PR.

Steps to reproduce

I created a simple example: https://codepen.io/bichotll/pen/KBYBpd?editors=0011

@inlet
Copy link
Collaborator

inlet commented Aug 15, 2018

I believe this should be up to the developer. PIXI memoizes the elements to render, clears the canvas and redraw the elements back to improve performance.

If you're using the Graphics.draw prop, you can simply add g.clear() before you draw another rectangle. See this example: https://codepen.io/inlet/pen/RMLJKm?editors=0011

image

We could clear the graphics before the prop draw is called here, but I think this is not what you want as a developer.

@inlet
Copy link
Collaborator

inlet commented Aug 15, 2018

Closing issue now, please let me know if you think we should reopen it.

@inlet inlet closed this as completed Aug 15, 2018
@bichotll
Copy link
Contributor Author

Yes. I'm using g.clear() :)

I just think it would be helpful for the user to let them know that.
My point is: If they are not familiar enough with Pixi, they may expect that passing a new prop to the Graphics component, it would just clear the Graphics component "canvas" and write on a blank canvas (You have to explicitly call the method .clear() in order to have that desired behaviour).

That actually confused me - when it happened to me - until I found out what it was going on.

Again, if that make sense to you, I can create a PR (an update of the docs with the note).
It's not a big deal and it's not part of the library, but it's a good thing to know - at least for newbies.

@inlet inlet reopened this Aug 15, 2018
@inlet
Copy link
Collaborator

inlet commented Aug 15, 2018

Good point, would be great if you add this to the README. Thanks!

@bichotll
Copy link
Contributor Author

Sure thing. I'll work on that soon-ish 👍

@inlet
Copy link
Collaborator

inlet commented Sep 10, 2018

Hi @bichotll,

I've added a note to the Graphics doc, see:
https://reactpixi.org/#/components/graphics

@inlet inlet closed this as completed Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants