2651 posts aspire to create - create to inspire
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helped several times protecting Envato Market against copyright violations
  • Has sold $125,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
+10 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.

392 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
+4 more
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?

5257 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+11 more
felt_tips 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.

403 posts
  • Won a Most Wanted contest
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Joined an Envato Football competition
+4 more
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?

2651 posts aspire to create - create to inspire
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helped several times protecting Envato Market against copyright violations
  • Has sold $125,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
+10 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)
403 posts
  • Won a Most Wanted contest
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Joined an Envato Football competition
+4 more
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.

5257 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+11 more
felt_tips 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”)

392 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
+4 more
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

1596 posts
  • Sells items exclusively on Envato Market
  • Has sold $40,000+ on Envato Market
  • Had an item featured in an Envato Bundle
  • Made it to the Authors' Hall of Fame
+6 more
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

5257 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+11 more
felt_tips 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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by