paper 0.12.18 → 0.12.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/docs/assets/js/paper.js +91 -53
  3. package/dist/docs/classes/Color.html +2 -2
  4. package/dist/docs/classes/CompoundPath.html +2 -2
  5. package/dist/docs/classes/Curve.html +2 -2
  6. package/dist/docs/classes/CurveLocation.html +2 -2
  7. package/dist/docs/classes/Event.html +2 -2
  8. package/dist/docs/classes/Gradient.html +2 -2
  9. package/dist/docs/classes/GradientStop.html +2 -2
  10. package/dist/docs/classes/Group.html +2 -2
  11. package/dist/docs/classes/HitResult.html +2 -2
  12. package/dist/docs/classes/Item.html +2 -2
  13. package/dist/docs/classes/Key.html +2 -2
  14. package/dist/docs/classes/KeyEvent.html +2 -2
  15. package/dist/docs/classes/Layer.html +2 -2
  16. package/dist/docs/classes/Matrix.html +2 -2
  17. package/dist/docs/classes/MouseEvent.html +2 -2
  18. package/dist/docs/classes/PaperScope.html +2 -2
  19. package/dist/docs/classes/PaperScript.html +2 -2
  20. package/dist/docs/classes/Path.html +2 -2
  21. package/dist/docs/classes/PathItem.html +2 -2
  22. package/dist/docs/classes/Point.html +2 -2
  23. package/dist/docs/classes/PointText.html +2 -2
  24. package/dist/docs/classes/Project.html +2 -2
  25. package/dist/docs/classes/Raster.html +2 -2
  26. package/dist/docs/classes/Rectangle.html +2 -2
  27. package/dist/docs/classes/Segment.html +2 -2
  28. package/dist/docs/classes/Shape.html +2 -2
  29. package/dist/docs/classes/Size.html +2 -2
  30. package/dist/docs/classes/Style.html +2 -2
  31. package/dist/docs/classes/SymbolDefinition.html +2 -2
  32. package/dist/docs/classes/SymbolItem.html +2 -2
  33. package/dist/docs/classes/TextItem.html +2 -2
  34. package/dist/docs/classes/Tool.html +2 -2
  35. package/dist/docs/classes/ToolEvent.html +2 -2
  36. package/dist/docs/classes/Tween.html +2 -2
  37. package/dist/docs/classes/View.html +2 -2
  38. package/dist/docs/classes/global.html +2 -2
  39. package/dist/docs/classes/index.html +2 -2
  40. package/dist/docs/index.html +1 -1
  41. package/dist/paper-core.js +90 -52
  42. package/dist/paper-core.min.js +3 -3
  43. package/dist/paper-full.js +91 -53
  44. package/dist/paper-full.min.js +3 -3
  45. package/dist/paper.d.ts +2 -2
  46. package/package.json +5 -2
  47. package/dist/paperjs/LICENSE.txt +0 -23
  48. package/dist/paperjs/dist/node/canvas.js +0 -66
  49. package/dist/paperjs/dist/node/extend.js +0 -156
  50. package/dist/paperjs/dist/node/self.js +0 -58
  51. package/dist/paperjs/dist/node/xml.js +0 -40
  52. package/dist/paperjs/dist/paper-core.d.ts +0 -1
  53. package/dist/paperjs/dist/paper-core.js +0 -15703
  54. package/dist/paperjs/dist/paper-core.min.js +0 -32
  55. package/dist/paperjs/dist/paper-full.js +0 -17472
  56. package/dist/paperjs/dist/paper-full.min.js +0 -32
  57. package/dist/paperjs/dist/paper.d.ts +0 -7394
  58. package/dist/paperjs/docs/assets/css/docs.css +0 -414
  59. package/dist/paperjs/docs/assets/js/codemirror.js +0 -4
  60. package/dist/paperjs/docs/assets/js/docs.js +0 -493
  61. package/dist/paperjs/docs/assets/js/jquery.js +0 -6
  62. package/dist/paperjs/docs/assets/js/paper.js +0 -17472
  63. package/dist/paperjs/docs/classes/Color.html +0 -2188
  64. package/dist/paperjs/docs/classes/CompoundPath.html +0 -8877
  65. package/dist/paperjs/docs/classes/Curve.html +0 -2323
  66. package/dist/paperjs/docs/classes/CurveLocation.html +0 -672
  67. package/dist/paperjs/docs/classes/Event.html +0 -176
  68. package/dist/paperjs/docs/classes/Gradient.html +0 -240
  69. package/dist/paperjs/docs/classes/GradientStop.html +0 -273
  70. package/dist/paperjs/docs/classes/Group.html +0 -6864
  71. package/dist/paperjs/docs/classes/HitResult.html +0 -239
  72. package/dist/paperjs/docs/classes/Item.html +0 -6628
  73. package/dist/paperjs/docs/classes/Key.html +0 -139
  74. package/dist/paperjs/docs/classes/KeyEvent.html +0 -308
  75. package/dist/paperjs/docs/classes/Layer.html +0 -6850
  76. package/dist/paperjs/docs/classes/Matrix.html +0 -1744
  77. package/dist/paperjs/docs/classes/MouseEvent.html +0 -355
  78. package/dist/paperjs/docs/classes/PaperScope.html +0 -459
  79. package/dist/paperjs/docs/classes/PaperScript.html +0 -198
  80. package/dist/paperjs/docs/classes/Path.html +0 -11775
  81. package/dist/paperjs/docs/classes/PathItem.html +0 -8639
  82. package/dist/paperjs/docs/classes/Point.html +0 -2699
  83. package/dist/paperjs/docs/classes/PointText.html +0 -7029
  84. package/dist/paperjs/docs/classes/Project.html +0 -1305
  85. package/dist/paperjs/docs/classes/Raster.html +0 -7843
  86. package/dist/paperjs/docs/classes/Rectangle.html +0 -1654
  87. package/dist/paperjs/docs/classes/Segment.html +0 -939
  88. package/dist/paperjs/docs/classes/Shape.html +0 -7363
  89. package/dist/paperjs/docs/classes/Size.html +0 -1825
  90. package/dist/paperjs/docs/classes/Style.html +0 -919
  91. package/dist/paperjs/docs/classes/SymbolDefinition.html +0 -311
  92. package/dist/paperjs/docs/classes/SymbolItem.html +0 -6755
  93. package/dist/paperjs/docs/classes/TextItem.html +0 -6869
  94. package/dist/paperjs/docs/classes/Tool.html +0 -761
  95. package/dist/paperjs/docs/classes/ToolEvent.html +0 -446
  96. package/dist/paperjs/docs/classes/Tween.html +0 -374
  97. package/dist/paperjs/docs/classes/View.html +0 -1772
  98. package/dist/paperjs/docs/classes/global.html +0 -425
  99. package/dist/paperjs/docs/classes/index.html +0 -88
  100. package/dist/paperjs/docs/index.html +0 -11
  101. package/dist/paperjs/examples/Animated/AnimatedStar.html +0 -53
  102. package/dist/paperjs/examples/Animated/BooleanOperations.html +0 -115
  103. package/dist/paperjs/examples/Animated/CandyCrash.html +0 -151
  104. package/dist/paperjs/examples/Animated/Extruded.html +0 -50
  105. package/dist/paperjs/examples/Animated/Lines.html +0 -53
  106. package/dist/paperjs/examples/Animated/Smoothing.html +0 -70
  107. package/dist/paperjs/examples/Animated/Space.html +0 -86
  108. package/dist/paperjs/examples/Animated/SpaceUsingShapes.html +0 -79
  109. package/dist/paperjs/examples/Games/Paperoids.html +0 -569
  110. package/dist/paperjs/examples/JSON/Circle Testing.html +0 -34
  111. package/dist/paperjs/examples/JSON/Compound Path.html +0 -25
  112. package/dist/paperjs/examples/JSON/Empty Path Testing.html +0 -31
  113. package/dist/paperjs/examples/JSON/Gradients.html +0 -34
  114. package/dist/paperjs/examples/JSON/Group Transform.html +0 -28
  115. package/dist/paperjs/examples/JSON/Line Testing.html +0 -44
  116. package/dist/paperjs/examples/JSON/Random Path Testing.html +0 -42
  117. package/dist/paperjs/examples/JSON/Raster.html +0 -29
  118. package/dist/paperjs/examples/JSON/Rect and Attribute Testing.html +0 -56
  119. package/dist/paperjs/examples/JSON/Rotated Primitives.html +0 -55
  120. package/dist/paperjs/examples/JSON/Selection.html +0 -43
  121. package/dist/paperjs/examples/JSON/Shapes.html +0 -54
  122. package/dist/paperjs/examples/JSON/Symbols.html +0 -30
  123. package/dist/paperjs/examples/JSON/Text Testing.html +0 -38
  124. package/dist/paperjs/examples/JSON/Tiger.html +0 -19
  125. package/dist/paperjs/examples/JSON/Transform Test 1.html +0 -32
  126. package/dist/paperjs/examples/JSON/Transform Test 2.html +0 -30
  127. package/dist/paperjs/examples/Node.js/AnimatedStar.js +0 -52
  128. package/dist/paperjs/examples/Node.js/BooleanOperations.js +0 -36
  129. package/dist/paperjs/examples/Node.js/JSONtoPDF.js +0 -20
  130. package/dist/paperjs/examples/Node.js/Raster.js +0 -32
  131. package/dist/paperjs/examples/Node.js/RasterRemote.js +0 -33
  132. package/dist/paperjs/examples/Node.js/SvgExport.js +0 -52
  133. package/dist/paperjs/examples/Node.js/SvgImport.js +0 -23
  134. package/dist/paperjs/examples/Node.js/Tadpoles.js +0 -16
  135. package/dist/paperjs/examples/Node.js/Tadpoles.pjs +0 -278
  136. package/dist/paperjs/examples/Node.js/in.json +0 -1
  137. package/dist/paperjs/examples/Node.js/in.svg +0 -16
  138. package/dist/paperjs/examples/Paperjs.org/BooleanOperattions.html +0 -115
  139. package/dist/paperjs/examples/Paperjs.org/BouncingBalls.html +0 -103
  140. package/dist/paperjs/examples/Paperjs.org/Chain.html +0 -54
  141. package/dist/paperjs/examples/Paperjs.org/DivisionRaster.html +0 -72
  142. package/dist/paperjs/examples/Paperjs.org/FutureSplash.html +0 -122
  143. package/dist/paperjs/examples/Paperjs.org/HitTesting.html +0 -103
  144. package/dist/paperjs/examples/Paperjs.org/InteractiveTiger.html +0 -777
  145. package/dist/paperjs/examples/Paperjs.org/MetaBalls.html +0 -132
  146. package/dist/paperjs/examples/Paperjs.org/NyanRainbow.html +0 -202
  147. package/dist/paperjs/examples/Paperjs.org/PathIntersections.html +0 -76
  148. package/dist/paperjs/examples/Paperjs.org/Qbertify.html +0 -146
  149. package/dist/paperjs/examples/Paperjs.org/RadialRainbows.html +0 -80
  150. package/dist/paperjs/examples/Paperjs.org/RoundedRectangles.html +0 -41
  151. package/dist/paperjs/examples/Paperjs.org/SatieLikedToDraw.html +0 -140
  152. package/dist/paperjs/examples/Paperjs.org/Simplify.html +0 -63
  153. package/dist/paperjs/examples/Paperjs.org/SpiralRaster.html +0 -120
  154. package/dist/paperjs/examples/Paperjs.org/Tadpoles.html +0 -283
  155. package/dist/paperjs/examples/Paperjs.org/Voronoi.html +0 -134
  156. package/dist/paperjs/examples/Rasters/PhyllotaxisRaster.html +0 -96
  157. package/dist/paperjs/examples/Rasters/Raster.html +0 -34
  158. package/dist/paperjs/examples/Rasters/RotationRaster.html +0 -44
  159. package/dist/paperjs/examples/Rasters/Smoothing.html +0 -36
  160. package/dist/paperjs/examples/SVG Export/Circle Testing.html +0 -32
  161. package/dist/paperjs/examples/SVG Export/Clipping.html +0 -17
  162. package/dist/paperjs/examples/SVG Export/Compound Path.html +0 -22
  163. package/dist/paperjs/examples/SVG Export/Empty Path Testing.html +0 -28
  164. package/dist/paperjs/examples/SVG Export/Gradients.html +0 -52
  165. package/dist/paperjs/examples/SVG Export/Group Transform.html +0 -25
  166. package/dist/paperjs/examples/SVG Export/Line Testing.html +0 -41
  167. package/dist/paperjs/examples/SVG Export/Random Path Testing.html +0 -39
  168. package/dist/paperjs/examples/SVG Export/Raster.html +0 -21
  169. package/dist/paperjs/examples/SVG Export/Rect and Attribute Testing.html +0 -53
  170. package/dist/paperjs/examples/SVG Export/Rotated Primitives.html +0 -80
  171. package/dist/paperjs/examples/SVG Export/Shapes.html +0 -58
  172. package/dist/paperjs/examples/SVG Export/Symbols.html +0 -27
  173. package/dist/paperjs/examples/SVG Export/Text Testing.html +0 -45
  174. package/dist/paperjs/examples/SVG Export/Tiger.html +0 -23
  175. package/dist/paperjs/examples/SVG Export/Transform Test 1.html +0 -29
  176. package/dist/paperjs/examples/SVG Export/Transform Test 2.html +0 -27
  177. package/dist/paperjs/examples/SVG Import/Arcs.html +0 -78
  178. package/dist/paperjs/examples/SVG Import/Butterfly.html +0 -223
  179. package/dist/paperjs/examples/SVG Import/Circle and Ellipse Testing.html +0 -26
  180. package/dist/paperjs/examples/SVG Import/Clipping.html +0 -100
  181. package/dist/paperjs/examples/SVG Import/From File.html +0 -30
  182. package/dist/paperjs/examples/SVG Import/Gradient.html +0 -138
  183. package/dist/paperjs/examples/SVG Import/Gradients.html +0 -30
  184. package/dist/paperjs/examples/SVG Import/Inkscape Pivot.html +0 -52
  185. package/dist/paperjs/examples/SVG Import/Inkscape.html +0 -88
  186. package/dist/paperjs/examples/SVG Import/Line Testing.html +0 -24
  187. package/dist/paperjs/examples/SVG Import/MoreGradients.html +0 -107
  188. package/dist/paperjs/examples/SVG Import/Multiple Paths Test 1.html +0 -42
  189. package/dist/paperjs/examples/SVG Import/Multiple Paths Test 2.html +0 -33
  190. package/dist/paperjs/examples/SVG Import/Nested Groups Test.html +0 -78
  191. package/dist/paperjs/examples/SVG Import/Polybezier.html +0 -43
  192. package/dist/paperjs/examples/SVG Import/Rect Testing.html +0 -25
  193. package/dist/paperjs/examples/SVG Import/Symbols.html +0 -24
  194. package/dist/paperjs/examples/SVG Import/Testing.html +0 -40
  195. package/dist/paperjs/examples/SVG Import/Text Testing.html +0 -19
  196. package/dist/paperjs/examples/SVG Import/Tiger.html +0 -742
  197. package/dist/paperjs/examples/SVG Import/Transform Testing.html +0 -22
  198. package/dist/paperjs/examples/SVG Import/Viewbox.html +0 -38
  199. package/dist/paperjs/examples/Scripts/Arcs.html +0 -39
  200. package/dist/paperjs/examples/Scripts/BlendModes.html +0 -77
  201. package/dist/paperjs/examples/Scripts/BooleanOperations.html +0 -937
  202. package/dist/paperjs/examples/Scripts/CompoundPath.html +0 -19
  203. package/dist/paperjs/examples/Scripts/CurveTimeParameterization.html +0 -61
  204. package/dist/paperjs/examples/Scripts/HslColor.html +0 -53
  205. package/dist/paperjs/examples/Scripts/PathStructure.html +0 -82
  206. package/dist/paperjs/examples/Scripts/PathTangents.html +0 -73
  207. package/dist/paperjs/examples/Scripts/Resize.html +0 -42
  208. package/dist/paperjs/examples/Scripts/RoundRectangle.html +0 -28
  209. package/dist/paperjs/examples/Scripts/Shapes.html +0 -54
  210. package/dist/paperjs/examples/Scripts/StrokeBounds.html +0 -101
  211. package/dist/paperjs/examples/Scripts/StrokeScaling.html +0 -65
  212. package/dist/paperjs/examples/Tools/BezierTool.html +0 -90
  213. package/dist/paperjs/examples/Tools/Circles.html +0 -28
  214. package/dist/paperjs/examples/Tools/Clouds.html +0 -35
  215. package/dist/paperjs/examples/Tools/DrippingBrush.html +0 -73
  216. package/dist/paperjs/examples/Tools/FancyBrush.html +0 -82
  217. package/dist/paperjs/examples/Tools/Grid.html +0 -44
  218. package/dist/paperjs/examples/Tools/MultiLines.html +0 -44
  219. package/dist/paperjs/examples/Tools/MultipleTools.html +0 -44
  220. package/dist/paperjs/examples/Tools/PathEditing.html +0 -95
  221. package/dist/paperjs/examples/Tools/SquareRounded.html +0 -76
  222. package/dist/paperjs/examples/Tools/Stars.html +0 -38
  223. package/dist/paperjs/examples/Tools/Vektor.html +0 -200
  224. package/dist/paperjs/examples/Tools/Wave.html +0 -50
  225. package/dist/paperjs/examples/Tools/WormFarm.html +0 -88
  226. package/dist/paperjs/examples/Worker/Main.html +0 -53
  227. package/dist/paperjs/examples/Worker/Worker.js +0 -14
  228. package/dist/paperjs/examples/css/style.css +0 -12
@@ -1,569 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
6
- <title>Paperoids</title>
7
- <script type="text/javascript" src="../../dist/paper-full.js"></script>
8
- <script type="text/paperscript" canvas="canvas">
9
-
10
- //
11
- //
12
- // Paperoids - an Asteroids clone for paper.js
13
- //
14
- // Sorry nerds, no enemy ships or sound just yet.
15
- //
16
- // Version: 1.2.1
17
- // Author: David Hirmes (@hirmes)
18
- // Date: 2011-08-09
19
- //
20
- // Revision History:
21
- // 1.0 - 2011-07-13 - Initial release
22
- // 1.1 - 2011-07-13 - Optimizations by Jonathan Puckey (@jonathanpuckey)
23
- // 1.2 - 2011-07-16 - Refactored with closures (@jonathanpuckey)
24
- // 1.2.1- 2011-08-09 - bug fixes
25
- //
26
-
27
- var presets = {
28
- speed: 0.2,
29
- maxRockSpeed: 4.5,
30
- rockCount: 6,
31
- lives: 3,
32
- freeShipScore: 10000,
33
- freeShipIncrement: 10000
34
- };
35
-
36
- function initialize() {
37
- Rocks.add(presets.rockCount);
38
- Score.update();
39
- Lives.initialize();
40
- }
41
-
42
- function onKeyUp(event) {
43
- if (event.key == 'space') {
44
- Ship.moveTo(Point.random() * view.size);
45
- Ship.stop();
46
- }
47
- if (event.key == 'z') {
48
- Ship.fire();
49
- }
50
- // Show stats:
51
- if (event.key == 'f') {
52
- var stats = document.getElementById('stats');
53
- if (stats) {
54
- stats.style.display = (stats.style.display == 'block')
55
- ? 'none' : 'block';
56
- }
57
- }
58
- }
59
-
60
- function onFrame() {
61
- Bullets.move();
62
- Rocks.iterateExplosions();
63
- Ship.checkCollisions();
64
- if (Key.isDown('left')) {
65
- Ship.turnLeft();
66
- }
67
- if (Key.isDown('right')) {
68
- Ship.turnRight();
69
- }
70
- if (Key.isDown('up')) {
71
- Ship.thrust();
72
- } else {
73
- Ship.coast();
74
- }
75
- Ship.move();
76
- }
77
-
78
- project.currentStyle.strokeColor = 'white';
79
-
80
- var Game = {
81
- roundDelay: false,
82
- over: function() {
83
- document.getElementById('gameover').style.display = 'block';
84
- },
85
- newRound: function() {
86
- Game.roundDelay = false;
87
- Rocks.add(presets.rockCount);
88
- },
89
- // Stats.js by Mr. Doob - https://github.com/mrdoob/stats.js
90
- };
91
-
92
- var assets = {
93
- destroyedShip: new function() {
94
- var group = new Group(
95
- new Path([-10, -8], [10, 0]),
96
- new Path([10, 0], [-10, 8]),
97
- new Path([-8, 4], [-8, -4])
98
- );
99
- group.visible = false;
100
- return group;
101
- },
102
- explosion: new function() {
103
- var explosionPath = new Path.Circle(new Point(), 1);
104
- explosionPath.fillColor = 'white';
105
- explosionPath.strokeColor = null;
106
- return new SymbolDefinition(explosionPath);
107
- }
108
- };
109
-
110
- var Ship = new function() {
111
- var path = new Path([-10, -8], [10, 0], [-10, 8], [-8, 4], [-8, -4]);
112
- path.closed = true;
113
- var thrust = new Path([-8, -4], [-14, 0], [-8, 4]);
114
- var group = new Group(path, thrust);
115
- group.position = view.bounds.center;
116
- return {
117
- item: group,
118
-
119
- angle: 0,
120
-
121
- vector: new Point({
122
- angle: 0.2,
123
- length: 1
124
- }),
125
-
126
- turnLeft: function() {
127
- group.rotate(-3);
128
- this.angle -= 3;
129
- },
130
-
131
- turnRight: function() {
132
- group.rotate(3);
133
- this.angle += 3;
134
- },
135
-
136
- thrust: function() {
137
- thrust.visible = true;
138
- this.vector += new Point({
139
- angle: this.angle,
140
- length: presets.speed
141
- });
142
- if (this.vector.length > 8) {
143
- this.vector.length = 8;
144
- }
145
- },
146
-
147
- stop: function() {
148
- this.vector.length = 0;
149
- },
150
-
151
- fire: function() {
152
- if (!this.dying)
153
- Bullets.fire(this.item.position, this.angle);
154
- },
155
-
156
- coast: function() {
157
- thrust.visible = false;
158
- this.vector *= .992;
159
- },
160
-
161
- move: function() {
162
- group.position += this.vector;
163
- keepInView(group);
164
- },
165
-
166
- moveTo: function(position) {
167
- group.position = position;
168
- keepInView(group);
169
- },
170
-
171
- destroy: function() {
172
- this.destroyedShip = assets.destroyedShip.clone();
173
- this.destroyedShip.position = this.item.position;
174
- this.destroyedShip.visible = true;
175
- this.item.visible = false;
176
- this.stop();
177
- this.item.position = view.center;
178
- this.dying = true;
179
- },
180
-
181
- destroyed: function() {
182
- this.item.visible = true;
183
- this.stop();
184
- this.item.position = view.center;
185
- this.dying = false;
186
- this.destroyedShip.visible = false;
187
- },
188
-
189
- checkCollisions: function() {
190
- var crashRock;
191
-
192
- // move rocks and do a hit-test
193
- // between bounding rect of rocks and ship
194
- for (var i = 0; i < Rocks.children.length; i++) {
195
- var rock = Rocks.children[i];
196
- rock.position += rock.vector;
197
- if (rock.bounds.intersects(this.item.bounds))
198
- crashRock = rock;
199
- keepInView(rock);
200
- }
201
-
202
- if (this.dying) {
203
- var children = this.destroyedShip.children;
204
- children[0].position.x++;
205
- children[1].position.x--;
206
- children[2].position.x--;
207
- children[2].position.y++;
208
- children[0].rotate(1);
209
- children[1].rotate(-1);
210
- children[2].rotate(1);
211
- this.destroyedShip.opacity *= 0.98;
212
-
213
- // don't update anything else if the ship is already dead.
214
- return;
215
- }
216
-
217
-
218
- // if bounding rect collision, do a line intersection test
219
- if (crashRock) {
220
- var tempRock = crashRock.symbol.definition.clone();
221
- tempRock.transform(crashRock.matrix);
222
- tempRock.remove();
223
- var intersections = this.item.firstChild.getIntersections(tempRock);
224
- if (intersections.length > 0)
225
- Lives.remove();
226
- }
227
- }
228
- };
229
- };
230
-
231
- var Bullets = new function() {
232
- var group = new Group();
233
- var children = group.children;
234
-
235
- function checkHits(bullet) {
236
- for (var r = 0; r < Rocks.children.length; r++) {
237
- var rock = Rocks.children[r];
238
- if (rock.bounds.contains(bullet.position) ) {
239
- Score.update(rock.shapeType);
240
- Rocks.explode(rock);
241
- if (rock.shapeType < Rocks.TYPE_SMALL ) {
242
- for (var j = 0; j < 2; j++) {
243
- Rocks.add(1, rock.shapeType + 4, rock.position);
244
- }
245
- }
246
- rock.remove();
247
- bullet.remove();
248
- }
249
- }
250
- }
251
-
252
- return {
253
- fire: function(position, angle) {
254
- // We can only fire 5 bullets at a time:
255
- if (children.length == 5)
256
- return;
257
- var vector = new Point({
258
- angle: angle,
259
- length: 10
260
- });
261
- var bullet = new Path.Circle({
262
- center: position + vector,
263
- radius: 0.5,
264
- parent: group,
265
- fillColor: 'white',
266
- strokeWidth: 'white',
267
- strokeWidth: 0,
268
- data: {
269
- vector: vector,
270
- timeToDie: 58
271
- }
272
- });
273
- },
274
- move: function() {
275
- for (var i = 0; i < children.length; i++) {
276
- var bullet = children[i];
277
- bullet.data.timeToDie--;
278
- if (bullet.data.timeToDie < 1) {
279
- bullet.remove();
280
- } else {
281
- bullet.position += bullet.data.vector;
282
- checkHits(bullet);
283
- keepInView(bullet);
284
- }
285
- }
286
- }
287
- };
288
- };
289
-
290
- var Rocks = new function() {
291
- var group = new Group();
292
- var shapes = [
293
- new Path(
294
- [-23, -40.5], [0, -30.5], [24, -40.5], [45, -21.5], [25, -12.5],
295
- [46, 9.5], [22, 38.5], [-10, 30.5], [-22, 40.5], [-46, 18.5],
296
- [-33, 0.5], [-44, -21.5], [-23, -40.5]),
297
- new Path(
298
- [-45, -9.5], [-12, -40.5], [24, -40.5], [46, -11.5], [45, 10.5],
299
- [24, 40.5], [0, 40.5], [0, 10.5], [-23, 38.5], [-46, 9.5], [-25, 0.5],
300
- [-45, -9.5]),
301
- new Path([-21.5, -39.5], [11.5, -39.5], [45.5, -20.5],
302
- [45.5, -8.5], [9.5, 0.5], [44.5, 21.5], [22.5, 39.5], [9.5, 31.5],
303
- [-20.5, 39.5], [-45.5, 10.5], [-45.5, -20.5], [-11.5, -21.5],
304
- [-21.5, -39.5]),
305
- new Path(
306
- [-22.5, -40.5], [-0.5, -19.5], [23.5, -39.5], [44.5, -21.5],
307
- [33.5, 0.5], [46.5, 19.5], [13.5, 40.5], [-22.5, 39.5], [-46.5, 18.5],
308
- [-46.5, -18.5], [-22.5, -40.5])
309
- ];
310
-
311
- // medium rocks
312
- for (var i = 4; i < 8; i++) {
313
- shapes[i] = shapes[i - 4].clone();
314
- shapes[i].scale(0.5);
315
- }
316
-
317
- // small rocks
318
- for (var i = 8; i < 12; i++) {
319
- shapes[i] = shapes[i - 4].clone();
320
- shapes[i].scale(0.4);
321
- }
322
-
323
- var rockSymbols = [];
324
- for (var i = 0; i < shapes.length; i++) {
325
- rockSymbols[i] = new SymbolDefinition(shapes[i]);
326
- }
327
-
328
- var explosions = new Group();
329
-
330
- return {
331
- shapes: shapes,
332
- children: group.children,
333
- make: function(type, pos) {
334
- var randomRock = type + Math.floor(4 * Math.random());
335
- var rock = rockSymbols[randomRock].place();
336
- rock.position = pos ? pos : Point.random() * view.size;
337
- rock.vector = new Point({
338
- angle: 360 * Math.random(),
339
- length: presets.maxRockSpeed * Math.random() + 0.1
340
- });
341
- rock.shapeType = type;
342
- return rock;
343
- },
344
- add: function(amount, type, position) {
345
- for (var i = 0; i < amount; i++) {
346
- var rock = this.make(type || this.TYPE_BIG, position);
347
- group.addChild(rock);
348
- }
349
- },
350
- explode: function(rock) {
351
- var boomRock = rock.symbol.definition.clone();
352
- boomRock.position = rock.position;
353
- for (var i = 0; i < boomRock.segments.length; i++) {
354
- var segmentPoint = boomRock.segments[i].point;
355
- var placed = assets.explosion.place(segmentPoint);
356
- placed.vector = (placed.position - rock.position) * 0.1;
357
- explosions.addChild(placed);
358
- }
359
- boomRock.remove();
360
- },
361
- iterateExplosions: function() {
362
- for (var i = 0; i < explosions.children.length; i++) {
363
- var explosion = explosions.children[i];
364
- explosion.vector.length *= .7;
365
- explosion.position += explosion.vector;
366
- explosion.opacity = explosion.vector.length;
367
- if (explosion.vector.length < 0.05 ) {
368
- explosion.remove();
369
- // if no more rocks, wait a second and start a new round
370
- if (this.children.length < 1 && !Game.roundDelay) {
371
- Game.roundDelay = true;
372
- presets.rockCount += 2;
373
- setTimeout(Game.newRound, 1000);
374
- }
375
- }
376
- }
377
- },
378
- TYPE_BIG: 0,
379
- TYPE_MEDIUM: 4,
380
- TYPE_SMALL: 8
381
- };
382
- };
383
-
384
- var Score = new function() {
385
- var numberGroup = new Group(
386
- new Path([0, 0], [20, 0], [20, 27], [0, 27], [0, 0]),
387
- new Path([10, 0], [10, 27]),
388
- new Path([0, 0], [20, 0], [20, 14], [0, 14], [0, 27], [20, 27]),
389
- new Path([0, 0], [20, 0], [20, 14], [0, 14], [20, 14], [20, 27], [0, 27]),
390
- new Path([0, 0], [0, 14], [20, 14], [20, 0], [20, 27]),
391
- new Path([20, 0], [0, 0], [0, 14], [20, 14], [20, 27], [0, 27]),
392
- new Path([20, 0], [0, 0], [0, 27], [20, 27], [20, 14], [0, 14]),
393
- new Path([0, 0], [20, 0], [0, 27]),
394
- new Path([0, 0], [20, 0], [20, 27], [0, 27], [0, 0], [0, 14], [20, 14]),
395
- new Path([20, 14], [0, 14], [0, 0], [20, 0], [20, 27])
396
- );
397
- numberGroup.visible = false;
398
- var scoreDisplay = new Group();
399
- var score = 0;
400
- return {
401
- update: function(type) {
402
- if (type == Rocks.TYPE_BIG) score += 20;
403
- if (type == Rocks.TYPE_MEDIUM) score += 50;
404
- if (type == Rocks.TYPE_SMALL) score += 100;
405
- if (score >= presets.freeShipScore) {
406
- Lives.add(1);
407
- presets.freeShipScore += presets.freeShipIncrement;
408
- }
409
- scoreDisplay.removeChildren();
410
-
411
- var scoreString = score + '';
412
- for (var i = 0; i < scoreString.length; i++) {
413
- var n = parseInt(scoreString[i], 10);
414
- scoreDisplay.addChild(numberGroup.children[n].clone());
415
- scoreDisplay.lastChild.position = [22 + i * 24, 22];
416
- }
417
- }
418
- };
419
- };
420
-
421
- var Lives = new function() {
422
- var currentLives;
423
- var shipPath = Ship.item.firstChild.clone();
424
- project.activeLayer.addChild(shipPath);
425
- shipPath.visible = false;
426
- Ship.visible = false;
427
- var group = new Group();
428
- return {
429
- initialize: function() {
430
- currentLives = presets.lives;
431
- this.display();
432
- },
433
- add: function() {
434
- currentLives++;
435
- this.display();
436
- },
437
- remove: function() {
438
- currentLives--;
439
- this.display();
440
- Ship.destroy();
441
- setTimeout(function() {
442
- if (currentLives == 0) {
443
- Game.over();
444
- } else {
445
- Ship.destroyed();
446
- }
447
- }, 1200);
448
- },
449
- display: function() {
450
- group.removeChildren();
451
- for (var i = 0;i < currentLives - 1; i++) {
452
- var copy = shipPath.clone();
453
- copy.rotate(-90);
454
- copy.visible = true;
455
- group.addChild(copy);
456
- copy.position = [22+ i * copy.bounds.width, 53];
457
- }
458
- }
459
- };
460
- };
461
-
462
- initialize();
463
-
464
- // Stop left and right keyboard events from propagating.
465
- function onKeyDown(event) {
466
- if (event.key == 'left' || event.key == 'right') {
467
- return false;
468
- }
469
- }
470
-
471
- function keepInView(item) {
472
- var position = item.position;
473
- var itemBounds = item.bounds;
474
- var bounds = view.bounds;
475
-
476
- if (itemBounds.left > bounds.width) {
477
- position.x = -item.bounds.width;
478
- }
479
-
480
- if (position.x < -itemBounds.width) {
481
- position.x = bounds.width;
482
- }
483
-
484
- if (itemBounds.top > view.size.height) {
485
- position.y = -itemBounds.height;
486
- }
487
-
488
- if (position.y < -itemBounds.height) {
489
- position.y = bounds.height + itemBounds.height / 2;
490
- }
491
- }
492
- </script>
493
- <style type="text/css">
494
- html,
495
- body {
496
- margin: 0;
497
- overflow: hidden;
498
- height: 100%;
499
- }
500
-
501
- canvas {
502
- width: 100%;
503
- height: 100%;
504
- }
505
-
506
- body {
507
- background: #000;
508
- font-family:Helvetica,Arial;
509
- }
510
-
511
- .footer {
512
- position:absolute;
513
- bottom:0;
514
- color:#ff0000;
515
- background-color: rgba(60,60,60,0.8);
516
- font-size:0.75em;
517
- padding:0.5em;
518
- color:#ddd;
519
- width: 100%
520
- }
521
-
522
- .footer a {
523
- color: #fff;
524
- font-weight:
525
- bold; text-decoration: none;
526
- border-bottom: 1px solid #555;
527
- }
528
-
529
- .footer b {
530
- background-color: #660000;
531
- padding-left: 0.25em;
532
- padding-right: 0.25em;
533
- }
534
-
535
- .gameover {
536
- display: none;
537
- position: absolute;
538
- left: 40%;
539
- top: 40%;
540
- color: #fff;
541
- background-color: rgba(60,60,60,0.8);
542
- padding: 32px;
543
- -moz-border-radius: 12px;
544
- -webkit-border-radius: 12px;
545
- border-radius: 12px;
546
- -moz-background-clip: padding;
547
- -webkit-background-clip: padding-box;
548
- background-clip: padding-box;
549
- }
550
-
551
- .gameover a {
552
- color: #fff;
553
- font-weight: bold;
554
- }
555
-
556
- #stats {
557
- position: absolute;
558
- left: auto !important;
559
- right: 0px;
560
- }
561
- </style>
562
- </head>
563
- <body>
564
- <canvas id="canvas" resize stats></canvas>
565
- <div id="footer" class="footer"><a href=#">Paperoids</a>. To Play: <b>&#8592;</b> and <b>&#8594;</b> to rotate. <b>&#8593;</b> for thrust. <b>Z</b> to fire. <b>F</b> to show FPS. Follow @<a href="http://twitter.com/#/hirmes">hirmes</a> for updates. Made with the amazing <a href="http://paperjs.org">Paper.js</a></div>
566
-
567
- <div id="gameover" class="gameover">Game Over. <a href="Paperoids.html">Play again</a>?</div>
568
- </body>
569
- </html>
@@ -1,34 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Circle Testing</title>
6
- <link rel="stylesheet" href="../css/style.css">
7
- <script type="text/javascript" src="../../dist/paper-full.js"></script>
8
- <script type="text/paperscript" canvas="canvas1">
9
- var topLeft = new Point(200, 200);
10
- var size = new Size(150, 100);
11
- var rectangle = new Rectangle(topLeft, size);
12
- var path = new Path.Ellipse(rectangle);
13
- path.fillColor = 'black';
14
-
15
- var topLeft = new Point(5, 400);
16
- var size = new Size(100, 50);
17
- var rectangle = new Rectangle(topLeft, size);
18
- var path = new Path.Ellipse(rectangle);
19
- path.fillColor = 'yellow';
20
-
21
- var path = new Path.Circle(new Point(50, 50), 25);
22
- path.fillColor = 'red';
23
- window._json = project.exportJSON();
24
- console.log(window._json);
25
- </script>
26
- <script type="text/paperscript" canvas="canvas2">
27
- project.importJSON(window._json);
28
- </script>
29
- </head>
30
- <body>
31
- <canvas id="canvas1" width="500" height="500"></canvas>
32
- <canvas id="canvas2" width="500" height="500"></canvas>
33
- </body>
34
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Compound Path</title>
6
- <link rel="stylesheet" href="../css/style.css">
7
- <script type="text/javascript" src="../../dist/paper-full.js"></script>
8
- <script type="text/paperscript" canvas="canvas1">
9
- project.currentStyle.fillColor = 'black';
10
- var path1 = new Path.Rectangle([200, 200], [100, 100]);
11
- var path2 = new Path.Rectangle([50, 50], [200, 200]);
12
- var path3 = new Path.Rectangle([0, 0], [400, 400]);
13
- new CompoundPath(path1, path2, path3);
14
- window._json = project.exportJSON();
15
- console.log(window._json);
16
- </script>
17
- <script type="text/paperscript" canvas="canvas2">
18
- project.importJSON(window._json);
19
- </script>
20
- </head>
21
- <body>
22
- <canvas id="canvas1" width="500" height="500"></canvas>
23
- <canvas id="canvas2" width="500" height="500"></canvas>
24
- </body>
25
- </html>
@@ -1,31 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Empty Path Testing</title>
6
- <link rel="stylesheet" href="../css/style.css">
7
- <script type="text/javascript" src="../../dist/paper-full.js"></script>
8
- <script type="text/paperscript" canvas="canvas1">
9
- var path = new Path();
10
- path.strokeColor = 'black';
11
- path.add(new Point(30, 30));
12
- path.add(new Point(100, 100));
13
-
14
- var segments = [new Point(30, 90), new Point(100, 150)];
15
- var path2 = new Path(segments);
16
- path2.strokeColor = 'yellow';
17
-
18
- var path3 = new Path();
19
-
20
- window._json = project.exportJSON();
21
- console.log(window._json);
22
- </script>
23
- <script type="text/paperscript" canvas="canvas2">
24
- project.importJSON(window._json);
25
- </script>
26
- </head>
27
- <body>
28
- <canvas id="canvas1" width="500" height="500"></canvas>
29
- <canvas id="canvas2" width="500" height="500"></canvas>
30
- </body>
31
- </html>
@@ -1,34 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Gradients</title>
6
- <link rel="stylesheet" href="../css/style.css">
7
- <script type="text/javascript" src="../../dist/paper-full.js"></script>
8
- <script type="text/paperscript" canvas="canvas1">
9
- var path = new Path.Circle({
10
- center: view.center,
11
- radius: view.bounds.height * 0.4
12
- });
13
- path.fillColor = {
14
- stops: ['yellow', 'red', 'black'],
15
- radial: true,
16
- origin: path.position,
17
- destination: path.bounds.rightCenter
18
- }
19
-
20
- var symbol = new SymbolDefinition(path);
21
- symbol.place(view.center);
22
-
23
- window._json = project.exportJSON();
24
- console.log(window._json);
25
- </script>
26
- <script type="text/paperscript" canvas="canvas2">
27
- project.importJSON(window._json);
28
- </script>
29
- </head>
30
- <body>
31
- <canvas id="canvas1" width="500" height="500"></canvas>
32
- <canvas id="canvas2" width="500" height="500"></canvas>
33
- </body>
34
- </html>