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