Jump to content

How do I change the radius of a circle? (created with .drawCircle(x,y,radius))


MrB
 Share

Recommended Posts

Pretty straight forward problem, but I haven't figured out how to solve it.

 

I have something like this:

...graphics = new PIXI.Graphics();graphics.lineStyle(styles[s].lineWidth, styles[s].lineColor, p.active);graphics.beginFill(styles[s].fillColor, styles[s].fillAlpha);graphics.drawCircle(0,0, p.w/styles[s].radius);graphics.position.x = p.x+size/2;graphics.position.y = p.y+size/2;stage.addChild(graphics);shapes[flower][p.index][s] = graphics;...

And then later I try to change the radius like so:

...shapes[flower][p.index][s].currentPath.points[2] = p.w/styles[s].radius;shapes[flower][p.index][s].currentPath.points[3] = p.w/styles[s].radius;...

Where the value of p.w has changed and therefor the radius should change but it doesn't, perhaps because I'm not suppose to be editing .currentPath to change the radius.

 

So how do I change the radius?

Link to comment
Share on other sites

Maybe I'm misunderstanding the API, perhaps the correct way is not to create a graphic and then alter it's properties, but to have my new properties ready and then just draw the graphic again by using .clear() and calling the drawing calls again.

 

So on each update I do:

shapes[flower][p.index][s].clear();shapes[flower][p.index][s].lineStyle(styles[s].lineWidth, lineColor, lineAlpha);shapes[flower][p.index][s].beginFill(fillColor, styles[s].fillAlpha);shapes[flower][p.index][s].drawCircle(0,0, p.w/styles[s].radius);shapes[flower][p.index][s].position.x = p.x+size/2;shapes[flower][p.index][s].position.y = p.y+size/2;shapes[flower][p.index][s].alpha = p.active;
Link to comment
Share on other sites

 

Maybe I'm misunderstanding the API, perhaps the correct way is not to create a graphic and then alter it's properties, but to have my new properties ready and then just draw the graphic again by using .clear() and calling the drawing calls again.

 

That is correct, you should just make use of the drawing APIs. I wouldn't worry about trying to modify the path, let the object do that for you.

Link to comment
Share on other sites

  • 1 year later...

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