paper.js/examples/Tools/Wave.html
2011-05-05 20:08:13 +01:00

48 lines
No EOL
1.2 KiB
HTML

<!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">var root = '../../'</script>
<script type="text/javascript" src="../../src/load.js"></script>
<script type="text/paperscript" canvas="canvas">
//////////////////////////////////////////////////////////////////////
// Values
tool.minDistance = 10;
var values = {
curviness: 0.5,
distance: tool.minDistance,
offset: 10,
mouseOffset: true
};
//////////////////////////////////////////////////////////////////////
// Mouse handling
var path;
function onMouseDown(event) {
path = new Path();
path.strokeColor = '#000000';
}
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;
}
</script>
</head>
<body>
<canvas id='canvas' resize></canvas>
</body>