Without question, wiggle() is an extremely handy and versatile tool for adding an element of randomness to a project. Sometimes though, it would be extremely useful to be able to get the wiggle motion to loop. Here we'll take a look at a way to accomplish this by using a bit of clever math and taking advantage of one of wiggle()'s seldom used parameters.
Let's say we want to create a three-second loop of wiggle motion. Visualize a graph showing the path that our layer traces out as it moves randomly from time zero through three seconds. If you examine the lower movie to the right you'll see such a path traced out by the blue dot. It starts in the lower left corner and ends up near the middle of the right edge after three seconds. Then it repeats.
Now examine the path traced out by the red dot. Notice that it starts near the right edge but ends up in the lower left corner - exactly where the blue dot starts. That seems like quite a coincidence, right? Well, there's a little trickery going on here that is key to making this all work. It turns out that the red and blue dots are actually tracing out the same random wiggle path. The trick is that the red dot is tracing out the three-second portion of the path that occurs before time zero.
Let that sink in for a second. The red dot is tracing out the portion of the path that occurs between minus three seconds and zero. The blue dot is tracing out the portion that occurs between zero and positive three seconds. We are able to access these negative time values of wiggle() by using the seldom-used fifth parameter of wiggle() - time. This parameter works very much like the valueAtTime() method you can use to retrieve a property's value at any given time. Whatever time you specify, you get the wiggle() value that would occur at that time. By putting a negative value in for time we can get a layer to trace out a portion of the path that occurs before time zero.
OK - that's great but how does that help us? Well, all we have to do now is blend the two portions of the path together so that our layer starts out where the blue dot starts, but ends up where the red dot ends up (which happens to put it back where it started, thus creating a loop). This is exactly how the seamless loop of the white dot was created. This blending of the paths turns out to be quite easy to do using the extremely useful linear() interpolation method.
freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)
With a little math wizardry, we can get wiggle() to loop seamlessly.
The looping path of the white object is created by blending the paths of the blue and red objects.
In its fully populated form, wiggle() can take up to five parameters. We only need to use the first, second and fifth parameters for this task. However, to get to the fifth parameter, we have to specify the third and fourth paramters. So we'll just plug in the default values (the values that After Effects uses if only two parameters are specified).
好吃懒做是什么生肖 | 糖尿病能吃什么零食 | 女性睾酮高说明什么 | 三朵花代表什么意思 | 颞下颌关节炎吃什么药 |
六月六是什么日子 | 血红蛋白低吃什么药 | 惊雷是什么意思 | 子宫前倾是什么意思 | 揭榜是什么意思 |
6月份怀孕预产期是什么时候 | 鲤鱼为什么很少人吃 | 大便青黑色是什么原因 | 2019什么年 | 鱼代表什么数字 |
1942年是什么年 | 收缩压和舒张压是什么意思 | 曾孙是什么意思 | 一个田一个比读什么 | 人中白是什么 |
女同叫什么hcv9jop3ns3r.cn | 什么是修辞手法hcv8jop7ns1r.cn | 部分空蝶鞍是什么意思dajiketang.com | 什么茶减肥效果好hcv9jop0ns5r.cn | 高尿酸血症是什么意思hcv9jop1ns7r.cn |
梦见和死去的亲人说话是什么意思hcv7jop9ns5r.cn | 孩子爱咬指甲是什么原因hcv8jop7ns7r.cn | 血压高查什么项目hcv9jop3ns1r.cn | 左胸隐痛什么原因hcv8jop2ns3r.cn | 娘娘的意思是什么adwl56.com |
鱼条念什么hcv7jop7ns1r.cn | cua是什么意思hcv9jop2ns5r.cn | 手机有什么品牌hcv8jop2ns9r.cn | 养胃是什么意思hcv9jop0ns8r.cn | 脚气涂什么药膏hcv7jop4ns6r.cn |
怀孕什么时候有反应hcv7jop6ns0r.cn | 介入医学科是什么科室hcv8jop6ns4r.cn | 什么时候减肥效果最快最好hcv7jop9ns6r.cn | 女性腰疼去医院挂什么科hcv8jop5ns6r.cn | 牙龈肿痛上火吃什么药最好hcv8jop3ns5r.cn |