ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Placing Null In A Circle

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Amir Aizat
Placing Null In A Circle
on Oct 25, 2018 at 9:47:20 am
Last Edited By Amir Aizat on Oct 25, 2018 at 3:44:04 pm

Hello,

I'm trying to rig a pie chart in After Effects, I am currently having trouble with placing the nulls for call-outs.

Edit

With some fiddling, I was able to get close to what I wanted to achieve, but now I have this problem:

This is how my expression works:


This is how I wanted it to work:


Here is my expression:
var comp = thisComp;
var ident = name.split(" ")[1];
var init_pos = comp.layer("Super Anchor").transform.position;

var degree = comp.layer("Calculator").effect("Angle Per Part")("Slider");
var angle = degreesToRadians(degree) * -ident;
var diameter = comp.layer("Controller").effect("Diameter")("Slider");
var thickness = comp.layer("Controller").effect("Thickness")("Slider");
var radius = (diameter + (thickness / 2)) / 2;

var x_position = radius * Math.cos(angle);
var y_position = radius * Math.sin(angle);

[init_pos[0] + x_position, init_pos[1] + y_position]


There will be a lot of duplicating, so I tend to put expressions with loops to a slider and get the values from there.

"Angle Per Part" is just 360 / number of layers with the name "Pie Part" in it (in this example, 360 / 6 = 60);
"Ident" is the number assigned to the layer, Callout 01, Callout 02 (hence split(" ")[1])

Better yet, is there a way to modify my expressions so that I can freely rotate the entire thing using expression controls?

Thank you.


Return to posts index

Filip Vandueren
Re: Placing Null In A Circle
on Oct 25, 2018 at 9:06:15 pm

Are these shapelayers you created, or imported PSD-layers, or just one graphic that you are masking ?
What exactly do you want to do, and why do you need expressions for it ?



Return to posts index

Amir Aizat
Re: Placing Null In A Circle
on Oct 26, 2018 at 9:00:50 am

Hello,

I managed to get it to work. Sorry if the initial post is unclear.

I'll clarify. The pie parts are just comp sized shape layers with the effect radial wipe applied, they respond to input sliders in a special layer. Then I masked the entire layer with a donut shape layer.

Basically what I wanted to achieve is to make null objects stick to the middle of a pie part at all times, and which pie part sticks depends on its layer name, so null object "callout 01" will stick to the middle of "pie part 01" at all times.

With parametric equation for circles, I was nearly there, but that's when I encountered the issue where my null objects are where they're supposed to be, but +90 degrees off. But that's not all, I need it that when I duplicate the callout null, the new null will follow the rotation in counter clockwise.

So I added an angle control so I can control the start angle to my liking, calculated the percentage of the pie to an angle, then divided it by two.

Voila, the null objects are stuck to the pie parts.


Here's the expression I wrote, it's not very elegant or anything, but it works.
var comp = thisComp;
var ident = name.split(" ")[1];
var init_pos = comp.layer("Super Anchor").transform.position;

var start_degree = comp.layer("Controller").effect("Callout Rotation")("Angle");
var start_angle = degreesToRadians(start_degree);
var diameter = comp.layer("Controller").effect("Diameter")("Slider");
var thickness = comp.layer("Controller").effect("Thickness")("Slider");
var radius = (diameter + (thickness / 2)) / 2;

var value_layer = comp.layer("Pie Part " + ident)
var value_target = value_layer.effect("Radial Wipe")("Transition Completion");
var value_start = value_layer.effect("Radial Wipe")("Start Angle");
var value_percent = (360 - (value_target / 100 * 360)) * -1;
var value_degree = value_start + (value_percent / 2);
var value_angle = degreesToRadians(value_degree);

var x_position = radius * Math.cos(start_angle + value_angle);
var y_position = radius * Math.sin(start_angle + value_angle);

[init_pos[0] + x_position, init_pos[1] + y_position]


Took me 7 hours because I'm so bad with maths lol.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]