Resolution for the source code mystery of the Spider-Man: Homecoming trailer 3
Last active
July 14, 2022 02:07
-
-
Save Wunkolo/984d73fc0a45b3d5aceb194f15a86923 to your computer and use it in GitHub Desktop.
Spiderman home-coming mystery code solved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
targetPos = thisComp.layer("target").toComp([0,0]); // Compensating for the missing "targetPos" variable | |
box = thisComp.layer("box"); | |
boxTopLeft = box.toComp([0,0]); | |
boxBottomRight = box.toComp([box.width,box.height]); | |
// this is erroneous on their part. "deltaX" and "xDistanceToEdge" does not exist yet, commented out. | |
boxAnchor = box.toComp(box.anchorPoint);// xRatio = deltaX/xDistanceToEdge; | |
deltaVec = sub(targetPos, boxAnchor) | |
deltaX = deltaVec[0]; | |
deltaY = deltaVec[1]; | |
xRatio = 1; | |
yRatio = 1; | |
if(deltaX>0){ // target is right of anchorPoint | |
xDistanceToEdge = boxBottomRight[0] - boxAnchor[0]; | |
xRatio = deltaX / xDistanceToEdge; | |
}else if(deltaX<0) | |
{ | |
xDistanceToEdge = boxTopLeft[0] - boxAnchor[0]; | |
xRatio = deltaX / xDistanceToEdge; | |
} | |
if(deltaY>0){ // target is below anchorPoint | |
yDistanceToEdge = boxBottomRight[1] - boxAnchor[1]; | |
yRatio = deltaY / yDistanceToEdge; | |
}else if(deltaY<0) | |
{ | |
yDistanceToEdge = boxTopLeft[1] - boxAnchor[1]; | |
yRatio = deltaY / yDistanceToEdge; | |
} | |
ratio = (xRatio>yRatio)? xRatio:yRatio; | |
offset = div(deltaVec,ratio); | |
boxAnchor + offset; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment