# 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, 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]);
}
createPath(pts);

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

The best way to get our project files is to become a patron on Patreon. For \$5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

or