Created
May 24, 2013 22:14
-
-
Save lmccart/5646852 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
var values = { | |
radius: 40, | |
opacity: 1, | |
color: 'red', | |
animate: false | |
}; | |
var components = { | |
radius: { | |
type: 'slider', label: 'Radius', | |
min: 10, max: 100, | |
step: 5 | |
}, | |
opacity: { | |
type: 'slider', label: 'Opacity', | |
min: 0, max: 1, | |
step: 0.01 | |
}, | |
color: { | |
type: 'list', label: 'Color', | |
options: ['red', 'yellow', 'purple', 'green'] | |
}, | |
animate: { | |
type: 'boolean', label: 'Animate' | |
} | |
}; | |
var palette = new Palette('My Palette', components, values); | |
function onMouseDrag(event) { | |
var circle = new Path.Circle(event.point, values.radius); | |
circle.fillColor = values.color; | |
circle.opacity = values.opacity; | |
if (values.animate) { | |
var count = 0; | |
var vector = new Point(1, 0); | |
circle.onFrame = function(event) { | |
if (count < 100) { | |
circle.position += vector; | |
circle.scale(1.005, 1.003); | |
} else if (count < 200) { | |
circle.position -= vector; | |
circle.scale(1 / 1.005, 1 / 1.003); | |
} | |
count++; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment