1679 posts aspire to create - create to inspire
  • Elite Author
  • Author had a File in an Envato Bundle
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Bought between 50 and 99 items
  • Referred between 10 and 49 users
  • Germany
+1 more
Creattive says

So on layer 1, you might have an Expression Slider with the expression a=4;

Adding a slider to hold the value of a variable is a good idea, thank you Felt.

251 posts
  • Pakistan
  • Sold between 5 000 and 10 000 dollars
  • Referred between 1 and 9 users
  • Bought between 1 and 9 items
  • Contributed a Tutorial to a Tuts+ Site
  • Microlancer Beta Tester
  • Has been a member for 2-3 years
  • Exclusive Author
bilalmarri says

I have a little question here

is it possible to use the same effect on multi layers but can be controlled by a single slider control so on changing the value it offsets the reaction time of the effect on all layers?

for example i have a logo which has been broker into pieces by masks. now on each mask i want to apply CC page turn effect. now if its turning effects is controlled by a single slider which results each piece to turn independently not in any order but randomly in different directions??

can it be controlled by the expressions?

4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

I have a little question here

is it possible to use the same effect on multi layers but can be controlled by a single slider control so on changing the value it offsets the reaction time of the effect on all layers?

for example i have a logo which has been broker into pieces by masks. now on each mask i want to apply CC page turn effect. now if its turning effects is controlled by a single slider which results each piece to turn independently not in any order but randomly in different directions??

can it be controlled by the expressions?

There are two answers already on this thread which will help you.

You need to learn about valueAtTime() and seedRandom

Basically, you could have a Slider Control called Turn Amount and a Slider Control called Random Offset. These would be on a layer called Controller. You could optionally have a third Slider Control called Random Seed. The Turn Amount slider is keyframed to control the overall page turn effect. The Random Offset control controls the maximum amount by which the individual layer’s CC Page Turn effects will be offset in time. The bigger it is, the more staggered they will be. The optional Random Seed control controls the random pattern… in other words, if you don’t like the way the dice happen to fall (so to speak), then change the random seed and you’ll get a different random arrangement.

Your expression on the CC Page Turn Completion would be something like this. (I don’t have Ae in front of me, so I can’t check the effect in question, but I’ll assume there’s an Amount property that’s a percentage).

var ctrlr = thisComp.layer("Controller");
var seed = ctrlr.effect("Random Seed")(1).value; //if you're using the Random Seed slider
//var seed = 1; //if you're not using the Random Seed slider.
var rndOffset = ctrlr.effect("Random Offset")(1).value;
var turnAmt = ctrlr.effect("Turn Amount")(1); //notice I DON'T use .value here. It's a ref to the property object, not its value.
//___
seedRandom(seed, true); // timeless randoms will now be generated using the specified seed
myOffset = random(rndOffset) - rndOffset/2; //a random between -rndOffset/2 and + rndOffset/2
myTurnAmt = turnAmt.valueAtTime(time + myOffset);

Edit: just checked CC Page Turn and it doesn’t work on a “percentage complete”. See 4 posts below on how to convert a completion percentage to the kind of position data input that the effect requires.

300 posts
  • Exclusive Author
  • Has been a member for 1-2 years
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Netherlands
motionvids says

So I’m making a Control Panel for my Template. And I have this graphic slider which you can slide/position horizontally with your mouse from left to right while using the clamp expression.

 x = clamp(position[0], 151,582);
y = clamp(position[1], 750,750);
[x,y]

So my visual slider object is able to slide between the position values 151 and 582 from left to right horizontally, and this is meaning to control the opacity of “Layer 1”. So I’ve parented the opacity of this “Layer 1” to a Slider Control.

Now I’m adding this Slider Control to the position of this ‘Graphic Slider Object’ so that when I change the position of the ‘Graphic Slider Object’ the value of the Slider Control changes with it and thus the opacity of “Layer 1” changes.

One thing though is that the value of the Opacity ranges from 0 to 100 and the value from my ‘Graphic Slider Object’ is 151 to 582. Resulting in my “Layer 1” always staying visible since the value of the ‘Graphic Slider Object’, Slider Control and the Opacity is at all times above 151.

So in short I need Opacity 0% to equal the clamped 151 position value and Opacity 100% to equal the clamped 582 position value. Any thoughts?

1679 posts aspire to create - create to inspire
  • Elite Author
  • Author had a File in an Envato Bundle
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Bought between 50 and 99 items
  • Referred between 10 and 49 users
  • Germany
+1 more
Creattive says

@GloriousVids

you need to use the “linear” function on the opacity for that.

linear( :pickwhip the x-value of your slider object: , 151, 582, 0, 100)
300 posts
  • Exclusive Author
  • Has been a member for 1-2 years
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Netherlands
motionvids says

@GloriousVids

you need to use the “linear” function on the opacity for that.

linear( :pickwhip the x-value of your slider object: , 151, 582, 0, 100)

Awesome! Works beautifully! Thanks :) Now I’m gonna find out more about the linear expression.

4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

Controlling CC Page Turn with Expressions


var ctrlr = thisComp.layer("Controller");
var seed = ctrlr.effect("Random Seed")(1).value; //if you're using the Random Seed slider
//var seed = 1; //if you're not using the Random Seed slider.
var rndOffset = ctrlr.effect("Random Offset")(1).value;
var turnAmt = ctrlr.effect("Turn Amount")(1); //notice I DON'T use .value here. It's a ref to the property object, not its value.
//___
seedRandom(seed, true); // timeless randoms will now be generated using the specified seed
myOffset = random(rndOffset) - rndOffset/2; //a random between -rndOffset/2 and + rndOffset/2
myTurnAmt = turnAmt.valueAtTime(time + myOffset);

@bilalmarri,

Okay.. so I just checked out CC Page Turn and it actually doesn’t work on a percentage slider, but on a Fold Direction angle and a Fold Position point. So you’d need to convert that percentage to a position that moves across the layer perpendicularly to the Fold Direction… a bit tricky…

You’d need to add something like…

ang = effect("CC Page Turn")("Fold Direction").value;
LCenter = [thisLayer.source.width/2, thisLayer.source.height/2]; //layer's center
radius = Math.sqrt(Math.pow(LCenter[0], 2) + Math.pow(LCenter[1], 2)); //pythagoras.
unitVec = normalize([1,Math.tan(degreesToRadians(ang+90))]); //the angle as a vector of length 1
//For start and end below, the 1.1 adds 10% margin for error - to do with the fold radius
start = LCenter + unitVec*radius*1.1; //the start position
end = LCenter - unitVec*radius*1.1; //the end posiiton
linear(myTurnAmt, 0, 100, start, end); //range map the % complete to the position.

(also @Glorious vids – notice how I use linear at the end, using two number inputs and pulling out two point outputs… if you want to research the general concept that linear() and ease() both use, it’s called “range mapping”)

251 posts
  • Pakistan
  • Sold between 5 000 and 10 000 dollars
  • Referred between 1 and 9 users
  • Bought between 1 and 9 items
  • Contributed a Tutorial to a Tuts+ Site
  • Microlancer Beta Tester
  • Has been a member for 2-3 years
  • Exclusive Author
bilalmarri says


var ctrlr = thisComp.layer("Controller");
var seed = ctrlr.effect("Random Seed")(1).value; //if you're using the Random Seed slider
//var seed = 1; //if you're not using the Random Seed slider.
var rndOffset = ctrlr.effect("Random Offset")(1).value;
var turnAmt = ctrlr.effect("Turn Amount")(1); //notice I DON'T use .value here. It's a ref to the property object, not its value.
//___
seedRandom(seed, true); // timeless randoms will now be generated using the specified seed
myOffset = random(rndOffset) - rndOffset/2; //a random between -rndOffset/2 and + rndOffset/2
myTurnAmt = turnAmt.valueAtTime(time + myOffset);

@bilalmarri,

Okay.. so I just checked out CC Page Turn and it actually doesn’t work on a percentage slider, but on a Fold Direction angle and a Fold Position point. So you’d need to convert that percentage to a position that moves across the layer perpendicularly to the Fold Direction… a bit tricky…

You’d need to add something like…

ang = effect("CC Page Turn")("Fold Direction").value;
LCenter = [thisLayer.source.width/2, thisLayer.source.height/2]; //layer's center
radius = Math.sqrt(Math.pow(LCenter[0], 2) + Math.pow(LCenter[1], 2)); //pythagoras.
unitVec = normalize([1,Math.tan(degreesToRadians(ang+90))]); //the angle as a vector of length 1
//For start and end below, the 1.1 adds 10% margin for error - to do with the fold radius
start = LCenter + unitVec*radius*1.1; //the start position
end = LCenter - unitVec*radius*1.1; //the end posiiton
linear(myTurnAmt, 0, 100, start, end); //range map the % complete to the position.
(also @Glorious vids – notice how I use linear at the end, using two number inputs and pulling out two point outputs… if you want to research the general concept that linear() and ease() both use, it’s called “range mapping”)

Thank you felt Let me try it our then ill let you know about it. Thanks again

1471 posts
  • Sold between 10 000 and 50 000 dollars
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Russian Federation
  • Has been a member for 2-3 years
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Grew a moustache for the Envato Movember competition
AndrVlad says

Hi Felt and all,

Sorry if my question is too simple. What if I have some X,Y,Z coordintes of one target object and moving/rotating camera what expression can I use to get X,Y coordinates of this object through the camera. Basicaly I need like display X,Y coordinates of target object calculated through camera when camera looks into composition 3D scene.

Greatly appreciate your help!

Best Regards, Andrey

4792 posts
  • Elite Author
  • Community Moderator
  • Sold between 100 000 and 250 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips Volunteer moderator says

Getting 2D Screen Coordinates of a 3D Object


Hi Felt and all,

Sorry if my question is too simple. What if I have some X,Y,Z coordintes of one target object and moving/rotating camera what expression can I use to get X,Y coordinates of this object through the camera. Basicaly I need like display X,Y coordinates of target object calculated through camera when camera looks into composition 3D scene.

Greatly appreciate your help!

Best Regards, Andrey

If I understand what you’re asking correctly Andrey, you could do something like this:

Set up a 2D text layer and on the Source Text property…

L = thisComp.layer("layer whose coords you want");
P = L.toComp(L.anchorPoint);
P.length = 2;
PStr = "Coordinates of L: " + P.toString();

The toComp() method converts a point (in this case, the anchorPoint of L) from layer space to composition space. The first two coordinates of this give you the position on screen. In my Tuts+ portfolio I have an hour long tutorial about layerSpace transforms. It costs $10 right now, but once the Tuts+ marketplace is closed, I’m going to publish it on my Vimeo account for free, so watch this space.

Layer space transforms like toComp(), fromComp(), toWorld(), fromWorld() etc. are profoundly useful, and one of the most important parts of expression language to get your head around.

by
by
by
by
by
by