neonwarge04 Posted May 8, 2016 Share Posted May 8, 2016 I am struggling, the only resource I found is this. I have not dealt with the code yet, but concepts on how to deal with it. So the thought I came up with is to create a circle via PIXI.Graphics and make this a mask on another black transparent graphics object. The thing is, I wanted my Circle mask to look like a degrading pie chart overtime. I need to be it like this for some reason not like the one on the link. Basically, what I am asking is this, how can I make a circle, to fan left and to fan right (I don't know if I am using the right term)? I needed to draw a fanning effect so I can create a cooldown effect not just this, but some other cool stuff like a loading indicators something similar to Imgur, regardless the shape of my object of interest. Here is what I came up with: This is fairly easy to do in Pixi.js or any other similar renderer libraries out there. But how can I make my circle to have a pie slice like this and it should grow overtime? so I can make something like this (Not just specifically this by the way): I don't like codes by the way. Just concept. I really can get my head wrap around this thing. I don't even know what its properly called (aside from calling it a circular cooldown effect) which made me even more frustrated. I need help! Thanks! Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted May 9, 2016 Share Posted May 9, 2016 Cannot help you since I'm a Pre-Algebra major and circular Maths is not my field, but found this: http://codepen.io/jeremywynn/pen/emLjyL Magic is at ctx.arc(0, 0, hypoteneuse/2, degrees * Math.PI/180, Math.PI*2, false); Quote Link to comment Share on other sites More sharing options...
Exca Posted May 9, 2016 Share Posted May 9, 2016 You could draw it by having the masked graphic be round and then build the mask by drawing line to start angle. Then moving it to edge off bounding box and then to end angle position and from that on back to origo. That way you would need only 4 basic lins instead of arcs. Not sure which one is faster though. Here's an example: var angle = -Math.PI*0.3 - Math.PI/2; var angleStart= 0 - Math.PI/2; var radius= 40; test.beginFill(0xFF0000, 1); test.moveTo(0, 0); var x1= Math.cos(angleStart) * radius; var y1= Math.sin(angleStart) * radius; var x2= Math.cos(angle) * radius; var y2= Math.sin(angle) * radius; //Move to start point. test.lineTo( x1 , y1); //Move to left or right edge depending on which side the target is at. test.lineTo( x2 < 0 ? -radius : radius, y1); //Move to y-coordinate where end angle starts test.lineTo( x2 < 0 ? -radius : radius, y2); //Move to position where end angle starts test.lineTo( x2, y2); //Move back to center. test.lineTo( 0, 0); test.endFill(); [Edit]: You could also calculate the distance to edge and use that as a radius multiplier for each angle and then just draw line to corner of bounding box. That way it would work also with rectangle graphics. soop and PixelPicoSean 1 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 12, 2016 Share Posted May 12, 2016 Dont forget to clear it. 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.