Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var circle = ...create a circle
- var circleCached = circle.clone();
- var mousePoint = new Point(0, 0);
- // onMouseMove
- var tool = ...initialize a Tool()
- tool.onMouseMove = function (event) {
- mousePoint = event.point;
- }
- // onFrame
- view.onFrame = function (event) {
- // Animation 1: Automatic circular rotation of each segment
- for (var i = 0; i < circle.segments.length; i++) {
- var offsetRotation = new Point(Math.cos(event.time + i * 2), Math.sin(event.time + i * 2)).multiply(15);
- circle.segments[i] = circleCached.segments[i].add(offsetRotation);
- }
- // Animation 2: the circle moves following the mouse movements with transition
- var delta = mousePoint.subtract(circle.position).divide(15);
- circle.position = circle.position.add(delta);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement