2011-04-26 10:46:36 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
2011-06-30 09:57:17 -04:00
|
|
|
<title>Stars</title>
|
2011-05-05 11:25:17 -04:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2011-06-12 14:03:18 -04:00
|
|
|
<script type="text/javascript" src="../../dist/paper.js"></script>
|
2011-04-26 10:46:36 -04:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
|
|
|
function onMouseDown(event) {
|
|
|
|
var hue = Math.random() * 360;
|
2011-11-10 13:16:34 -05:00
|
|
|
project.currentStyle.fillColor = new HsbColor(hue, 1, 1);
|
2011-04-26 10:46:36 -04:00
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2011-04-26 10:46:36 -04:00
|
|
|
function onMouseDrag(event) {
|
2011-05-15 06:36:10 -04:00
|
|
|
var delta = event.point - event.downPoint;
|
|
|
|
var radius = delta.length;
|
|
|
|
var points = 5 + Math.round(radius / 50);
|
2013-03-09 10:28:53 -05:00
|
|
|
var path = new Path.Star({
|
|
|
|
center: event.downPoint,
|
|
|
|
numPoints: points,
|
|
|
|
radius1: radius / 2,
|
|
|
|
radius2: radius
|
|
|
|
});
|
2011-04-26 10:46:36 -04:00
|
|
|
path.rotate(delta.angle);
|
|
|
|
// Remove the path automatically before the next mouse drag
|
|
|
|
// event:
|
|
|
|
path.removeOnDrag();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2011-06-29 07:44:06 -04:00
|
|
|
<canvas id="canvas" resize></canvas>
|
2011-05-30 18:27:39 -04:00
|
|
|
</body>
|
|
|
|
</html>
|