Copy link to clipboard
Copied
src=wiggle(2,200);
boundary = [135,135]; // size of boundinglayer/2
clamp(src, value - boundary, value + boundary)
how i do this in dynamic way , means if shape layer is rectangle and i want when ever i change height and weidth and bound upadated , balls are bounded inside the inner box because the box have stroke. bound also updated with stroke changes ,how can ido that , can anyone give me idea?
Copy link to clipboard
Copied
highlight this value [135,135] and use expression pickwip and choose the rectangle size then add /2
src=wiggle(2,200);
boundary = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size / 2; // size of boundinglayer/2
clamp(src, value - boundary, value + boundary)
Copy link to clipboard
Copied
To respect the rectangle stroke width, you need to subtract it from the rectangle size,
As the size data is a 2D vector [x,y] and the stroke width is a single dimension float value you can put it twice in a 2D vector then subtract it from the size
var temp = << pickwip to insert it's code >> ;
var strokeWidth = [temp.temp] ;
then do the subtraction in parentheses before deviding by 2 (size - strokeWidth) /2
Copy link to clipboard
Copied
also i need to minus circle redius also ?
Copy link to clipboard
Copied
Sure, if you want to always keep the circle boundary inside the rectangle then you shoud subtract the circle size too.
(rectngleSize - circleSize - strokeWidth) / 2
but this assumes that the initial circle position is at the center of the rectangle, if not then you should calculate the clamp in a different way.
Copy link to clipboard
Copied
it's usefull to control the wiggle parameters by slider controllers on a null layer to be able to change it once for all circles.
Copy link to clipboard
Copied
src=wiggle(2,200);
boundary = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size ; // size of boundinglayer/2
var t = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Stroke 1").strokeWidth
var strokeWidth = [t,t] ;
r = content("Ellipse 1").content("Ellipse Path 1").size;
B = (boundary - strokeWidth - r )/2
clamp(src, value - B, value + B);
is this expression correct , with this my ball slightly excessed
Copy link to clipboard
Copied
is because of the result comes in decimal value ?
Copy link to clipboard
Copied
does the circle have stroke?
does any of the layers has none 100% scale?
Copy link to clipboard
Copied
it looks fine, but for good practice use ; at the end of each line
Copy link to clipboard
Copied
both the rectangle and circle should have 100% scale
Copy link to clipboard
Copied
thanks it works
Copy link to clipboard
Copied
Great! Happy Animating : )
Copy link to clipboard
Copied
but is it possible if cicle start from anywhere in the box and then behave like this , basically can we make this expression dynamic to there position ?
Copy link to clipboard
Copied
sure, it just needs a different math
now you have the main idea, on a paper you can draw a line (as if it is the x axis) layout the boundaries and the circle and figure out the new formula
Copy link to clipboard
Copied
@Indranil_Mondal9509 Did it work?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now