2011-03-19 20:11:06 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>Example</title>
|
2011-05-05 11:25:17 -04:00
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
2011-03-19 20:11:06 -04:00
|
|
|
<script type="text/javascript">var root = '../../'</script>
|
|
|
|
<script type="text/javascript" src="../../src/load.js"></script>
|
|
|
|
<script type="text/paperscript" canvas="canvas">
|
|
|
|
var path = new Path();
|
|
|
|
path.moveTo(200, 200);
|
|
|
|
path.curveTo([170, 50], [300, 200]);
|
|
|
|
path.strokeWidth = 1;
|
|
|
|
path.strokeColor = 'black';
|
|
|
|
var curve = path.curves[0];
|
2011-03-20 07:41:58 -04:00
|
|
|
|
2011-03-19 20:11:06 -04:00
|
|
|
function onMouseMove(event) {
|
2011-04-26 07:31:35 -04:00
|
|
|
modifyCurve(event.point, true);
|
2011-03-20 07:41:58 -04:00
|
|
|
}
|
|
|
|
|
2011-04-26 07:31:35 -04:00
|
|
|
function modifyCurve(point, remove) {
|
2011-03-20 07:41:58 -04:00
|
|
|
curve.segment2.point = point;
|
2011-03-19 20:11:06 -04:00
|
|
|
var length = curve.length;
|
|
|
|
var step = 10;
|
2011-04-26 07:31:35 -04:00
|
|
|
var iteratively = false;
|
2011-03-20 07:41:58 -04:00
|
|
|
var num = Math.floor(length / step);
|
|
|
|
var prev = 0;
|
2011-03-19 20:11:06 -04:00
|
|
|
for (var i = 0, pos = 0; i <= num; i++, pos += step) {
|
2011-03-20 07:41:58 -04:00
|
|
|
var t = iteratively
|
|
|
|
? curve.getParameter(step, prev)
|
|
|
|
: curve.getParameter(pos);
|
2011-03-19 20:11:06 -04:00
|
|
|
var point = curve.getPoint(t);
|
2011-03-20 07:41:58 -04:00
|
|
|
var circle = new Path.Circle(point, step / 2);
|
2011-03-19 20:11:06 -04:00
|
|
|
circle.strokeColor = 'red';
|
2011-03-20 07:41:58 -04:00
|
|
|
if (remove)
|
|
|
|
circle.removeOnMove();
|
|
|
|
prev = t;
|
2011-03-19 20:11:06 -04:00
|
|
|
}
|
|
|
|
}
|
2011-03-20 07:41:58 -04:00
|
|
|
|
2011-04-26 07:31:35 -04:00
|
|
|
// modifyCurve(new Point(400, 377), false);
|
2011-03-20 07:41:58 -04:00
|
|
|
|
2011-03-19 20:11:06 -04:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2011-05-14 06:04:02 -04:00
|
|
|
<canvas id="canvas" resize keepalive="true"></canvas>
|
2011-03-19 20:11:06 -04:00
|
|
|
</body>
|