# How to create a circular cooldown effect?

## Recommended Posts

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!

##### Share on other sites

Cannot help you since I'm a Pre-Algebra major and circular Maths is not my field, but found this:

Magic is at ctx.arc(0, 0, hypoteneuse/2, degrees * Math.PI/180, Math.PI*2, false);

##### Share on other sites

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;
test.beginFill(0xFF0000, 1);
test.moveTo(0, 0);

//Move to start point.
test.lineTo( x1 , y1);

//Move to left or right edge depending on which side the target is at.
//Move to y-coordinate where end angle starts
//Move to position where end angle starts
test.lineTo( x2, y2);
//Move back to center.
test.lineTo( 0, 0);
test.endFill();``````

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

##### Share on other sites

Dont forget to clear it.

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.