Reputation: 431
How can I draw multiple circles using paperjs? I tried removing path.removeOnDrag()
it works and after removing fillcolor
, but the output is not as expected.
<script type="text/paperscript" canvas="canvas">
function onMouseDrag(event) {
// The radius is the distance between the position
// where the user clicked and the current position
// of the mouse.
var path = new Path.Circle({
center: event.downPoint,
radius: (event.downPoint - event.point).length,
fillColor: null,
strokeColor: 'black',
strokeWidth: 10
});
// Remove this path on the next drag event:
path.removeOnDrag();
};
</script>
Upvotes: 1
Views: 2548
Reputation: 2201
Here an easy solution: http://jsfiddle.net/vupt3/1/
So on mouseUp you just store the currently drawn path into the array. Then also if you need to, you can access and manipulate those rings later on.
// path we are currently drawing
var path = null;
// array to store paths (so paper.js would still draw them)
var circles = [];
function onMouseDrag(event) {
// The radius is the distance between the position
// where the user clicked and the current position
// of the mouse.
path = new Path.Circle({
center: event.downPoint,
radius: (event.downPoint - event.point).length,
fillColor: null,
strokeColor: 'black',
strokeWidth: 10
});
// Remove this path on the next drag event:
path.removeOnDrag();
};
function onMouseUp(event) {
// if mouseUp event fires, save current path into the array
circles.push(path);
};
Upvotes: 0