paper.js/examples/Tools/Stars.html

30 lines
907 B
HTML
Raw Normal View History

2011-04-26 10:46:36 -04:00
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example</title>
<link rel="stylesheet" href="../css/style.css">
<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;
project.currentStyle.fillColor = new HSBColor(hue, 1, 1);
2011-04-26 10:46:36 -04:00
}
function onMouseDrag(event) {
var delta = event.point - event.downPoint;
var radius = delta.length;
var points = 5 + Math.round(radius / 50);
var position = event.downPoint;
var path = new Path.Star(position, points, radius / 2, 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>
<canvas id="canvas" resize></canvas>
2011-05-30 18:27:39 -04:00
</body>
</html>