rks Posted May 23, 2021 Share Posted May 23, 2021 Hi, I am currently creating a polygon geometry with PIXI.Graphics. As one of the requirements of our application, we need to add fill color after we create a graphic. Is there any way to do it? Currently, we have something like below. const graphic = new PIXI.Graphics(); graphic.lineStyle(2, style.color, 1); for (..){ if (type === 1) graphic.lineTo(x, y); else graphic.moveTo(x, y); } As you can see, this will simply create a polyline but we need to find a way to fill this polyline with some color and convert it to polygon. *this needs to be a polyline when it was created It would be appreciating if you could give me any advise to achieve this. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 23, 2021 Share Posted May 23, 2021 (edited) Sorry, need better example Whats exactly the problem? Why not just use `beginFill` there too? I hope you have experience with Flash or Canvas2d, because pixi graphics is like it, it cant actually do more Edited May 23, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
rks Posted May 24, 2021 Author Share Posted May 24, 2021 Thanks for your reply. I just want users to have a way to edit the fill color and opacity of those graphics afterward. So probably destroying the existing graphics and creating new graphics with a new fill color would be the only way to enable those editings? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 24, 2021 Share Posted May 24, 2021 No, you can change graphicsData directly, it was described many times in this forum, something-something "geometry.invalidate()" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.