paper.js/examples/Tools/Wave.html

48 lines
1.1 KiB
HTML
Raw Normal View History

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>
<link rel="stylesheet" href="../css/style.css">
<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();
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>
<canvas id="canvas" resize keepalive="true"></canvas>
2011-05-30 18:27:39 -04:00
</body>
</html>