Skip to content

Instantly share code, notes, and snippets.

@lmccart
Created April 24, 2014 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmccart/11253473 to your computer and use it in GitHub Desktop.
Save lmccart/11253473 to your computer and use it in GitHub Desktop.
sketch.paperjs test code
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