Tutorial 140: Making Custom Effects - Linear Wipe

Joe Clay | Sep 7, 2018

If you're like me, you get annoyed sometimes when built-in After Effects effects are missing a feature that you want. For example, back in the day, the Ramp effect didn't let you swap the colors. It was a pain that was eventually alleviated.

That's how I feel about Linear Wipe sometimes. So this week, I decided to improve it. Linear Wipe only works in comp space, which is great if your layers are comp-sized. But if you need to put a Linear Wipe on text and then you have a change that forces you to move the text, you'll need to re-animate your wipe. That sucks.

Here's the code to fix it. It gets applied to a Mask Path property. I built a pseudo effect with Pseudo Effect Maker so all of the things that are linked with thisLayer will need to be modified for your controls. You'll need Point Controls called Size and Position Offset, a Slider Controls called Completion and Feather, and an Angle Control called Angle.

If you're a $20 Patron, this will be one of the included complex elements for this month. The Feather value in the mask properties can just be pickwhipped to the controller for feather.

size = mul(thisLayer("Effects")("Linear Wipe Improved")("Size"), .5); //cut the size in half
feather = thisLayer("Effects")("Linear Wipe Improved")("Feather");
size = size + [feather, feather];
pos = thisLayer("Effects")("Linear Wipe Improved")("Position Offset");
completion = Math.abs(thisLayer("Effects")("Linear Wipe Improved")("Completion")-100)/100; //1-0 range
completion = completion*2-1; //Convert 1-0 range into 1,-1

pts = [];
pts[0] = [size[0], -size[1]];
pts[1] = [size[0], size[1]];
pts[2] = [-size[0] * completion, size[1]];
pts[3] = [-size[0] * completion, -size[1]];

for(i = 0; i < 4; i++) {
    pts[i] = rotatePoint(pts[i]);
    pts[i] = translatePoint(pts[i]);

function rotatePoint(p) {
    angle = degreesToRadians(thisLayer("Effects")("Linear Wipe Improved")("Angle")-90); //zero out the default angle and convert it to radians for the math below
    x = (p[0] * Math.cos(angle)) - (p[1] * Math.sin(angle));
    y = (p[0] * Math.sin(angle)) + (p[1] * Math.cos(angle));
    return [x,y];

function translatePoint(p) {
    return p + pos;

The code for the rotation function was derived from this lesson on Khan Academy. I can't recommend them enough.

Grab the Project Files

Get the project file through our Gumroad Store. This project file includes the setups shown in the tutorial. A version is included that will open back to CC v13.

If you're buying project files, consider becoming a Patron. At the $5/mo. tier, you get access to project files as they come out and some tutorials also come with additional BTS content showing more of the builds.

Get the project on Gumroad

Become a Patron

If you'd like to help support Workbench, check out our Patreon page. Thank you for even considering clicking this link to support what we're doing. We appreciate it. Patrons get all sorts of benefits, from R&D files, setups, and elements to early product releases.

Check out our Patreon Today