paper.js/examples/Tools/Stars.html
2014-08-16 19:24:54 +02:00

38 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Stars</title>
<link rel="stylesheet" href="../css/style.css">
<script type="text/javascript" src="../../dist/paper-full.js"></script>
<script type="text/paperscript" canvas="canvas">
function onMouseDown(event) {
var hue = Math.random() * 360;
project.currentStyle.fillColor = {
hue: hue,
saturation: 1,
brightness: 1
};
}
function onMouseDrag(event) {
var delta = event.point - event.downPoint;
var radius = delta.length;
var points = 5 + Math.round(radius / 50);
var path = new Path.Star({
center: event.downPoint,
points: points,
radius1: radius / 2,
radius2: radius
});
path.rotate(delta.angle);
// Remove the path automatically before the next mouse drag
// event:
path.removeOnDrag();
}
</script>
</head>
<body>
<canvas id="canvas" resize></canvas>
</body>
</html>