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,1072 +0,0 @@
1
- "use strict";
2
- exports.id = 6221;
3
- exports.ids = [6221,7781,6148];
4
- exports.modules = {
5
-
6
- /***/ 6221:
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 exports MemoryGame, MemoryGamePanel */
13
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _Activity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1567);
16
- /* harmony import */ var _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7781);
17
- /* harmony import */ var _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9205);
18
- /* harmony import */ var _boxes_BoxConnector_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6148);
19
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7912);
20
- /* harmony import */ var _shapers_Rectangular_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4921);
21
- /**
22
- * File : activities/memory/MemoryGame.js
23
- * Created : 04/06/2015
24
- * By : Francesc Busquets <francesc@gmail.com>
25
- *
26
- * JClic.js
27
- * An HTML5 player of JClic activities
28
- * https://projectestac.github.io/jclic.js
29
- *
30
- * @source https://github.com/projectestac/jclic.js
31
- *
32
- * @license EUPL-1.2
33
- * @licstart
34
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
35
- *
36
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
37
- * the European Commission- subsequent versions of the EUPL (the "Licence");
38
- * You may not use this work except in compliance with the Licence.
39
- *
40
- * You may obtain a copy of the Licence at:
41
- * https://joinup.ec.europa.eu/software/page/eupl
42
- *
43
- * Unless required by applicable law or agreed to in writing, software
44
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
45
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
46
- * Licence for the specific language governing permissions and limitations
47
- * under the Licence.
48
- * @licend
49
- * @module
50
- */
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
- /**
61
- * This class of {@link module:Activity.Activity Activity} shows a panel with duplicate {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects initially
62
- * hidden and shuffled. To complete the activity, all object pairs must be found. Only two objects
63
- * are revealed in every move, so the user must remember the content of each cell.
64
- *
65
- * The cell pairs can have identical content, defined in the `primary` {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} of
66
- * the activity, or two different contents. In this case, the `secondary` bag elements will have
67
- * content related to each `primary` element.
68
- * @extends module:Activity.Activity
69
- */
70
- class MemoryGame extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I {
71
- /**
72
- * MemoryGame constructor
73
- * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
74
- */
75
- constructor(project) {
76
- super(project);
77
- }
78
-
79
- /**
80
- * Retrieves the minimum number of actions needed to solve this activity.
81
- * @override
82
- * @returns {number}
83
- */
84
- getMinNumActions() {
85
- return this.abc.primary.getNumCells();
86
- }
87
-
88
- /**
89
- * Whether or not the activity uses random to shuffle internal components
90
- * @override
91
- * @returns {boolean}
92
- */
93
- hasRandom() {
94
- return true;
95
- }
96
-
97
- /**
98
- * When `true`, the activity must always be shuffled
99
- * @override
100
- * @returns {boolean}
101
- */
102
- shuffleAlways() {
103
- return true;
104
- }
105
- }
106
-
107
- /**
108
- * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/memory/MemoryGame.MemoryGame MemoryGame} activities are played.
109
- * @extends module:Activity.ActivityPanel
110
- */
111
- class MemoryGamePanel extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .ActivityPanel */ .S {
112
- /**
113
- * MemoryGamePanel constructor
114
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
115
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
116
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
117
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
118
- */
119
- constructor(act, ps, $div) {
120
- super(act, ps, $div);
121
- }
122
-
123
- /**
124
- * Miscellaneous cleaning operations
125
- * @override
126
- */
127
- clear() {
128
- if (this.bg) {
129
- this.bg.end();
130
- this.bg = null;
131
- }
132
- }
133
-
134
- /**
135
- * Prepares the visual components of the activity
136
- * @override
137
- */
138
- buildVisualComponents() {
139
- if (this.firstRun)
140
- super.buildVisualComponents();
141
- this.clear();
142
-
143
- const
144
- abcA = this.act.abc['primary'],
145
- abcB = this.act.abc['secondary'];
146
-
147
- if (abcA) {
148
- if (abcA.image)
149
- abcA.setImgContent(this.act.project.mediaBag, null, false);
150
- if (abcB && abcB.image)
151
- abcB.setImgContent(this.act.project.mediaBag, null, false);
152
- if (this.act.acp !== null) {
153
- const contentKit = [abcA];
154
- if (abcB)
155
- contentKit.push(abcB);
156
- this.act.acp.generateContent(abcA.nch, abcA.ncw, contentKit, false);
157
- }
158
-
159
- let ncw = abcA.ncw, nch = abcA.nch;
160
- if (this.act.boxGridPos === 'AB' || this.act.boxGridPos === 'BA')
161
- ncw *= 2;
162
- else
163
- nch *= 2;
164
-
165
- this.bg = new _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__["default"](null, this, abcA.style,
166
- this.act.margin, this.act.margin,
167
- abcA.w * ncw, abcA.h * nch, new _shapers_Rectangular_js__WEBPACK_IMPORTED_MODULE_6__["default"](ncw, nch));
168
-
169
- const nc = abcA.getNumCells();
170
- this.bg.setBorder(abcA.border);
171
- this.bg.setContent(abcA, null, 0, 0, nc);
172
- this.bg.setContent(abcB ? abcB : abcA, null, 0, nc, nc);
173
- for (let i = 0; i < 2; i++) {
174
- for (let j = 0; j < nc; j++) {
175
- const bx = this.bg.getActiveBox(i * nc + j);
176
- bx.idAss = j;
177
- bx.setInactive(true);
178
- }
179
- }
180
- this.bg.setVisible(true);
181
- }
182
- }
183
-
184
- /**
185
- * Basic initialization procedure
186
- * @override
187
- */
188
- initActivity() {
189
- super.initActivity();
190
-
191
- if (!this.firstRun)
192
- this.buildVisualComponents();
193
- else
194
- this.firstRun = false;
195
-
196
- if (this.bg) {
197
- this.shuffle([this.bg], true, true);
198
- this.invalidate().update();
199
- this.setAndPlayMsg('initial', 'start');
200
- this.playing = true;
201
- }
202
- }
203
-
204
- /**
205
- * Updates the graphic content of this panel.
206
- * This method will be called from {@link module:AWT.Container#update} when needed.
207
- * @override
208
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
209
- * it's the whole panel.
210
- */
211
- updateContent(dirtyRegion) {
212
- super.updateContent(dirtyRegion);
213
- if (this.bg && this.$canvas) {
214
- const
215
- canvas = this.$canvas.get(-1),
216
- ctx = canvas.getContext('2d');
217
- if (!dirtyRegion)
218
- dirtyRegion = new _AWT_js__WEBPACK_IMPORTED_MODULE_5__/* .Rectangle */ .M_(0, 0, canvas.width, canvas.height);
219
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
220
- this.bg.update(ctx, dirtyRegion);
221
- }
222
- return this;
223
- }
224
-
225
- /**
226
- * Sets the real dimension of this panel.
227
- * @override
228
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
229
- * @returns {module:AWT.Dimension}
230
- */
231
- setDimension(preferredMaxSize) {
232
- if (!this.bg || this.getBounds().equals(preferredMaxSize))
233
- return preferredMaxSize;
234
- return _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__["default"].layoutSingle(preferredMaxSize, this.bg, this.act.margin);
235
- }
236
-
237
- /**
238
- * Sets the size and position of this activity panel
239
- * @override
240
- * @param {module:AWT.Rectangle} rect
241
- */
242
- setBounds(rect) {
243
- if (this.$canvas)
244
- this.$canvas.remove();
245
-
246
- super.setBounds(rect);
247
- if (this.bg) {
248
- // Create the main canvas
249
- this.$canvas = jquery__WEBPACK_IMPORTED_MODULE_0___default()(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
250
- position: 'absolute',
251
- top: 0,
252
- left: 0
253
- });
254
- this.$div.append(this.$canvas);
255
-
256
- // Create a [BoxConnector](BoxConnector.html) and attach it to the canvas context
257
- this.bc = new _boxes_BoxConnector_js__WEBPACK_IMPORTED_MODULE_4__["default"](this, this.$canvas);
258
-
259
- // Repaint all
260
- this.invalidate().update();
261
- }
262
- }
263
-
264
- /**
265
- * Builds the accessible components needed for this ActivityPanel
266
- * This method is called when all main elements are placed and visible, when the activity is ready
267
- * to start or when resized.
268
- * @override
269
- */
270
- buildAccessibleComponents() {
271
- if (this.$canvas && this.accessibleCanvas && this.bg) {
272
- super.buildAccessibleComponents();
273
- this.bg.setCellAttr('accessibleAlwaysActive', true);
274
- this.bg.buildAccessibleElements(this.$canvas, this.$div, 'mousedown');
275
- }
276
- }
277
-
278
- /**
279
- * Main handler used to process mouse, touch, keyboard and edit events
280
- * @override
281
- * @param {external:Event} event - The HTML event to be processed
282
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
283
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
284
- */
285
- processEvent(event) {
286
- if (this.bc && this.playing) {
287
- //
288
- // The [AWT.Point](AWT.html#Point) where the mouse or touch event has been originated
289
- let p = null;
290
- //
291
- // Two [ActiveBox](ActiveBox.html) pointers used for the [BoxConnector](BoxConnector.html)
292
- // `origin` and `dest` points.
293
- let bx1, bx2,
294
- // Array to be filled with actions to be executed at the end of event processing
295
- delayedActions = [];
296
- //
297
- // _touchend_ event don't provide pageX nor pageY information
298
- if (event.type === 'touchend')
299
- p = this.bc.active ? this.bc.dest.clone() : new _AWT_js__WEBPACK_IMPORTED_MODULE_5__/* .Point */ .bR();
300
- else {
301
- // Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
302
- const
303
- x = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
304
- y = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY;
305
- p = new _AWT_js__WEBPACK_IMPORTED_MODULE_5__/* .Point */ .bR(x - this.$div.offset().left, y - this.$div.offset().top);
306
- }
307
-
308
- // Flag for tracking `mouseup` events
309
- let up = false;
310
- switch (event.type) {
311
- case 'touchcancel':
312
- // Canvel movement
313
- if (this.bc.active)
314
- this.bc.end();
315
- break;
316
-
317
- case 'mouseup':
318
- case 'touchend':
319
- // Don't consider drag moves below 3 pixels. Can be a "trembling click"
320
- if (this.bc.active && p.distanceTo(this.bc.origin) <= 3)
321
- break;
322
-
323
- up = true;
324
- /* falls through */
325
- case 'touchstart':
326
- case 'mousedown':
327
- if (!this.bc.active) {
328
- // New pairing starts
329
- //
330
- // Pairings can never start with a `mouseup` event
331
- if (up)
332
- break;
333
-
334
- this.ps.stopMedia(1);
335
- //
336
- // Find the ActiveBox behind the clicked point
337
- bx1 = this.bg ? this.bg.findActiveBox(p) : null;
338
- if (bx1 && bx1.idAss !== -1) {
339
- // Play cell media or event sound
340
- if (!bx1.playMedia(this.ps, delayedActions))
341
- this.playEvent('click');
342
- bx1.setInactive(false);
343
- // Start the [BoxConnector](BoxConnector.html)
344
- this.update();
345
- if (this.act.dragCells)
346
- this.bc.begin(p, bx1);
347
- else
348
- this.bc.begin(p);
349
- }
350
- } else {
351
- this.ps.stopMedia(1);
352
- // Pairing completed
353
- //
354
- // Find the active boxes behind `bc.origin` and `p`
355
- if (this.act.dragCells)
356
- bx1 = this.bc.bx;
357
- else
358
- bx1 = this.bg ? this.bg.findActiveBox(this.bc.origin) : null;
359
- this.bc.end();
360
- bx2 = this.bg ? this.bg.findActiveBox(p) : null;
361
- //
362
- // Check if the pairing was OK
363
- if (bx1 && bx1.idAss !== -1 && bx2 && bx2.idAss !== -1) {
364
- if (bx1 !== bx2) {
365
- let ok = false;
366
- if (bx1.idAss === bx2.idAss ||
367
- bx1.getContent().isEquivalent(bx2.getContent(), true)) {
368
- ok = true;
369
- bx1.idAss = -1;
370
- bx1.setInactive(false);
371
- bx2.idAss = -1;
372
- bx2.setInactive(false);
373
- } else {
374
- bx1.setInactive(true);
375
- if (this.act.dragCells)
376
- bx2.setInactive(true);
377
- else {
378
- bx2.setInactive(false);
379
- // Start the [BoxConnector](BoxConnector.html)
380
- this.update();
381
- if (this.act.dragCells)
382
- this.bc.begin(p, bx1);
383
- else
384
- this.bc.begin(p);
385
- }
386
- }
387
- let m = bx2.playMedia(this.ps, delayedActions);
388
- if (this.bg) {
389
- const cellsAtPlace = this.bg.countCellsWithIdAss(-1);
390
- this.ps.reportNewAction(this.act, 'MATCH', bx1.getDescription(), bx2.getDescription(), ok, cellsAtPlace / 2);
391
- if (ok && cellsAtPlace === this.bg.getNumCells())
392
- this.finishActivity(true);
393
- else if (!m)
394
- this.playEvent(ok ? 'actionOk' : 'actionError');
395
- }
396
- } else {
397
- this.playEvent('CLICK');
398
- bx1.setInactive(true);
399
- }
400
- } else if (bx1 !== null)
401
- bx1.setInactive(true);
402
-
403
- this.invalidate().update();
404
- }
405
- break;
406
-
407
- case 'mousemove':
408
- case 'touchmove':
409
- this.bc.moveTo(p);
410
- break;
411
- }
412
- delayedActions.forEach(action => action());
413
- event.preventDefault();
414
- }
415
- }
416
- }
417
-
418
- Object.assign(MemoryGamePanel.prototype, {
419
- /**
420
- * The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} containing the information to be displayed.
421
- * @name module:activities/memory/MemoryGame.MemoryGamePanel#bg
422
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
423
- bg: null,
424
- /**
425
- * The {@link module:boxes/BoxConnector.BoxConnector BoxConnector} used to reveal pairs of cells
426
- * @name module:activities/memory/MemoryGame.MemoryGamePanel#bc
427
- * @type {module:boxes/BoxConnector.BoxConnector} */
428
- bc: null,
429
- /**
430
- * List of mouse, touch and keyboard events intercepted by this panel
431
- * @override
432
- * @name module:activities/memory/MemoryGame.MemoryGamePanel#events
433
- * @type {string[]} */
434
- events: ['mousedown', 'mouseup', 'mousemove', 'touchstart', 'touchend', 'touchmove', 'touchcancel'],
435
- });
436
-
437
- /**
438
- * Panel class associated to this type of activity: {@link module:activities/memory/MemoryGame.MemoryGamePanel MemoryGamePanel}
439
- * @type {class} */
440
- MemoryGame.Panel = MemoryGamePanel;
441
-
442
- // Register activity class
443
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I.registerClass('@memory.MemoryGame', MemoryGame));
444
-
445
-
446
- /***/ }),
447
-
448
- /***/ 7781:
449
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
450
-
451
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
452
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
453
- /* harmony export */ });
454
- /* unused harmony export ActiveBoxGrid */
455
- /* harmony import */ var _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(427);
456
- /* harmony import */ var _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1725);
457
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
458
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1253);
459
- /**
460
- * File : boxes/ActiveBoxGrid.js
461
- * Created : 19/05/2015
462
- * By : Francesc Busquets <francesc@gmail.com>
463
- *
464
- * JClic.js
465
- * An HTML5 player of JClic activities
466
- * https://projectestac.github.io/jclic.js
467
- *
468
- * @source https://github.com/projectestac/jclic.js
469
- *
470
- * @license EUPL-1.2
471
- * @licstart
472
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
473
- *
474
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
475
- * the European Commission- subsequent versions of the EUPL (the "Licence");
476
- * You may not use this work except in compliance with the Licence.
477
- *
478
- * You may obtain a copy of the Licence at:
479
- * https://joinup.ec.europa.eu/software/page/eupl
480
- *
481
- * Unless required by applicable law or agreed to in writing, software
482
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
483
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
484
- * Licence for the specific language governing permissions and limitations
485
- * under the Licence.
486
- * @licend
487
- * @module
488
- */
489
-
490
-
491
-
492
-
493
-
494
-
495
- /**
496
- * This class extends {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with constructors that take an argument of type
497
- * {@link module:shapers/Shaper.Shaper Shaper} used to build all its {@link module:boxes/ActiveBox.ActiveBox ActiveBox}components. It also maintains information
498
- * about the number of "rows" and "columns", useful to compute valid (integer) values when
499
- * resizing or moving its components.
500
- * @extends module:boxes/ActiveBoxBag.ActiveBoxBag
501
- */
502
- class ActiveBoxGrid extends _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
503
- /**
504
- * ActiveBxGrid constructor
505
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
506
- * @param {module:AWT.Container} container - The container where this box grid is placed.
507
- * @param {module:boxes/BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
508
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
509
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
510
- * @param {number} setWidth - Total width of the box grid
511
- * @param {number} setHeight - Total height of the box grid
512
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
513
- */
514
- constructor(parent, container, boxBase, px, py, setWidth, setHeight, sh) {
515
- // ActiveBoxGrid derives from ActiveBoxBag
516
- super(parent, container, boxBase);
517
-
518
- this.nCols = sh.nCols;
519
- this.nRows = sh.nRows;
520
-
521
- // This will be the enclosing rectangle of this ActiveBox bag
522
- const r = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(
523
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(px, py),
524
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
525
- Math.round(setWidth / this.nCols) * this.nCols,
526
- Math.round(setHeight / this.nRows) * this.nRows));
527
-
528
- // Create all the [ActiveBox](ActiveBox.html) objects based on the
529
- // shapes provided by the [Shaper](Shaper.html)
530
- for (let i = 0; i < sh.nCells; i++) {
531
- const
532
- tmpSh = sh.getShape(i, r),
533
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, i, tmpSh.getBounds());
534
- if (!sh.rectangularShapes)
535
- bx.setShape(tmpSh);
536
- this.addActiveBox(bx);
537
- }
538
-
539
- // If the Shaper has `remainder` (extra space), set the background box of this
540
- // [BoxBag](BoxBag.html)
541
- if (sh.hasRemainder) {
542
- const
543
- tmpSh = sh.getRemainderShape(r),
544
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, 0, tmpSh.getBounds());
545
- bx.setShape(tmpSh);
546
- this.setBackgroundBox(bx);
547
- }
548
- }
549
-
550
- /**
551
- * This factory constructor creates a new empty grid with the number of cells indicated by the
552
- * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} `abc`, not filling the cells with any content.
553
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
554
- * @param {module:AWT.Container} container - The container where this box grid is placed.
555
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
556
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
557
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - Used only to get the number of cells and the shaper (when `sh` is `null`)
558
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
559
- * @param {module:boxes/BoxBase.BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
560
- * of this box grid are defined.
561
- * @returns {module:boxes/ActiveBoxGrid.ActiveBoxGrid}
562
- */
563
- static createEmptyGrid(parent, container, px, py, abc, sh, boxBase) {
564
- const result = abc ? new ActiveBoxGrid(parent, container,
565
- boxBase || abc.style,
566
- px, py,
567
- abc.getTotalWidth(), abc.getTotalHeight(),
568
- sh || abc.getShaper()) : null;
569
-
570
- if (result)
571
- result.setBorder(abc.border);
572
-
573
- return result;
574
- }
575
-
576
- /**
577
- * Gets the minimum size of this grid
578
- * @returns {module:AWT.Dimension}
579
- */
580
- getMinimumSize() {
581
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
582
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nCols,
583
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nRows);
584
- }
585
-
586
- /**
587
- * Gets a scaled size of this grid, rounded to the nearest integer values
588
- * @param {number} scale - The scale factor
589
- * @returns {module:AWT.Dimension}
590
- */
591
- getScaledSize(scale) {
592
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
593
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.width, this.nCols),
594
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.height, this.nRows));
595
- }
596
-
597
- /**
598
- * Returns the logical coordinates of the provided {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
599
- * The units of the result are not pixels, but ordinal numbers (relative positions) of columns
600
- * and rows in the grid.
601
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to process
602
- * @returns {module:AWT.Point}
603
- */
604
- getCoord(bx) {
605
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bx.idLoc % this.nCols, Math.floor(bx.idLoc / this.nCols));
606
- }
607
-
608
- /**
609
- * Calculates the logical distance between two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
610
- * Resulting units are not pixels, but ordinal numbers (relative positions) of columns and rows
611
- * in the grid.
612
- * @param {module:boxes/ActiveBox.ActiveBox} src - First box
613
- * @param {module:boxes/ActiveBox.ActiveBox} dest - Second box
614
- * @returns {module:AWT.Point}
615
- */
616
- getCoordDist(src, dest) {
617
- const
618
- ptSrc = this.getCoord(src),
619
- ptDest = this.getCoord(dest);
620
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(ptDest.x - ptSrc.x, ptDest.y - ptSrc.y);
621
- }
622
- }
623
-
624
- Object.assign(ActiveBoxGrid.prototype, {
625
- /**
626
- * Number of columns of this box grid
627
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nCols
628
- * @type {number} */
629
- nCols: 1,
630
- /**
631
- * Number of rows of this box grid
632
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nRows
633
- * @type {number} */
634
- nRows: 1,
635
- });
636
-
637
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveBoxGrid);
638
-
639
-
640
- /***/ }),
641
-
642
- /***/ 6148:
643
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
644
-
645
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
646
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
647
- /* harmony export */ });
648
- /* unused harmony export BoxConnector */
649
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7912);
650
- /**
651
- * File : boxes/BoxConnector.js
652
- * Created : 26/05/2015
653
- * By : Francesc Busquets <francesc@gmail.com>
654
- *
655
- * JClic.js
656
- * An HTML5 player of JClic activities
657
- * https://projectestac.github.io/jclic.js
658
- *
659
- * @source https://github.com/projectestac/jclic.js
660
- *
661
- * @license EUPL-1.2
662
- * @licstart
663
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
664
- *
665
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
666
- * the European Commission- subsequent versions of the EUPL (the "Licence");
667
- * You may not use this work except in compliance with the Licence.
668
- *
669
- * You may obtain a copy of the Licence at:
670
- * https://joinup.ec.europa.eu/software/page/eupl
671
- *
672
- * Unless required by applicable law or agreed to in writing, software
673
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
674
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
675
- * Licence for the specific language governing permissions and limitations
676
- * under the Licence.
677
- * @licend
678
- * @module
679
- */
680
-
681
-
682
-
683
- const DEFAULT_COMPOSITE_OP = 'source-over';
684
-
685
- /**
686
- * BoxConnector allows users to visually connect two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects of an
687
- * {@link module:Activity.ActivityPanel ActivityPanel}. There are two modes of operation:
688
- *
689
- * - Drawing a line between an origin point (usually the point where the user clicks on) and a
690
- * destination point.
691
- * - Dragging the ActiveBox from one location to another.
692
- *
693
- * The connecting lines can have arrowheads at its endings.
694
- */
695
- class BoxConnector {
696
- /**
697
- * BoxConnector constructor
698
- * @param {module:AWT.Container} parent - The Container to which this BoxConnector belongs
699
- * @param {external:jQuery} $canvas - The HTML `canvas` element where this BoxConnector will draw.
700
- */
701
- constructor(parent, $canvas) {
702
- this.parent = parent;
703
- this.ctx = $canvas.get(-1).getContext('2d', { willReadFrequently: true });
704
- this.dim = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg(this.ctx.canvas.width, this.ctx.canvas.height);
705
- this.origin = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
706
- this.dest = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
707
- this.relativePos = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
708
- }
709
-
710
- /**
711
- * Displaces the ending point of the connector
712
- * @param {number} dx - Displacement on the X axis
713
- * @param {number} dy - Displacement on the Y axis
714
- */
715
- moveBy(dx, dy) {
716
- this.moveTo((0,_AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR)(this.dest.x + dx, this.dest.y + dy));
717
- }
718
-
719
- /**
720
- * Moves the ending point of the connector to a new position
721
- * @param {module:AWT.Point} pt - The new position
722
- * @param {boolean} forcePaint - When `true`, forces the repaint of all the area also if there is
723
- * no movement at all.
724
- */
725
- moveTo(pt, forcePaint) {
726
- if (!this.active || !forcePaint && this.dest.equals(pt))
727
- return;
728
-
729
- // Restore the background
730
- if (this.bgRect) {
731
- if (this.bgImg) {
732
- this.ctx.putImageData(
733
- this.bgImg,
734
- 0, 0,
735
- this.bgRect.pos.x, this.bgRect.pos.y,
736
- this.bgRect.dim.width, this.bgRect.dim.height);
737
- } else if (this.parent)
738
- this.parent.updateContent();
739
- }
740
-
741
- this.dest.moveTo(pt);
742
-
743
- // Calculate the bounds of the invalidated area after the move:
744
- // Start with the origin point or box area
745
- const pt1 = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(this.origin.x - this.relativePos.x, this.origin.y - this.relativePos.y);
746
- this.bgRect = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Rectangle */ .M_(pt1, this.bx ? this.bx.dim : new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg());
747
- // Add the destination point or box area
748
- const pt2 = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(pt.x - this.relativePos.x, pt.y - this.relativePos.y);
749
- this.bgRect.add(new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Rectangle */ .M_(pt2, this.bx ? this.bx.dim : new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg()));
750
- // Add a generous border around the area
751
- this.bgRect.grow(10, 10);
752
-
753
- if (this.bx !== null) {
754
- // Move the ActiveBox
755
- this.bx.moveTo(new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(pt.x - this.relativePos.x, pt.y - this.relativePos.y));
756
- this.bx.setTemporaryHidden(false);
757
- this.bx.update(this.ctx, null);
758
- this.bx.setTemporaryHidden(true);
759
- } else {
760
- // Draw the connecting line
761
- this.drawLine();
762
- this.linePainted = true;
763
- }
764
- }
765
-
766
- /**
767
- * Starts the box connector operation
768
- * @param {module:AWT.Point} pt - Starting point
769
- * @param {module:boxes/ActiveBox.ActiveBox} [box] - Passed only when the BoxConnector runs in drag&drop mode
770
- */
771
- begin(pt, box) {
772
- if (this.active)
773
- this.end();
774
- this.origin.moveTo(pt);
775
- this.dest.moveTo(pt);
776
- this.linePainted = false;
777
- this.active = true;
778
-
779
- if (box) {
780
- // Remember what box will be moved, hide it from the panel and repaint all
781
- this.bx = box;
782
- this.relativePos.moveTo(pt.x - box.pos.x, pt.y - box.pos.y);
783
- this.bx.setFocused(true);
784
- this.bx.setTemporaryHidden(true);
785
- this.linePainted = false;
786
- this.parent.invalidate().update();
787
- }
788
-
789
- // Save the full image currently displayed on the panel (with the box hidden)
790
- try {
791
- this.bgImg = this.ctx.getImageData(0, 0, this.dim.width, this.dim.height);
792
- } catch (_ex) {
793
- // Avoid "canvas tainted by cross-origin data" errors
794
- // Setting bgImg to null is less efficient, but works
795
- this.bgImg = null;
796
- }
797
- this.bgRect = null;
798
-
799
- // Make a first movement to make the box appear
800
- if (box)
801
- this.moveTo(pt, true);
802
- }
803
-
804
- /**
805
- * Finalizes the operation of this box connector until a new call to `begin`
806
- */
807
- end() {
808
- if (!this.active)
809
- return;
810
-
811
- this.active = false;
812
- this.linePainted = false;
813
- this.bgRect = null;
814
- this.bgImg = null;
815
-
816
- if (this.bx) {
817
- // Restore the original position and attributes of the box
818
- this.bx.setFocused(false);
819
- this.bx.moveTo(this.origin.x - this.relativePos.x, this.origin.y - this.relativePos.y);
820
- this.bx.setTemporaryHidden(false);
821
- this.bx = null;
822
- this.relativePos.moveTo(0, 0);
823
- }
824
-
825
- // Repaint all
826
- this.ctx.clearRect(0, 0, this.dim.width, this.dim.height);
827
- this.parent.invalidate().update();
828
- }
829
-
830
- /**
831
- * Strokes a line between `origin` and `dest`, optionally ended with an arrowhead.
832
- */
833
- drawLine() {
834
- if (this.compositeOp !== DEFAULT_COMPOSITE_OP) {
835
- this.ctx.strokeStyle = this.xorColor;
836
- this.ctx.globalCompositeOperation = this.compositeOp;
837
- } else
838
- this.ctx.strokeStyle = this.lineColor;
839
-
840
- this.ctx.lineWidth = this.lineWidth;
841
-
842
- this.ctx.beginPath();
843
- this.ctx.moveTo(this.origin.x, this.origin.y);
844
- this.ctx.lineTo(this.dest.x, this.dest.y);
845
- this.ctx.stroke();
846
-
847
- if (this.arrow) {
848
- // Draws the arrow head
849
- const
850
- beta = Math.atan2(this.origin.x - this.dest.x, this.dest.x - this.origin.x),
851
- arp = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(this.dest.x - this.arrowLength * Math.cos(beta + this.arrowAngle),
852
- this.dest.y + this.arrowLength * Math.sin(beta + this.arrowAngle));
853
- this.ctx.beginPath();
854
- this.ctx.moveTo(this.dest.x, this.dest.y);
855
- this.ctx.lineTo(arp.x, arp.y);
856
- this.ctx.stroke();
857
-
858
- arp.moveTo(this.dest.x - this.arrowLength * Math.cos(beta - this.arrowAngle),
859
- this.dest.y + this.arrowLength * Math.sin(beta - this.arrowAngle));
860
- this.ctx.beginPath();
861
- this.ctx.moveTo(this.dest.x, this.dest.y);
862
- this.ctx.lineTo(arp.x, arp.y);
863
- this.ctx.stroke();
864
- }
865
- if (this.compositeOp !== DEFAULT_COMPOSITE_OP) {
866
- // reset default settings
867
- this.ctx.globalCompositeOperation = DEFAULT_COMPOSITE_OP;
868
- }
869
- }
870
- }
871
-
872
- Object.assign(BoxConnector.prototype, {
873
- /**
874
- * The background image, saved and redrawn on each movement
875
- * @name module:boxes/BoxConnector.BoxConnector#bgImg
876
- * @type {external:HTMLImageElement} */
877
- bgImg: null,
878
- /**
879
- * The rectangle of {@link module:Activity.ActivityPanel ActivityPanel} saved in `bgImg`
880
- * @name module:boxes/BoxConnector.BoxConnector#bgRect
881
- * @type {module:AWT.Rectangle} */
882
- bgRect: null,
883
- /**
884
- * Initial position of the connector
885
- * @name module:boxes/BoxConnector.BoxConnector#origin
886
- * @type {module:AWT.Point} */
887
- origin: null,
888
- /**
889
- * Current (while moving) and final position of the connector
890
- * @name module:boxes/BoxConnector.BoxConnector#dest
891
- * @type {module:AWT.Point} */
892
- dest: null,
893
- /**
894
- * When `true`, the connector must end on arrowhead
895
- * @name module:boxes/BoxConnector.BoxConnector#arrow
896
- * @type {boolean} */
897
- arrow: false,
898
- /**
899
- * `true` while the connector is active
900
- * @name module:boxes/BoxConnector.BoxConnector#active
901
- * @type {boolean} */
902
- active: false,
903
- /**
904
- * `true` while the line has already been painted (used for XOR expressions)
905
- * @name module:boxes/BoxConnector.BoxConnector#linePainted
906
- * @type {boolean} */
907
- linePainted: false,
908
- /**
909
- * The arrowhead length (in pixels)
910
- * @name module:boxes/BoxConnector.BoxConnector#arrowLength
911
- * @type {number} */
912
- arrowLength: 10,
913
- /**
914
- * The arrowhead angle
915
- * @name module:boxes/BoxConnector.BoxConnector#arrowAngle
916
- * @type {number} */
917
- arrowAngle: Math.PI / 6,
918
- /**
919
- * The main color used in XOR operations
920
- * @name module:boxes/BoxConnector.BoxConnector#lineColor
921
- * @type {string} */
922
- lineColor: 'black',
923
- /**
924
- * The complementary color used in XOR operations
925
- * @name module:boxes/BoxConnector.BoxConnector#xorColor
926
- * @type {string} */
927
- xorColor: 'white',
928
- /**
929
- * The global composite operator used when drawing in XOR mode. Default is "difference".
930
- * For a list of possible values see:
931
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation}
932
- * @name module:boxes/BoxConnector.BoxConnector#compositeOp
933
- * @type {string} */
934
- compositeOp: 'difference',
935
- /**
936
- * The default {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation composite operator}
937
- * ("source-over").
938
- * @name module:boxes/BoxConnector.BoxConnector#DEFAULT_COMPOSITE_OP
939
- * @static
940
- * @type {string} */
941
- DEFAULT_COMPOSITE_OP: DEFAULT_COMPOSITE_OP,
942
- /**
943
- * Relative position of point B regarding A
944
- * @name module:boxes/BoxConnector.BoxConnector#relativePos
945
- * @type {module:AWT.Point} */
946
- relativePos: null,
947
- /**
948
- * The ActiveBox to connect or move
949
- * @name module:boxes/BoxConnector.BoxConnector#bx
950
- * @type {module:boxes/ActiveBox.ActiveBox} */
951
- bx: null,
952
- /**
953
- * The Graphics context where the BoxConnector will paint
954
- * @name module:boxes/BoxConnector.BoxConnector#ctx
955
- * @type {external:CanvasRenderingContext2D} */
956
- ctx: null,
957
- /**
958
- * The dimension of the HTML canvas where to draw
959
- * @name module:boxes/BoxConnector.BoxConnector#dim
960
- * @type {module:AWT.Dimension} */
961
- dim: null,
962
- /**
963
- * The container to which this connector belongs
964
- * @name module:boxes/BoxConnector.BoxConnector#parent
965
- * @type {module:AWT.Container} */
966
- parent: null,
967
- /**
968
- * Width of the connector line
969
- * @name module:boxes/BoxConnector.BoxConnector#lineWidth
970
- * @type {number} */
971
- lineWidth: 1.5,
972
- });
973
-
974
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxConnector);
975
-
976
-
977
- /***/ }),
978
-
979
- /***/ 4921:
980
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
981
-
982
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
983
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
984
- /* harmony export */ });
985
- /* unused harmony export Rectangular */
986
- /* harmony import */ var _Shaper_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8276);
987
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7912);
988
- /**
989
- * File : shapers/Rectangular.js
990
- * Created : 19/05/2015
991
- * By : Francesc Busquets <francesc@gmail.com>
992
- *
993
- * JClic.js
994
- * An HTML5 player of JClic activities
995
- * https://projectestac.github.io/jclic.js
996
- *
997
- * @source https://github.com/projectestac/jclic.js
998
- *
999
- * @license EUPL-1.2
1000
- * @licstart
1001
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
1002
- *
1003
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
1004
- * the European Commission- subsequent versions of the EUPL (the "Licence");
1005
- * You may not use this work except in compliance with the Licence.
1006
- *
1007
- * You may obtain a copy of the Licence at:
1008
- * https://joinup.ec.europa.eu/software/page/eupl
1009
- *
1010
- * Unless required by applicable law or agreed to in writing, software
1011
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
1012
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1013
- * Licence for the specific language governing permissions and limitations
1014
- * under the Licence.
1015
- * @licend
1016
- * @module
1017
- */
1018
-
1019
-
1020
-
1021
-
1022
- /**
1023
- *
1024
- * This is the simplest {@link module:shapers/Shaper.Shaper Shaper}. It divides the graphic object in a set of rectangular
1025
- * shapes distributed in the specified number of rows and columns.
1026
- * @extends module:shapers/Shaper.Shaper
1027
- */
1028
- class Rectangular extends _Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
1029
- /**
1030
- * Rectangular constructor
1031
- * @param {number} nx - Number of columns
1032
- * @param {number} ny - Number of rows
1033
- */
1034
- constructor(nx, ny) {
1035
- super(nx, ny);
1036
- }
1037
-
1038
- /**
1039
- * Builds the rectangular shapes based on the number of rows and columns
1040
- * @override
1041
- */
1042
- buildShapes() {
1043
- const
1044
- w = 1 / this.nCols,
1045
- h = 1 / this.nRows;
1046
- for (let y = 0; y < this.nRows; y++) {
1047
- for (let x = 0; x < this.nCols; x++) {
1048
- this.shapeData[y * this.nCols + x] = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Point */ .bR(x * w, y * h), new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(w, h));
1049
- }
1050
- }
1051
- this.initiated = true;
1052
- }
1053
- }
1054
-
1055
- Object.assign(Rectangular.prototype, {
1056
- /**
1057
- * Overrides same flag in {@link module:/shapers/Shaper.Shaper#rectangularShapes Shaper#rectangularShapes}
1058
- * @name module:shapers/Rectangular.Rectangular#rectangularShapes
1059
- * @override
1060
- * @type {boolean} */
1061
- rectangularShapes: true,
1062
- });
1063
-
1064
- // Register this class in the list of known shapers
1065
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Shaper_js__WEBPACK_IMPORTED_MODULE_0__["default"].registerClass('@Rectangular', Rectangular));
1066
-
1067
-
1068
- /***/ })
1069
-
1070
- };
1071
- ;
1072
- //# sourceMappingURL=6221.jclic-node.js.map