mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Update extruded example to use Project#importJson.
This commit is contained in:
parent
0599aabdb9
commit
2eafb73912
1 changed files with 6 additions and 28 deletions
|
@ -6,41 +6,19 @@
|
|||
<link rel="stylesheet" href="../css/style.css">
|
||||
<script type="text/javascript" src="../../dist/paper.js"></script>
|
||||
<script type="text/paperscript" canvas="canvas">
|
||||
var segments = [
|
||||
[new Point(63.39306640625, 265.7138671875), null, new Point(10.86669921875, 6.96630859375)],
|
||||
[new Point(106.58203125, 277.97412109375), new Point(-16.71826171875, 0), new Point(24.79931640625, 0)],
|
||||
[new Point(145.87060546875, 245.9306640625), new Point(0, 18.947265625), new Point(0, -17.27587890625)],
|
||||
[new Point(110.4833984375, 208.87158203125), new Point(25.35595703125, 9.4736328125), new Point(-30.65087890625, -11.14599609375)],
|
||||
[new Point(60.88525390625, 155.37255859375), new Point(0, 26.19189453125), new Point(0, -29.25732421875)],
|
||||
[new Point(121.62890625, 104.380859375), new Point(-36.501953125, 0), new Point(18.947265625, 0)],
|
||||
[new Point(162.86767578125, 113.576171875), new Point(-8.08056640625, -4.73681640625)],
|
||||
[new Point(156.18017578125, 133.35986328125), null, new Point(-5.8515625, -3.62255859375)],
|
||||
[new Point(120.79296875, 124.443359375), new Point(16.9970703125, 0), new Point(-25.63525390625, 0)],
|
||||
[new Point(85.4052734375, 152.5859375), new Point(0, -12.8173828125), new Point(0, 17.55419921875)],
|
||||
[new Point(122.7431640625, 188.80908203125), new Point(-25.91357421875, -10.03076171875), new Point(31.76513671875, 12.26025390625)],
|
||||
[new Point(170.39111328125, 243.97998046875), new Point(0, -27.58544921875), new Point(0, 28.97900390625)],
|
||||
[new Point(104.91015625, 298.31494140625), new Point(44.30419921875, 0), new Point(-18.111328125, 0)],
|
||||
[new Point(56.984375, 286.0546875), new Point(10.03076171875, 6.6875)]
|
||||
];
|
||||
|
||||
var lineGroup = new Group();
|
||||
var lineCount = 100;
|
||||
for (var i = 0; i < lineCount; i++) {
|
||||
var linePath = new Path.Line([0, 0], [0, 0]);
|
||||
linePath.strokeColor = 'red';
|
||||
lineGroup.addChild(linePath);
|
||||
}
|
||||
lineGroup.strokeColor = 'red';
|
||||
|
||||
var path1 = new Path();
|
||||
path1.segments = segments;
|
||||
path1.closed = true;
|
||||
var path1 = project.importJson('["Path",{"pathData":"M63.39307,265.71387c10.8667,6.96631 26.4707,12.26025 43.18896,12.26025c24.79932,0 39.28857,-13.09619 39.28857,-32.04346c0,-17.27588 -10.03125,-27.58545 -35.38721,-37.05908c-30.65088,-11.146 -49.59814,-27.30713 -49.59814,-53.49902c0,-29.25732 24.2417,-50.9917 60.74365,-50.9917c18.94727,0 33.1582,4.4585 41.23877,9.19531L156.18018,133.35986c-5.85156,-3.62256 -18.39014,-8.9165 -35.38721,-8.9165c-25.63525,0 -35.3877,15.3252 -35.3877,28.14258c0,17.5542 11.42432,26.19238 37.33789,36.22314c31.76514,12.26025 47.64795,27.58545 47.64795,55.1709c0,28.979 -21.17676,54.33496 -65.48096,54.33496c-18.11133,0 -37.89502,-5.57275 -47.92578,-12.26025z"}]');
|
||||
path1.position = view.center;
|
||||
path1.scale(1.5);
|
||||
|
||||
var path2 = new Path();
|
||||
path2.segments = segments;
|
||||
path2.closed = true;
|
||||
path2.position = view.center;
|
||||
var path2 = path1.clone();
|
||||
path1.scale(1.5);
|
||||
path2.scale(2);
|
||||
|
||||
var length1 = path1.length;
|
||||
|
@ -60,8 +38,8 @@
|
|||
var path = lineGroup.children[i];
|
||||
var l1 = (length1 / lineCount * (i + event.count / 10)) % length1;
|
||||
var l2 = (length2 / lineCount * (i + event.count / 10)) % length2;
|
||||
path.segments[0].point = path1.getPointAt(l1),
|
||||
path.segments[1].point = path2.getPointAt(l2);
|
||||
path.firstSegment.point = path1.getPointAt(l1),
|
||||
path.lastSegment.point = path2.getPointAt(l2);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue