2011-02-21 08:31:26 -05:00
|
|
|
<!DOCTYPE html>
|
2011-02-08 07:16:43 -05:00
|
|
|
<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-06-12 14:03:18 -04:00
|
|
|
<script type="text/javascript" src="../../dist/paper.js"></script>
|
2011-03-04 06:38:38 -05:00
|
|
|
<script type="text/paperscript" canvas="canvas">
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Values
|
2011-02-08 07:16:43 -05:00
|
|
|
|
2011-03-04 06:38:38 -05:00
|
|
|
tool.minDistance = 10;
|
2011-02-08 07:16:43 -05:00
|
|
|
|
2011-03-04 06:38:38 -05:00
|
|
|
var values = {
|
|
|
|
curviness: 0.5,
|
|
|
|
distance: tool.minDistance,
|
|
|
|
offset: 10,
|
|
|
|
mouseOffset: true
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Mouse handling
|
|
|
|
|
|
|
|
var path;
|
|
|
|
function onMouseDown(event) {
|
|
|
|
path = new Path();
|
2011-03-04 19:02:46 -05:00
|
|
|
path.strokeColor = '#000000';
|
2011-03-04 06:38:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var mul = 1;
|
|
|
|
function onMouseDrag(event) {
|
|
|
|
var step = event.delta.rotate(90 * mul);
|
|
|
|
|
|
|
|
if (!values.mouseOffset)
|
|
|
|
step.length = values.offset;
|
|
|
|
|
|
|
|
var segment = new Segment(event.point + step);
|
|
|
|
segment.handleIn = -event.delta * values.curviness;
|
|
|
|
segment.handleOut = event.delta * values.curviness;
|
|
|
|
path.add(segment);
|
|
|
|
mul *= -1;
|
2011-02-08 07:16:43 -05:00
|
|
|
}
|
|
|
|
</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>
|