mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-13 06:29:11 -04:00
Examples: Renamed a few html files to correct one typo and fix inconsistency with spaces in filenames
This commit is contained in:
parent
4ea9f16bde
commit
b47d988fb3
4 changed files with 0 additions and 0 deletions
examples/Scripts
61
examples/Scripts/CurveTimeParameterization.html
Normal file
61
examples/Scripts/CurveTimeParameterization.html
Normal file
|
@ -0,0 +1,61 @@
|
|||
<!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" src="../../dist/paper.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];
|
||||
|
||||
function onMouseMove(event) {
|
||||
modifyCurve(event.point, true);
|
||||
}
|
||||
|
||||
function modifyCurve(point, remove) {
|
||||
curve.segment2.point = point;
|
||||
var length = curve.length;
|
||||
var step = 10;
|
||||
var iteratively = false;
|
||||
var flatten = true;
|
||||
var num = Math.floor(length / step);
|
||||
var prev = 0;
|
||||
if (flatten) {
|
||||
var clone = path.clone();
|
||||
clone.flatten(step);
|
||||
for (var i = 0; i < clone.segments.length; i++) {
|
||||
var point = clone.segments[i].point;
|
||||
var circle = new Path.Circle(point, step / 2);
|
||||
circle.strokeColor = 'red';
|
||||
if (remove)
|
||||
circle.removeOnMove();
|
||||
}
|
||||
clone.remove();
|
||||
} else {
|
||||
for (var i = 0, pos = 0; i <= num; i++, pos += step) {
|
||||
var t = iteratively
|
||||
? curve.getParameter(step, prev)
|
||||
: curve.getParameter(pos);
|
||||
var point = curve.getPoint(t);
|
||||
var circle = new Path.Circle(point, step / 2);
|
||||
circle.strokeColor = 'red';
|
||||
if (remove)
|
||||
circle.removeOnMove();
|
||||
prev = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// modifyCurve(new Point(400, 377), false);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" resize></canvas>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue