Created
February 26, 2014 08:48
-
-
Save vorg/9225975 to your computer and use it in GitHub Desktop.
Paper js scaling
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="js/paper.js"></script> | |
<script type="text/javascript" src="js/paper-error.js"></script> | |
<script type="text/javascript" src="js/paper-timeline.js"></script> | |
<script type="text/paperscript" canvas="myCanvas"> | |
//scaling | |
var shape2 = new Path(); | |
shape2.add(new Point(0, 0)) | |
shape2.add(new Point(100, 0)) | |
shape2.add(new Point(90, 50)) | |
shape2.strokeColor = 'blue'; | |
shape2.closed = true; | |
shape2.position = view.center; | |
//circle.position = center;//shape2.segments[0].point; | |
var pivot = shape2.bounds.topLeft.clone(); | |
var prevScale = 1; | |
var lightScale = { | |
value: 1 | |
} | |
Timeline.anim(lightScale).to({value:5}, 1) | |
onMouseMove = function(event) { | |
} | |
onFrame = function() { | |
Timeline.update(); | |
scale = lightScale.value; | |
shape2.scale(scale / prevScale, pivot); | |
prevScale = scale; | |
} | |
</script> | |
</head> | |
<body> | |
<canvas id="myCanvas" resize></canvas> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're aware you could use Item#pivot now, right?