jclic 2.1.21 → 2.1.23

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 (175) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/jclic-node.js +9 -8
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +4 -4
  7. package/src/GlobalData.js +1 -1
  8. package/src/JClicPlayer.js +2 -2
  9. package/src/bags/MediaBag.js +6 -5
  10. package/dist/1078.jclic-node.js +0 -282
  11. package/dist/1078.jclic-node.js.map +0 -1
  12. package/dist/1196.jclic-node.js +0 -808
  13. package/dist/1196.jclic-node.js.map +0 -1
  14. package/dist/1253.jclic-node.js +0 -1432
  15. package/dist/1253.jclic-node.js.map +0 -1
  16. package/dist/13.jclic-node.js +0 -103
  17. package/dist/13.jclic-node.js.map +0 -1
  18. package/dist/1567.jclic-node.js +0 -2313
  19. package/dist/1567.jclic-node.js.map +0 -1
  20. package/dist/1588.jclic-node.js +0 -602
  21. package/dist/1588.jclic-node.js.map +0 -1
  22. package/dist/1725.jclic-node.js +0 -836
  23. package/dist/1725.jclic-node.js.map +0 -1
  24. package/dist/1731.jclic-node.js +0 -438
  25. package/dist/1731.jclic-node.js.map +0 -1
  26. package/dist/1842.jclic-node.js +0 -651
  27. package/dist/1842.jclic-node.js.map +0 -1
  28. package/dist/2160.jclic-node.js +0 -1016
  29. package/dist/2160.jclic-node.js.map +0 -1
  30. package/dist/222.jclic-node.js +0 -129
  31. package/dist/222.jclic-node.js.map +0 -1
  32. package/dist/2316.jclic-node.js +0 -949
  33. package/dist/2316.jclic-node.js.map +0 -1
  34. package/dist/2355.jclic-node.js +0 -371
  35. package/dist/2355.jclic-node.js.map +0 -1
  36. package/dist/2366.jclic-node.js +0 -431
  37. package/dist/2366.jclic-node.js.map +0 -1
  38. package/dist/2379.jclic-node.js +0 -202
  39. package/dist/2379.jclic-node.js.map +0 -1
  40. package/dist/2437.jclic-node.js +0 -450
  41. package/dist/2437.jclic-node.js.map +0 -1
  42. package/dist/2531.jclic-node.js +0 -869
  43. package/dist/2531.jclic-node.js.map +0 -1
  44. package/dist/2608.jclic-node.js +0 -160
  45. package/dist/2608.jclic-node.js.map +0 -1
  46. package/dist/2715.jclic-node.js +0 -554
  47. package/dist/2715.jclic-node.js.map +0 -1
  48. package/dist/277.jclic-node.js +0 -22
  49. package/dist/277.jclic-node.js.map +0 -1
  50. package/dist/2921.jclic-node.js +0 -660
  51. package/dist/2921.jclic-node.js.map +0 -1
  52. package/dist/2952.jclic-node.js +0 -101
  53. package/dist/2952.jclic-node.js.map +0 -1
  54. package/dist/3018.jclic-node.js +0 -421
  55. package/dist/3018.jclic-node.js.map +0 -1
  56. package/dist/3019.jclic-node.js +0 -682
  57. package/dist/3019.jclic-node.js.map +0 -1
  58. package/dist/3231.jclic-node.js +0 -274
  59. package/dist/3231.jclic-node.js.map +0 -1
  60. package/dist/331.jclic-node.js +0 -115
  61. package/dist/331.jclic-node.js.map +0 -1
  62. package/dist/3391.jclic-node.js +0 -276
  63. package/dist/3391.jclic-node.js.map +0 -1
  64. package/dist/3502.jclic-node.js +0 -671
  65. package/dist/3502.jclic-node.js.map +0 -1
  66. package/dist/3653.jclic-node.js +0 -982
  67. package/dist/3653.jclic-node.js.map +0 -1
  68. package/dist/371.jclic.min.js +0 -2
  69. package/dist/371.jclic.min.js.map +0 -1
  70. package/dist/3856.jclic-node.js +0 -575
  71. package/dist/3856.jclic-node.js.map +0 -1
  72. package/dist/4112.jclic-node.js +0 -659
  73. package/dist/4112.jclic-node.js.map +0 -1
  74. package/dist/4123.jclic-node.js +0 -910
  75. package/dist/4123.jclic-node.js.map +0 -1
  76. package/dist/427.jclic-node.js +0 -894
  77. package/dist/427.jclic-node.js.map +0 -1
  78. package/dist/4483.jclic-node.js +0 -327
  79. package/dist/4483.jclic-node.js.map +0 -1
  80. package/dist/4548.jclic-node.js +0 -1078
  81. package/dist/4548.jclic-node.js.map +0 -1
  82. package/dist/466.jclic-node.js +0 -99
  83. package/dist/466.jclic-node.js.map +0 -1
  84. package/dist/485.jclic-node.js +0 -783
  85. package/dist/485.jclic-node.js.map +0 -1
  86. package/dist/4921.jclic-node.js +0 -500
  87. package/dist/4921.jclic-node.js.map +0 -1
  88. package/dist/5091.jclic-node.js +0 -239
  89. package/dist/5091.jclic-node.js.map +0 -1
  90. package/dist/520.jclic-node.js +0 -550
  91. package/dist/520.jclic-node.js.map +0 -1
  92. package/dist/5312.jclic-node.js +0 -1126
  93. package/dist/5312.jclic-node.js.map +0 -1
  94. package/dist/5338.jclic-node.js +0 -212
  95. package/dist/5338.jclic-node.js.map +0 -1
  96. package/dist/5344.jclic-node.js +0 -229
  97. package/dist/5344.jclic-node.js.map +0 -1
  98. package/dist/5550.jclic-node.js +0 -238
  99. package/dist/5550.jclic-node.js.map +0 -1
  100. package/dist/5626.jclic-node.js +0 -614
  101. package/dist/5626.jclic-node.js.map +0 -1
  102. package/dist/5977.jclic-node.js +0 -1081
  103. package/dist/5977.jclic-node.js.map +0 -1
  104. package/dist/6148.jclic-node.js +0 -345
  105. package/dist/6148.jclic-node.js.map +0 -1
  106. package/dist/6176.jclic-node.js +0 -481
  107. package/dist/6176.jclic-node.js.map +0 -1
  108. package/dist/6221.jclic-node.js +0 -1072
  109. package/dist/6221.jclic-node.js.map +0 -1
  110. package/dist/6238.jclic-node.js +0 -718
  111. package/dist/6238.jclic-node.js.map +0 -1
  112. package/dist/6454.jclic-node.js +0 -1413
  113. package/dist/6454.jclic-node.js.map +0 -1
  114. package/dist/6565.jclic-node.js +0 -294
  115. package/dist/6565.jclic-node.js.map +0 -1
  116. package/dist/6579.jclic-node.js +0 -719
  117. package/dist/6579.jclic-node.js.map +0 -1
  118. package/dist/6715.jclic-node.js +0 -148
  119. package/dist/6715.jclic-node.js.map +0 -1
  120. package/dist/6777.jclic-node.js +0 -171
  121. package/dist/6777.jclic-node.js.map +0 -1
  122. package/dist/6782.jclic-node.js +0 -1611
  123. package/dist/6782.jclic-node.js.map +0 -1
  124. package/dist/6847.jclic-node.js +0 -601
  125. package/dist/6847.jclic-node.js.map +0 -1
  126. package/dist/6856.jclic-node.js +0 -252
  127. package/dist/6856.jclic-node.js.map +0 -1
  128. package/dist/696.jclic-node.js +0 -1821
  129. package/dist/696.jclic-node.js.map +0 -1
  130. package/dist/698.jclic-node.js +0 -583
  131. package/dist/698.jclic-node.js.map +0 -1
  132. package/dist/704.jclic-node.js +0 -80
  133. package/dist/704.jclic-node.js.map +0 -1
  134. package/dist/7046.jclic-node.js +0 -735
  135. package/dist/7046.jclic-node.js.map +0 -1
  136. package/dist/7220.jclic-node.js +0 -156
  137. package/dist/7220.jclic-node.js.map +0 -1
  138. package/dist/7257.jclic-node.js +0 -931
  139. package/dist/7257.jclic-node.js.map +0 -1
  140. package/dist/743.jclic-node.js +0 -583
  141. package/dist/743.jclic-node.js.map +0 -1
  142. package/dist/757.jclic-node.js +0 -1072
  143. package/dist/757.jclic-node.js.map +0 -1
  144. package/dist/7781.jclic-node.js +0 -202
  145. package/dist/7781.jclic-node.js.map +0 -1
  146. package/dist/7912.jclic-node.js +0 -2103
  147. package/dist/7912.jclic-node.js.map +0 -1
  148. package/dist/827.jclic-node.js +0 -708
  149. package/dist/827.jclic-node.js.map +0 -1
  150. package/dist/8276.jclic-node.js +0 -409
  151. package/dist/8276.jclic-node.js.map +0 -1
  152. package/dist/8322.jclic-node.js +0 -498
  153. package/dist/8322.jclic-node.js.map +0 -1
  154. package/dist/8641.jclic-node.js +0 -360
  155. package/dist/8641.jclic-node.js.map +0 -1
  156. package/dist/8837.jclic-node.js +0 -651
  157. package/dist/8837.jclic-node.js.map +0 -1
  158. package/dist/8895.jclic-node.js +0 -151
  159. package/dist/8895.jclic-node.js.map +0 -1
  160. package/dist/9072.jclic-node.js +0 -1285
  161. package/dist/9072.jclic-node.js.map +0 -1
  162. package/dist/9078.jclic-node.js +0 -935
  163. package/dist/9078.jclic-node.js.map +0 -1
  164. package/dist/9103.jclic-node.js +0 -718
  165. package/dist/9103.jclic-node.js.map +0 -1
  166. package/dist/9359.jclic-node.js +0 -145
  167. package/dist/9359.jclic-node.js.map +0 -1
  168. package/dist/9409.jclic-node.js +0 -921
  169. package/dist/9409.jclic-node.js.map +0 -1
  170. package/dist/9513.jclic-node.js +0 -720
  171. package/dist/9513.jclic-node.js.map +0 -1
  172. package/dist/9704.jclic-node.js +0 -81
  173. package/dist/9704.jclic-node.js.map +0 -1
  174. package/dist/9950.jclic-node.js +0 -827
  175. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,735 +0,0 @@
1
- "use strict";
2
- exports.id = 7046;
3
- exports.ids = [7046,698,8276];
4
- exports.modules = {
5
-
6
- /***/ 7046:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony export ClassicJigSaw */
13
- /* harmony import */ var _Shaper_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8276);
14
- /* harmony import */ var _JigSaw_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(698);
15
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
16
- /**
17
- * File : shapers/ClassicJigSaw.js
18
- * Created : 25/05/2015
19
- * By : Francesc Busquets <francesc@gmail.com>
20
- *
21
- * JClic.js
22
- * An HTML5 player of JClic activities
23
- * https://projectestac.github.io/jclic.js
24
- *
25
- * @source https://github.com/projectestac/jclic.js
26
- *
27
- * @license EUPL-1.2
28
- * @licstart
29
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
30
- *
31
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
32
- * the European Commission- subsequent versions of the EUPL (the "Licence");
33
- * You may not use this work except in compliance with the Licence.
34
- *
35
- * You may obtain a copy of the Licence at:
36
- * https://joinup.ec.europa.eu/software/page/eupl
37
- *
38
- * Unless required by applicable law or agreed to in writing, software
39
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
40
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
41
- * Licence for the specific language governing permissions and limitations
42
- * under the Licence.
43
- * @licend
44
- * @module
45
- */
46
-
47
-
48
-
49
-
50
-
51
- /**
52
- * This is the classic {@link module:shapers/JigSaw.JigSaw JigSaw} {@link module:shapers/Shaper.Shaper Shaper} used in puzzle toys, where teeth and slots
53
- * are shaped by Bézier curves.
54
- * @extends module:shapers/JigSaw.JigSaw
55
- */
56
- class ClassicJigSaw extends _JigSaw_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
57
- /**
58
- * ClassicJigSaw constructor
59
- * @param {number} nx - Number of columns
60
- * @param {number} ny - Number of rows
61
- */
62
- constructor(nx, ny) {
63
- super(nx, ny);
64
- }
65
-
66
- /**
67
- * Overrides {@link module:shapers/JigSaw.JigSaw#hLine}
68
- * @override
69
- * @param {module:AWT.Path} sd - The Path to which the line will be added
70
- * @param {number} type - Type of tooth: 0 is flat (no tooth), 1 means tooth up, and 2 means tooth down
71
- * @param {number} x - X coordinate of the starting point
72
- * @param {number} y - Y coordinate of the starting point
73
- * @param {number} w - Width of the piece
74
- * @param {number} h - Height of the piece
75
- * @param {boolean} inv - The line must be drawn right to left
76
- */
77
- hLine(sd, type, x, y, w, h, inv) {
78
- const
79
- kx = inv ? -1 : 1,
80
- ky = type === 1 ? 1 : -1;
81
-
82
- if (type === 0)
83
- // Flat line
84
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('L', [x + w * kx, y]));
85
- else {
86
- const
87
- x0 = x + (w - w * this.baseWidthFactor) / 2 * kx,
88
- wb = w * (this.baseWidthFactor / 12) * kx;
89
-
90
- // Approximation to the tooth:
91
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('L', [x0, y]));
92
- // This is the tooth:
93
- const hb = h * this.toothHeightFactor * ky / 8;
94
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('B', [x0 + 4 * wb, y, x0 + 6 * wb, y - hb, x0 + 4 * wb, y - 3 * hb]));
95
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('B', [x0 + 2 * wb, y - 5 * hb, x0 + 10 * wb, y - 5 * hb, x0 + 8 * wb, y - 3 * hb]));
96
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('B', [x0 + 6 * wb, y - 1 * hb, x0 + 8 * wb, y, x0 + 12 * wb, y]));
97
- // Draw the remaining line
98
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('L', [x + w * kx, y]));
99
- }
100
- }
101
-
102
- /**
103
- * Overrides {@link module:shapers/JigSaw.JigSaw#vLine}
104
- * @override
105
- * @param {module:AWT.Path} sd - The Path to which the line will be added
106
- * @param {number} type - Type of tooth: 0 is flat (no tooth), 1 means tooth right, and 2 means tooth left
107
- * @param {number} x - X coordinate of the starting point
108
- * @param {number} y - Y coordinate of the starting point
109
- * @param {number} w - Width of the piece
110
- * @param {number} h - Height of the piece
111
- * @param {boolean} inv - The line must be drawn bottom to top
112
- */
113
- vLine(sd, type, x, y, w, h, inv) {
114
- const
115
- ky = inv ? -1 : 1,
116
- kx = type === 1 ? 1 : -1;
117
-
118
- if (type === 0)
119
- // Flat line
120
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('L', [x, y + h * ky]));
121
- else {
122
- const
123
- y0 = y + (h - h * this.baseWidthFactor) / 2 * ky,
124
- hb = h * this.baseWidthFactor / 12 * ky;
125
-
126
- // Approximation to the tooth:
127
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('L', [x, y0]));
128
- // This is the tooth:
129
- const wb = w * this.toothHeightFactor * kx / 8;
130
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('B', [x, y0 + 4 * hb, x - wb, y0 + 6 * hb, x - 3 * wb, y0 + 4 * hb]));
131
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('B', [x - 5 * wb, y0 + 2 * hb, x - 5 * wb, y0 + 10 * hb, x - 3 * wb, y0 + 8 * hb]));
132
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('B', [x - 1 * wb, y0 + 6 * hb, x, y0 + 8 * hb, x, y0 + 12 * hb]));
133
- // Draw the remaining line
134
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg('L', [x, y + h * ky]));
135
- }
136
- }
137
- }
138
-
139
- Object.assign(ClassicJigSaw.prototype, {
140
- /**
141
- * ClassicJigSaw needs a biggest base width
142
- * @name module:shapers/ClassicJigSaw.ClassicJigSaw#baseWidthFactor
143
- * @type {number} */
144
- baseWidthFactor: 3.0 / 4,
145
- /**
146
- * ClassicJigSaw needs a biggest base height factor
147
- * @name module:shapers/ClassicJigSaw.ClassicJigSaw#toothHeightFactor
148
- * @type {number} */
149
- toothHeightFactor: 3.0 / 5,
150
- });
151
-
152
- // Register this class in the list of known shapers
153
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"].registerClass('@ClassicJigSaw', ClassicJigSaw));
154
-
155
-
156
- /***/ }),
157
-
158
- /***/ 698:
159
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
160
-
161
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
162
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
163
- /* harmony export */ });
164
- /* unused harmony export JigSaw */
165
- /* harmony import */ var _Shaper_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8276);
166
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7912);
167
- /**
168
- * File : shapers/JigSaw.js
169
- * Created : 01/04/2015
170
- * By : Francesc Busquets <francesc@gmail.com>
171
- *
172
- * JClic.js
173
- * An HTML5 player of JClic activities
174
- * https://projectestac.github.io/jclic.js
175
- *
176
- * @source https://github.com/projectestac/jclic.js
177
- *
178
- * @license EUPL-1.2
179
- * @licstart
180
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
181
- *
182
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
183
- * the European Commission- subsequent versions of the EUPL (the "Licence");
184
- * You may not use this work except in compliance with the Licence.
185
- *
186
- * You may obtain a copy of the Licence at:
187
- * https://joinup.ec.europa.eu/software/page/eupl
188
- *
189
- * Unless required by applicable law or agreed to in writing, software
190
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
191
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
192
- * Licence for the specific language governing permissions and limitations
193
- * under the Licence.
194
- * @licend
195
- * @module
196
- */
197
-
198
-
199
-
200
-
201
- /**
202
- *
203
- * This {@link module:shapers/Shaper.Shaper Shaper} returns a set of rectangular shapes with teeth and slots that fit between them.
204
- * @extends module:shapers/Shaper.Shaper
205
- */
206
- class JigSaw extends _Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
207
- /**
208
- * JigSaw constructor
209
- * @param {number} nx - Number of columns
210
- * @param {number} ny - Number of rows
211
- */
212
- constructor(nx, ny) {
213
- super(nx, ny);
214
- }
215
-
216
- /**
217
- * Builds the jigsaw shapes based on the number of rows and columns
218
- * @override
219
- */
220
- buildShapes() {
221
- // Create two two-dimension arrays for storing the type of horizontal and vertical lines
222
- let hLineType = [], vLineType = [];
223
- for (let i = 0; i <= this.nRows; i++) {
224
- hLineType[i] = [];
225
- vLineType[i] = [];
226
- }
227
-
228
- for (let row = 0; row < this.nRows; row++) {
229
- for (let col = 0; col < this.nCols; col++) {
230
- hLineType[row][col] = row === 0 ? 0 : 1 + (this.randomLines ? Math.round(Math.random() * 9) : row + col) % 2;
231
- vLineType[row][col] = col === 0 ? 0 : 1 + (this.randomLines ? Math.round(Math.random() * 9) : col + row + 1) % 2;
232
- if (col === this.nCols - 1)
233
- vLineType[row][col + 1] = 0;
234
- if (row === this.nRows - 1)
235
- hLineType[row + 1][col] = 0;
236
- }
237
- }
238
-
239
- const w = 1 / this.nCols, h = 1 / this.nRows;
240
- for (let r = 0; r < this.nRows; r++) {
241
- for (let c = 0; c < this.nCols; c++) {
242
- const x = w * c;
243
- const y = h * r;
244
- const sd = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Path */ .wA([new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('M', [x, y])]);
245
- this.hLine(sd, hLineType[r][c], x + 0, y + 0, w, h, false);
246
- this.vLine(sd, vLineType[r][c + 1], x + w, y + 0, w, h, false);
247
- this.hLine(sd, hLineType[r + 1][c], x + w, y + h, w, h, true);
248
- this.vLine(sd, vLineType[r][c], x + 0, y + h, w, h, true);
249
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('X'));
250
- sd.calcEnclosingRect();
251
- // Save the Path in `shapeData`
252
- this.shapeData[r * this.nCols + c] = sd;
253
- }
254
- }
255
- this.initiated = true;
256
- }
257
-
258
- /**
259
- * Adds an horizontal line to the provided path
260
- * @param {module:AWT.Path} sd - The Path to which the line will be added
261
- * @param {number} type - Type of tooth: 0 is flat (no tooth), 1 means tooth up, and 2 means tooth down
262
- * @param {number} x - X coordinate of the starting point
263
- * @param {number} y - Y coordinate of the starting point
264
- * @param {number} w - Width of the piece
265
- * @param {number} h - Height of the piece
266
- * @param {boolean} inv - The line must be drawn right to left
267
- */
268
- hLine(sd, type, x, y, w, h, inv) {
269
- const
270
- kx = inv ? -1 : 1,
271
- ky = type === 1 ? 1 : -1;
272
-
273
- if (type === 0)
274
- // Flat line
275
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x + w * kx, y]));
276
- else {
277
- const x0 = x + (w - w * this.baseWidthFactor) / 2 * kx;
278
- const wb = w * this.baseWidthFactor * kx;
279
- // Approximation to the tooth:
280
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x0, y]));
281
- // The tooth:
282
- const hb = h * this.toothHeightFactor * ky;
283
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x0, y + hb]));
284
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x0 + wb, y + hb]));
285
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x0 + wb, y]));
286
- // Draw the remaining of the line
287
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x + w * kx, y]));
288
- }
289
- }
290
-
291
- /**
292
- *
293
- * Adds a vertical line to the provided path
294
- * @param {module:AWT.Path} sd - The Path to which the line will be added
295
- * @param {number} type - Type of tooth: 0 is flat (no tooth), 1 means tooth right, and 2 means tooth left
296
- * @param {number} x - X coordinate of the starting point
297
- * @param {number} y - Y coordinate of the starting point
298
- * @param {number} w - Width of the piece
299
- * @param {number} h - Height of the piece
300
- * @param {boolean} inv - The line must be drawn bottom to top
301
- */
302
- vLine(sd, type, x, y, w, h, inv) {
303
- const
304
- ky = inv ? -1 : 1,
305
- kx = type === 1 ? 1 : -1;
306
-
307
- if (type === 0) {
308
- // Flat line
309
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x, y + h * ky]));
310
- } else {
311
- const y0 = y + (h - h * this.baseWidthFactor) / 2 * ky;
312
- const hb = h * this.baseWidthFactor * ky;
313
- // Approximation to the tooth:
314
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x, y0]));
315
- // The tooth:
316
- const wb = w * this.toothHeightFactor * kx;
317
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x + wb, y0]));
318
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x + wb, y0 + hb]));
319
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x, y0 + hb]));
320
- // Draw the remaining line
321
- sd.addStroke(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .PathStroke */ .kg('L', [x, y + h * ky]));
322
- }
323
- }
324
- }
325
-
326
- // Register this class in the list of known shapers
327
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"].registerClass('@JigSaw', JigSaw));
328
-
329
-
330
- /***/ }),
331
-
332
- /***/ 8276:
333
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
334
-
335
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
336
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
337
- /* harmony export */ });
338
- /* unused harmony export Shaper */
339
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
340
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
341
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
342
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
343
- /**
344
- * File : shapers/Shaper.js
345
- * Created : 13/04/2015
346
- * By : Francesc Busquets <francesc@gmail.com>
347
- *
348
- * JClic.js
349
- * An HTML5 player of JClic activities
350
- * https://projectestac.github.io/jclic.js
351
- *
352
- * @source https://github.com/projectestac/jclic.js
353
- *
354
- * @license EUPL-1.2
355
- * @licstart
356
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
357
- *
358
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
359
- * the European Commission- subsequent versions of the EUPL (the "Licence");
360
- * You may not use this work except in compliance with the Licence.
361
- *
362
- * You may obtain a copy of the Licence at:
363
- * https://joinup.ec.europa.eu/software/page/eupl
364
- *
365
- * Unless required by applicable law or agreed to in writing, software
366
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
367
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
368
- * Licence for the specific language governing permissions and limitations
369
- * under the Licence.
370
- * @licend
371
- * @module
372
- */
373
-
374
-
375
-
376
-
377
-
378
- /**
379
- * The function of this class and its subclasses is to draw a set of "shapes" that will be used to
380
- * place {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects at a specific position, and to determine its dimension and
381
- * appearance.
382
- */
383
- class Shaper {
384
- /**
385
- * Shaper constructor
386
- * @param {number} nx - Number of columns (in grid-based shapers)
387
- * @param {number} ny - Number of rows (in grid-based shapers)
388
- */
389
- constructor(nx, ny) {
390
- this.reset(nx, ny);
391
- }
392
-
393
- /**
394
- * Registers a new type of shaper
395
- * @param {string} shaperName - The name used to identify this shaper
396
- * @param {function} shaperClass - The shaper class, usually extending Shaper
397
- * @returns {module:shapers/Shaper.Shaper} - The provided shaper class
398
- */
399
- static registerClass(shaperName, shaperClass) {
400
- Shaper.CLASSES[shaperName] = shaperClass;
401
- return shaperClass;
402
- }
403
-
404
- /**
405
- * Factory constructor that returns a Shaper of the requested class.
406
- * @param {string} className - The class name of the requested Shaper.
407
- * @param {number} nx - Number of columns (in grid-based shapers)
408
- * @param {number} ny - Number of rows (in grid-based shapers)
409
- * @returns {module:shapers/Shaper.Shaper}
410
- */
411
- static getShaper(className, nx, ny) {
412
- const cl = Shaper.CLASSES[(className || '').replace(/^edu\.xtec\.jclic\.shapers\./, '@')];
413
- if (!cl)
414
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('error', `Unknown shaper: ${className}`);
415
- return cl ? new cl(nx, ny) : null;
416
- }
417
-
418
- /**
419
- * Initializes this Shaper to default values
420
- * @param {number} nCols - Number of columns
421
- * @param {number} nRows - Number of rows
422
- */
423
- reset(nCols, nRows) {
424
- this.nCols = nCols;
425
- this.nRows = nRows;
426
- this.nCells = nRows * nCols;
427
- this.initiated = false;
428
- this.shapeData = [];
429
- for (let i = 0; i < this.nCells; i++)
430
- this.shapeData[i] = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Shape */ .yp();
431
- }
432
-
433
- /**
434
- * Loads this shaper settings from a specific JQuery XML element
435
- * @param {external:jQuery} $xml - The XML element with the shaper data
436
- */
437
- setProperties($xml) {
438
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, value) => {
439
- switch (name) {
440
- case 'class':
441
- this.className = value;
442
- break;
443
- case 'cols':
444
- this.nCols = Number(value);
445
- break;
446
- case 'rows':
447
- this.nRows = Number(value);
448
- break;
449
- case 'baseWidthFactor':
450
- case 'toothHeightFactor':
451
- case 'scaleX':
452
- case 'scaleY':
453
- this[name] = Number(value);
454
- break;
455
- case 'randomLines':
456
- case 'showEnclosure':
457
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(value, true);
458
- break;
459
- }
460
- });
461
-
462
- // Reads the 'enclosing'
463
- // (main shape area where the other shape elements are placed)
464
- $xml.children('enclosing:first').each((_n, child) => {
465
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(child).children('shape:first').each((_n, child2) => {
466
- let sh = Shaper.readShapeData(child2, this.scaleX, this.scaleY);
467
- this.enclosing = sh;
468
- this.showEnclosure = true;
469
- this.hasRemainder = true;
470
- });
471
- });
472
-
473
- // Read the shape elements
474
- $xml.children('shape').each((n, child) => {
475
- this.shapeData[n] = Shaper.readShapeData(child, this.scaleX, this.scaleY);
476
- });
477
-
478
- // Correction needed for '@Holes' shaper
479
- if (this.shapeData.length > 0 /* && this.shapeData.length !== this.nRows * this.nCols */) {
480
- //this.nRows = this.shapeData.length
481
- //this.nCols = 1
482
- //this.nCells = this.nCols * this.nRows
483
- this.nCells = this.shapeData.length;
484
- }
485
- return this;
486
- }
487
-
488
- /**
489
- * Reads an individual shape from an XML element.
490
- * Shapes are arrays of `stroke` objects.
491
- * Each `stroke` has an `action` (_move to_, _line to_, _quad to_...) and associated `data`.
492
- * @param {external:jQuery} $xml - The XML element with the shape data
493
- * @param {number} scaleX
494
- * @param {number} scaleY
495
- * @returns {module:AWT.Shape}
496
- */
497
- static readShapeData(xml, scaleX, scaleY) {
498
- const shd = [];
499
- let result = null;
500
- jquery__WEBPACK_IMPORTED_MODULE_0___default().each(xml.textContent.split('|'), (_n, txt) => {
501
- const sd = txt.split(':');
502
- // Possible strokes are: `rectangle`, `ellipse`, `M`, `L`, `Q`, `B`, `X`
503
- // Also possible, but not currently used in JClic: `roundRectangle` and `pie`
504
- let data = sd.length > 1 ? sd[1].split(',') : null;
505
- //
506
- // Data should be always divided by the scale (X or Y)
507
- if (data)
508
- data = data.map((d, n) => d / (n % 2 ? scaleY : scaleX));
509
-
510
- switch (sd[0]) {
511
- case 'rectangle':
512
- result = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(data[0], data[1], data[2], data[3]);
513
- break;
514
- case 'ellipse':
515
- result = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Ellipse */ .Pp(data[0], data[1], data[2], data[3]);
516
- break;
517
- default:
518
- // It's an `AWT.PathStroke`
519
- shd.push(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg(sd[0], data));
520
- break;
521
- }
522
- });
523
-
524
- return !result && shd.length > 0 ? new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Path */ .wA(shd) : result;
525
- }
526
-
527
- /**
528
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
529
- * parent references, constants and also attributes retaining the default value.
530
- * The resulting object is commonly usued to serialize elements in JSON format.
531
- * @returns {object} - The resulting object, with minimal attrributes
532
- */
533
- getAttributes() {
534
- const fields = [
535
- 'className', 'nCols', 'nRows',
536
- 'baseWidthFactor', 'toothHeightFactor',
537
- 'scaleX', 'scaleY',
538
- 'randomLines',
539
- ];
540
-
541
- if (this.customShapes) {
542
- ['showEnclosure', 'hasRemainder',
543
- 'enclosing', 'shapeData', // Array of AWT.Rectangle, AWT.Ellipse or (AWT.Path -> AWT.PathStroke)
544
- ].forEach(f => fields.push(f));
545
- }
546
-
547
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, fields);
548
- }
549
-
550
- /**
551
- * Builds a new shaper, based on the properties specified in a data object
552
- * @param {object} data - The data object to be parsed
553
- * @returns {module:shapers/Shaper.Shaper}
554
- */
555
- static factory(data) {
556
- const result = Shaper.getShaper(data.className, data.nCols, data.nRows);
557
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(result, data, [
558
- 'className', 'nCols', 'nRows',
559
- 'baseWidthFactor', 'toothHeightFactor',
560
- 'scaleX', 'scaleY',
561
- 'randomLines',
562
- 'showEnclosure', 'hasRemainder',
563
- { key: 'enclosing', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Shape */ .yp },
564
- { key: 'shapeData', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Shape */ .yp, group: 'array' },
565
- ]);
566
-
567
- result.nCells = result.shapeData.length || result.nCols * result.nRows;
568
-
569
- return result;
570
- }
571
-
572
- /**
573
- * Builds the individual shapes that will form this Shaper
574
- */
575
- buildShapes() {
576
- }
577
-
578
- /**
579
- * Gets a clone of the nth Shape object, scaled and located inside a Rectangle
580
- * @param {number} n
581
- * @param {module:AWT.Rectangle} rect
582
- * @returns {module:AWT.Shape}
583
- */
584
- getShape(n, rect) {
585
- if (!this.initiated)
586
- this.buildShapes();
587
- if (n >= this.nCells || this.shapeData[n] === null)
588
- return null;
589
- return this.shapeData[n].getShape(rect);
590
- }
591
-
592
- /**
593
- * Gets the nth Shape data object
594
- * @param {number} n
595
- * @returns {object}
596
- */
597
- getShapeData(n) {
598
- return n >= 0 && n < this.shapeData.length ? this.shapeData[n] : null;
599
- }
600
-
601
- /**
602
- * Gets the AWT.Rectangle that contains all shapes of this Shaper.
603
- * @returns {module:AWT.Rectangle}
604
- */
605
- getEnclosingShapeData() {
606
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(0, 0, 1, 1);
607
- }
608
-
609
- /**
610
- * When `hasRemainder` is true, this method gets the rectangle containing the full surface where
611
- * the Shaper develops.
612
- * @param {module:AWT.Rectangle} rect - The frame where to move and scale all the shapes
613
- * @returns {module:AWT.Rectangle}
614
- */
615
- getRemainderShape(rect) {
616
- if (!this.hasRemainder)
617
- return null;
618
-
619
- if (!this.initiated)
620
- this.buildShapes();
621
-
622
- const sh = this.getEnclosingShapeData();
623
- const r = sh ? sh.getShape(rect) : new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_();
624
- for (let i = 0; i < this.nCells; i++) {
625
- if (this.shapeData[i])
626
- r.add(this.shapeData[i].getShape(rect), false);
627
- }
628
- return r;
629
- }
630
- }
631
-
632
- Object.assign(Shaper.prototype, {
633
- /**
634
- * This shaper class name
635
- * @name module:shapers/Shaper.Shaper#className
636
- * @type {string} */
637
- className: 'Shaper',
638
- /**
639
- * Number of columns (useful in grid-based shapers)
640
- * @name module:shapers/Shaper.Shaper#nCols
641
- * @type {number} */
642
- nCols: 0,
643
- /**
644
- * Number of rows (useful in grid-based shapers)
645
- * @name module:shapers/Shaper.Shaper#nRows
646
- * @type {number} */
647
- nRows: 0,
648
- /**
649
- * Number of cells managed by this shaper
650
- * @name module:shapers/Shaper.Shaper#nCells
651
- * @type {number} */
652
- nCells: 0,
653
- /**
654
- * Contains the specific definition of each shape
655
- * @name module:shapers/Shaper.Shaper#shapeData
656
- * @type {object} */
657
- shapeData: null,
658
- /**
659
- * Flag used to check if the `Shaper` has been initialized against a real surface
660
- * @name module:shapers/Shaper.Shaper#initiated
661
- * @type {boolean} */
662
- initiated: false,
663
- //
664
- // Fields used only in JigSaw shapers
665
- /**
666
- * In {@link module:shapers/JigSaw.JigSaw JigSaw}, ratio between the base width of the tooth and the total length of the side.
667
- * @name module:shapers/Shaper.Shaper#baseWidthFactor
668
- * @type {number} */
669
- baseWidthFactor: 1.0 / 3,
670
- /**
671
- * In {@link module:shapers/JigSaw.JigSaw JigSaw}, ratio between the tooth height and the total length of the side.
672
- * @name module:shapers/Shaper.Shaper#toothHeightFactor
673
- * @type {number} */
674
- toothHeightFactor: 1.0 / 6,
675
- /**
676
- * In {@link module:shapers/JigSaw.JigSaw JigSaw}, whether the tooths take random directions or not
677
- * @name module:shapers/Shaper.Shaper#randomLines
678
- * @type {boolean} */
679
- randomLines: false,
680
- //
681
- // Fields used only in the `Holes` shaper
682
- /**
683
- * In {@link module:shapers/Holes.Holes Holes}, scale to be applied to horizontal positions and lengths to achieve the real
684
- * value of the shape placed on a real surface.
685
- * @name module:shapers/Shaper.Shaper#scaleX
686
- * @type {number} */
687
- scaleX: 1.0,
688
- /**
689
- * In {@link module:shapers/Holes.Holes Holes}, scale to be applied to vertical positions and lengths to achieve the real
690
- * value of the shape placed on a real surface.
691
- * @name module:shapers/Shaper.Shaper#scaleY
692
- * @type {number} */
693
- scaleY: 1.0,
694
- /**
695
- * In {@link module:shapers/Holes.Holes Holes}, the enclosing area where all shapes are placed.
696
- * @name module:shapers/Shaper.Shaper#enclosing
697
- * @type {module:AWT.Shape} */
698
- enclosing: null,
699
- /**
700
- * In {@link module:shapers/Holes.Holes Holes}, when `true`, the enclosing area will be drawn
701
- * @name module:shapers/Shaper.Shaper#showEnclosure
702
- * @type {boolean} */
703
- showEnclosure: false,
704
- /**
705
- * Flag indicating if this shaper organizes its cells in rows and columns
706
- * @name module:shapers/Shaper.Shaper#rectangularShapes
707
- * @type {boolean} */
708
- rectangularShapes: false,
709
- /**
710
- * Flag indicating if this Shaper deploys over a surface biggest than the rectangle enclosing
711
- * all its shapes
712
- * @name module:shapers/Shaper.Shaper#hasRemainder
713
- * @type {boolean} */
714
- hasRemainder: false,
715
- /**
716
- * Only the `Holes` shaper has this flag activated
717
- * @name module:shapers/Shaper.Shaper#customShapes
718
- * @type {boolean} */
719
- customShapes: false,
720
- });
721
-
722
- /**
723
- * List of known classes derived from Shaper. It should be filled by real shaper classes at
724
- * declaration time.
725
- * @type {object} */
726
- Shaper.CLASSES = {};
727
-
728
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Shaper);
729
-
730
-
731
- /***/ })
732
-
733
- };
734
- ;
735
- //# sourceMappingURL=7046.jclic-node.js.map