Created
May 11, 2017 16:24
-
-
Save kimballfrank/7d7abc977e6287604e9eadf2888bede5 to your computer and use it in GitHub Desktop.
This file contains 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
function distortLayer(layer, shearHorizontallyBy, shearVerticallyBy) { | |
var shearVerticallyBy = shearVerticallyBy || 0; | |
if(!layer.isKindOfClass(MSShapeGroup)) return; | |
var path=layer.bezierPathWithTransforms(); | |
var transform=DKDistortionTransform.transformWithInitialRect(layer.frame().rect()); | |
transform.shearHorizontallyBy(shearHorizontallyBy); | |
transform.shearVerticallyBy(shearVerticallyBy); | |
var nextPath = transform.transformBezierPath(path); | |
layer.setBezierPath(nextPath); | |
doc.reloadInspector(); | |
} | |
function shearByDegree(layer, angle) { | |
var offset=(Math.sqrt(Math.pow(layer.frame().height()/Math.cos(angle * (Math.PI/180)),2)-Math.pow(layer.frame().height(),2)))/2; | |
return (angle<0) ? -offset : offset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment