Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rotate Mask using Expression

  • Rotate Mask using Expression

    Posted by Ilya Sire on March 25, 2022 at 1:25 am

    Hi forum,

    I have this expression to sizing my mask, from this how can I rotating this?

    myShape = mask("Mask 1").maskPath;

    boxSize = 50;

    rot = effect("Angle Control")("Angle");

    tgn = [[0,0],[0,0],[0,0],[0,0]];

    for (i = 0; i < myShape.points(0).length; i++) {

    p1 = myShape.points(0)[0] = anchorPoint+[boxSize,boxSize] //br

    p2 = myShape.points(0)[1] = anchorPoint+[-boxSize,boxSize] //bl

    p3 = myShape.points(0)[2] = anchorPoint+[-boxSize,-boxSize] //tl

    p4 = myShape.points(0)[3] = anchorPoint+[boxSize,-boxSize] //tr

    }

    createPath([p1,p2,p3,p4],tgn,tgn,true);

    Ilya Sire replied 4 years, 1 month ago 1 Member · 1 Reply
  • 1 Reply
  • Ilya Sire

    March 25, 2022 at 5:06 am

    found the solution

    function rot(cx, cy, x, y, angle) {

    var radians = (Math.PI / 180) * angle;

    cos = Math.cos(radians);

    sin = Math.sin(radians);

    nx = (cos * (x - cx)) + (sin * (y - cy)) + cx;

    ny = (cos * (y - cy)) - (sin * (x - cx)) + cy;

    return [nx, ny];

    }

    myShape = mask("Mask 1").maskPath

    tgn = [[0,0],[0,0],[0,0],[0,0]];

    for (i = 0; i < myShape.points(0).length; i++) {

    p1 = myShape.points(0)[0] = anchorPoint+rot(0,0,50,0,effect("Angle Control")("Angle")) //br

    p2 = myShape.points(0)[1] = anchorPoint+rot(0,0,-50,0,effect("Angle Control")("Angle")) //bl

    p3 = myShape.points(0)[2] = anchorPoint+rot(0,0,-50,-100,effect("Angle Control")("Angle")) //tl

    p4 = myShape.points(0)[3] = anchorPoint+rot(0,0,50,-100,effect("Angle Control")("Angle")) //tr

    }

    createPath([p1,p2,p3,p4],tgn,tgn,true);

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy