Jump to content

Change the style of line that is already drawn?


Eugenius
 Share

Recommended Posts

Shame on you, necro-ing very old thread. There were threads like that not long ago, its possible but requires full invalidation of p[ixi v5 graphics object. You have to manually change "graphics.geometry.graphicsData" and call "graphics.geometry.invalidate()" . Note, that all the performance problems wil be your fault. Use spectorJS to debug, separate multiple graphics into several instances e.t.c. i really cant put it all in one message, its a very big topic.

Link to comment
Share on other sites

@ivan.popelyshev i dont know what necro-ing is and i dont know why im getting insulted but im sure that this doesnt feel welcoming at all. If the issue is personal feel free to elaborate.

All i asked was a question. by the way i did justify that a so given solution wasnt really a solution here

Edited by CamO
Link to comment
Share on other sites

Not really, unless I have missed something. Really all i am looking to do are 2 things:

 

1) when moving polygon point that the same goes for the lineStyle points dynamically (btw I am using vertexData to move change the points of the polygon)

2) to change the fill of the lineStyle when clicking on a button

Edited by CamO
Link to comment
Share on other sites

vertexData works only if graphics is small and it was detected as "batchable" (see the source of Graphics and GraphicsGeometry). You should change insides of `graphics.geometry.graphicsData` 

or something easy like that:

let myPoly = new Polygon(...);

graphics.drawPolygon(myPoly);

myPoly.points[0] = ... //change something

graphics.geometry.invalidate();

lineStyle gets copied so you cant just use it and  then change - you have to look inside `graphics.geometry.graphicsData[0]`. My earlier demo should work for you.

All those  problems are here because Graphics originally was created to be cleared&refilled.

Link to comment
Share on other sites

  • 2 years later...
PIXI.Graphics.prototype.updateLineStyle = function({width=null, color=null, alpha=null}={}) {
	this.geometry.graphicsData.forEach(data => {
		if (width!=null) { data.lineStyle.width = width; }
		if (color!=null) { data.lineStyle.color = color; }
		if (alpha!=null) { data.lineStyle.alpha = alpha; }
	});
	this.geometry.invalidate();
}

graphics_object.updateLineStyle({color:"0xff00ff"});

 

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