• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• how to write expression in such case-7

# how to write expression in such case-7

Engaged ,
Aug 11, 2024 Aug 11, 2024

Copied

Hi,

So I am playing with expressions.

To make my life more difficult I imagine Why dnt I stop the position animation at a certian point. After googling sometimes I learned that I can use 'Checkbox Expression' to control/manipulate/on-off expression. So,  I did that, but dnt like the result. I want the orange circle to stop in a smooth manner not like the one I got using chekbox control. How can I apply  easy ease on checkbox keyframes. If thats not possile what can I do to make the stopping velocity smooth and also I want the circle  animation stops as well.

I mean the orange circle will start its animation with ''Math.sin'', it will reach a certain point and in a smooth manner and then stops.

TOPICS
Expressions , How to

Views

142

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , Aug 11, 2024 Aug 11, 2024

This may be what you want, but I'm not quite sure:

p = thisLayer.effect("Checkbox Control")("Checkbox");
t = 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
if (n > 0){
for (i = 1; i <= n; i++){
if (p.key(i).value == true){
if (i < n){
t += p.key(i+1).time - p.key(i).time;
}else{
t1 = p.key(n).time;
if (n < p.numKeys){
t2 = p.key(n+1).time;
t += ease(time,t1,t2,0,t2-t1);

...

3 Replies 3
Community Expert ,
Aug 11, 2024 Aug 11, 2024

Copied

This may be what you want, but I'm not quite sure:

p = thisLayer.effect("Checkbox Control")("Checkbox");
t = 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
if (n > 0){
for (i = 1; i <= n; i++){
if (p.key(i).value == true){
if (i < n){
t += p.key(i+1).time - p.key(i).time;
}else{
t1 = p.key(n).time;
if (n < p.numKeys){
t2 = p.key(n+1).time;
t += ease(time,t1,t2,0,t2-t1);
}else{
t2 = thisComp.duration;
t += easeIn(time,t1,t2,0,t2-t1);
}
}
}
}
}
}
amp = 10;
freq = 1;
y = amp*Math.sin(t*freq*Math.PI*2);
value + [0,y]

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 11, 2024 Aug 11, 2024

Copied

If you don't actually need the easing, then this might suffice:

p = thisLayer.effect("Checkbox Control")("Checkbox");
t = p.value ? time : 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
if (n > 0){
t = p.key(1).value ? p.key(1).time : 0;
t += p.value ? time - p.key(n).time : 0;
for (i = 2; i <= n; i++){
t += p.key(i-1).value ? p.key(i).time - p.key(i-1).time : 0;
}
}
}
amp = 10;
freq = 1;
y = amp*Math.sin(t*freq*Math.PI*2);
value + [0,y]

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
Aug 11, 2024 Aug 11, 2024

Copied

LATEST

I am soooooooo happy. this is so cool. Thank you so much.

😮😮😮  I love the result. This is exactly what I wanted. The circle stops smoothly, not like before. Thank you.