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 +0,0 @@
1
- {"version":3,"file":"7912.jclic-node.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEuB;AACyG;AAC5F;;AAEpC;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;;AAEA;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B,aAAa,QAAQ;AACrB,wCAAwC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D,sDAAO,IAAI,2DAAY;AAClF,UAAU,yDAAY,GAAG,UAAU,oBAAoB;AACvD;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA,wCAAwC;AACxC,sBAAsB,oDAAQ;;AAE9B;AACA;AACA,uBAAuB,6CAAC;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,MAAM,yEAAoB;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,6DAA6D,sDAAO,IAAI,2DAAY;AACpF,MAAM,yDAAY,GAAG,UAAU,oBAAoB;AACnD;AACA;AACA;;AAEA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,+DAAU;AAC5B;AACA,oBAAoB,+DAAU;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,UAAU;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,cAAc,oCAAoC,EAAE,+CAA+C,EAAE,gCAAgC,EAAE,UAAU,KAAK,YAAY;AAClK;;AAEA;AACA,UAAU,gFAAgF;AAC1F,SAAS;AACT;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,sDAAsD,6CAA6C,IAAI,+CAA+C;AACtJ;AACA,eAAe;AACf;AACA;AACA;AACA,cAAc,6CAAC;AACf,eAAe,6CAAC,iBAAiB,sDAAsD;AACvF,aAAa,6CAAC;;AAEd,IAAI,6CAAC;AACL;AACA,mBAAmB,2BAA2B;AAC9C;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAiE,qBAAqB,iBAAiB;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA,sDAAsD,yCAAyC;AAC/F;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA,MAAM,iDAAiD;AACvD;AACA;AACA,aAAa,kDAAkD;AAC/D,cAAc,qCAAqC;AACnD,CAAC;;AAED;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA,cAAc,+DAAU;AACxB,cAAc,+DAAU;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA,gBAAgB;AAChB;AACA,aAAa,mCAAmC;AAChD,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,kBAAkB;AACtC;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,oCAAoC,kBAAkB,OAAO,QAAQ,IAAI,QAAQ;AACjF,oBAAoB,iBAAiB;AACrC,kBAAkB,OAAO,IAAI,8BAA8B;AAC3D,cAAc,OAAO;AACrB;;AAEA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA,WAAW,yEAAoB,aAAa,yEAAoB;AAChE;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED;AACA;AACA,SAAS;AACT;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,mCAAmC;AAChD,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,cAAc;AAC3B,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,cAAc;AAC3B,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,cAAc;AAC3B;AACA,aAAa,cAAc;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,kBAAkB;AAC/B,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED;AACA;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,kBAAkB;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA,yBAAyB,sCAAsC;AAC/D,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA,6BAA6B,wBAAwB;AACrD,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B,sCAAsC;AACnE,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,mCAAmC;AAChD,aAAa,sBAAsB;AACnC;AACA,eAAe,mCAAmC;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,mCAAmC;AAChD,eAAe,mCAAmC;AAClD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,mCAAmC;AAChD,eAAe,mCAAmC;AAClD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,mCAAmC;AAChD,aAAa,QAAQ;AACrB,eAAe,mCAAmC;AAClD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wDAAwD;AACxD,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA,gCAAgC,6BAA6B;AAC7D;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,uBAAuB;AAC/B;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,kBAAkB;AAC9B;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED;AACA,oBAAoB,wBAAwB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,kBAAkB;AAC/B,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,yBAAyB,sCAAsC;AAC/D,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,wBAAwB;AACvC,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB,aAAa,wBAAwB;AACpE,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe,uBAAuB,GAAG,uBAAuB,GAAG,wCAAwC,GAAG,yCAAyC;AACvJ;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;AACA,QAAQ,uBAAuB;AAC/B,QAAQ,2BAA2B;AACnC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA,UAAU,sCAAsC;AAChD;AACA,YAAY,sBAAsB;AAClC;AACA,CAAC;;AAED;AACA,0DAA0D;AAC1D;AACA;AACO;AACP;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,kBAAkB;AAC/B,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kCAAkC,iBAAiB;AACnD;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED;AACA,kBAAkB,wBAAwB;AAC1C,IAAI,6BAA6B;AACjC;AACA;AACO;AACP;AACA;AACA,aAAa,yBAAyB,wBAAwB,6BAA6B;AAC3F;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,6BAA6B;AAC1C,aAAa,uBAAuB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,sBAAsB,QAAQ;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,yBAAyB;AACrC;AACA;AACA,UAAU,sCAAsC;AAChD;AACA,YAAY,sBAAsB;AAClC;AACA;AACA;AACA;AACA,YAAY,oBAAoB;AAChC;AACA,CAAC;;AAED;AACA,yCAAyC,uBAAuB;AAChE;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,oBAAoB,uBAAuB,wBAAwB;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,mBAAmB;AAC3C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW;AACX,WAAW;AACX;AACA,aAAa,kBAAkB;AAC/B,aAAa,kBAAkB;AAC/B,aAAa,kBAAkB;AAC/B,aAAa,QAAQ;AACrB,sCAAsC,0CAA0C;AAChF,eAAe,oBAAoB;AACnC;AACA;AACA;AACA,kBAAkB,yDAAQ;AAC1B;AACA;AACA;AACA;AACA,oBAAoB,eAAe;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,kBAAkB;AAC/B,aAAa,kBAAkB;AAC/B,aAAa,kBAAkB;AAC/B,aAAa,kBAAkB;AAC/B,aAAa,QAAQ;AACrB,sCAAsC,0CAA0C;AAChF,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA,kBAAkB,yDAAQ;AAC1B;AACA;AACA,oBAAoB,eAAe;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,wBAAwB,IAAI,qCAAqC;AAC9E,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,mCAAmC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,cAAc,UAAU,GAAG,sCAAsC,6CAAE,MAAM,GAAG,6CAAE,MAAM,kBAAkB;AACtG;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,oBAAoB;AAChC;AACA,CAAC;;AAED;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,mBAAmB;AAChC,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,YAAY;AACxB;AACA,CAAC;;AAED;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,UAAU;AACvB,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,gBAAgB;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,CAAC;;AAED;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACO;AACP;AACA;AACA,aAAa,iCAAiC;AAC9C,aAAa,kBAAkB;AAC/B,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,sBAAsB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qBAAqB;AACrB,aAAa,kBAAkB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA,kCAAkC,2BAA2B,GAAG,mCAAmC,GAAG,+BAA+B;AACrI,IAAI,6BAA6B,GAAG,qCAAqC,GAAG,6BAA6B,GAAG,qCAAqC;AACjJ,IAAI,iCAAiC,GAAG,2BAA2B,GAAG,uCAAuC,GAAG,+BAA+B;AAC/I,IAAI,8BAA8B,KAAK,qCAAqC;AAC5E;AACA,iEAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,EAAC","sources":["webpack://jclic/./src/AWT.js"],"sourcesContent":["/**\n * File : AWT.js\n * Created : 12/04/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\n/* global console, window */\n\nimport $ from 'jquery';\nimport { settings, findParentsWithChild, getBoolean, getAttr, setAttr, checkColor, colorHasTransparency, fx } from './Utils.js';\nimport WebFont from 'webfontloader';\n\n/**\n * Font contains properties and provides methods to manage fonts\n */\nexport class Font {\n /**\n * Font constructor\n * @param {string} [family='Arial']\n * @param {number} [size=17]\n * @param {number} [bold=0]\n * @param {number} [italic=0]\n * @param {string} [variant='']\n */\n constructor(family, size, bold, italic, variant) {\n if (family)\n this.family = family;\n if (typeof size === 'number')\n this.size = size;\n if (bold)\n this.bold = bold;\n if (italic)\n this.italic = italic;\n if (variant)\n this.variant = variant;\n this._metrics = { ascent: -1, descent: -1, height: -1 };\n }\n\n /**\n * Finds the XML elements with typeface specifications, checks its value against the font\n * substitution list, replacing the `family` attribute and loading the alternative font when needed.\n * @param {external:jQuery} $tree - The xml element to be processed\n * @param {object} [options] - Optional param that can contain a `fontSubstitutions` attribute with\n * a substition table to be added to {@link module:AWT.Font.SUBSTITUTIONS SUBSTITUTIONS}\n */\n static checkTree($tree, options) {\n let substitutions = Font.SUBSTITUTIONS;\n // Load own fonts and remove it from the substitution table\n if (options && options.ownFonts) {\n options.ownFonts.forEach(name => {\n // Check WebFont as a workaround to avoid problems with a different version of `webfontloader` in agora.xtec.cat\n if (Font.ALREADY_LOADED_FONTS.indexOf(name) < 0 && WebFont && WebFont.load) {\n WebFont.load({ custom: { families: [name] } });\n Font.ALREADY_LOADED_FONTS.push(name);\n delete substitutions[name.trim().toLowerCase()];\n }\n });\n }\n\n // Add custom font substitutions\n if (options && options.fontSubstitutions)\n //substitutions = Object.assign({}, substitutions, options.fontSubstitutions)\n substitutions = $.extend(Object.create(substitutions), options.fontSubstitutions);\n\n if ($tree.jquery)\n $tree.find('style[family],font[family]').each((_n, style) => {\n const $style = $(style),\n name = $style.attr('family').trim().toLowerCase();\n if (name in substitutions) {\n const newName = substitutions[name];\n if (newName !== '') {\n Font.loadGoogleFont(newName);\n $style.attr('family', newName);\n }\n }\n });\n else {\n findParentsWithChild($tree, 'family').forEach(parent => {\n if (typeof parent.family === 'string') {\n const name = parent.family;\n if (Font.GOOGLEFONTS.includes(name))\n Font.loadGoogleFont(name);\n else {\n const newName = substitutions[name.trim().toLowerCase()];\n if (newName) {\n Font.loadGoogleFont(newName);\n parent.family = newName;\n }\n }\n }\n });\n }\n }\n\n /**\n * Try to load a specific font from [http://www.google.com/fonts]\n * @param {string} name - The font family name\n */\n // Check WebFont as a workaround to avoid problems with a different version of `webfontloader` in agora.xtec.cat\n static loadGoogleFont(name) {\n if (name && !Font.ALREADY_LOADED_FONTS.includes(name) && WebFont && WebFont.load) {\n WebFont.load({ google: { families: [name] } });\n Font.ALREADY_LOADED_FONTS.push(name);\n }\n }\n\n /**\n * Try to load a set of Google fonts\n * @param {string[]} fonts - An array of font names\n */\n static loadGoogleFonts(fonts) {\n if (fonts && fonts.forEach)\n fonts.forEach(name => Font.loadGoogleFont(name));\n }\n\n /**\n * Reads the properties of this Font from an XML element\n * @param {external:jQuery} $xml - The xml element to be parsed\n * @returns {module:AWT.Font}\n */\n setProperties($xml) {\n if ($xml.attr('family'))\n this.family = $xml.attr('family');\n if ($xml.attr('size'))\n this.size = Number($xml.attr('size'));\n if ($xml.attr('bold'))\n this.bold = getBoolean($xml.attr('bold'));\n if ($xml.attr('italic'))\n this.italic = getBoolean($xml.attr('italic'));\n if ($xml.attr('variant'))\n this.variant = $xml.attr('variant');\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, ['family|Arial', 'size|17', 'bold|0', 'italic|0', 'variant']);\n }\n\n /**\n * Reads the properties of this Font from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Font}\n */\n setAttributes(data) {\n return setAttr(this, data, ['family', 'size', 'bold', 'italic', 'variant']);\n }\n\n /**\n * Allows to change the `size` member, recalculating the vertical metrics.\n * @param {number} size - The new size to set\n * @returns {module:AWT.Font}\n */\n setSize(size) {\n const currentSize = this.size;\n this.size = size;\n if (currentSize !== size)\n this._metrics.height = -1;\n return this;\n }\n\n /**\n * Increases or decreases the current font size by the specified amount\n * @param {number} amount - The amount to increase or decrease current size\n * @returns {module:AWT.Font}\n */\n zoom(amount) {\n return this.setSize(this.size + amount);\n }\n\n /**\n * Calculates the font metrics\n * @returns {Object} - The font metrics\n */\n getMetrics() {\n if (this._metrics.height < 0) {\n // Look for an equivalent font already calculated\n const font = Font.ALREADY_CALCULATED_FONTS.find(font => font.equals(this));\n if (font)\n Object.assign(this._metrics, font._metrics);\n\n if (this._metrics.height < 0) {\n this._calcHeight();\n if (this._metrics.height > 0)\n Font.ALREADY_CALCULATED_FONTS.push(this);\n }\n }\n return this._metrics;\n }\n\n /**\n * Calculates the font metrics and returns its height\n * @returns {number} - The font height\n */\n getHeight() {\n return this.getMetrics().height;\n }\n\n /**\n * Translates the Font properties into CSS statements\n * @param {object} css - The object where to add CSS properties. When null or undefined, a new\n * object will be created and returned.\n * @returns {object} - A set of CSS property-values pairs, ready to be used by JQuery\n * [.css(properties)](http://api.jquery.com/css/#css-properties).\n */\n toCss(css) {\n if (!css)\n css = {};\n css['font-family'] = this.family;\n css['font-size'] = `${this.size}px`;\n if (this.hasOwnProperty('bold'))\n css['font-weight'] = this.bold ? 'bold' : 'normal';\n if (this.hasOwnProperty('italic'))\n css['font-style'] = this.italic ? 'italic' : 'normal';\n if (this.hasOwnProperty('variant'))\n css['font-variant'] = this.variant;\n return css;\n }\n\n /**\n * Gets the codification of this font in a single string, suitable to be used in a `font`\n * CSS attribute.\n * @returns {string} - A string with all the CSS font properties concatenated\n */\n cssFont() {\n return `${this.italic ? 'italic ' : 'normal'} ${this.variant === '' ? 'normal' : this.variant} ${this.bold ? 'bold ' : 'normal'} ${this.size}px ${this.family}`;\n }\n\n /**\n * The {@link https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics TextMetrics} object used\n * by {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D CanvasRenderingContext2D}\n * does not provide a `heigth` value for rendered text.\n * This {@link http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas stackoverflow question}\n * has an excellent response by Daniel Earwicker explaining how to measure the\n * vertical dimension of rendered text using a `span` element.\n * The code has been slighty adapted to deal with Font objects.\n *\n * _Warning_: Do not call this method direcly. Use {@link module:AWT.Font#getHeight getHeight()} or {@link module:AWT.Font#getMetrics getMetrics()} instead\n *\n * @returns {module:AWT.Font}\n */\n _calcHeight() {\n const\n $text = $('<span/>').html('Hg').css(this.toCss()),\n $block = $('<div/>').css({ display: 'inline-block', width: '1px', height: '0px' }),\n $div = $('<div/>').append($text, $block);\n\n $('body').append($div);\n try {\n $block.css({ verticalAlign: 'baseline' });\n this._metrics.ascent = $block.offset().top - $text.offset().top;\n $block.css({ verticalAlign: 'bottom' });\n this._metrics.height = $block.offset().top - $text.offset().top;\n this._metrics.descent = this._metrics.height - this._metrics.ascent;\n } finally {\n $div.remove();\n }\n return this;\n }\n\n /**\n * Checks if two Font objects are equivalent\n * @param {module:AWT.Font} font - The Font object to compare against this one\n * @returns {boolean} - `true` if both objects are equivalent, `false` otherwise\n */\n equals(font) {\n return this.family === font.family &&\n this.size === font.size &&\n this.bold === font.bold &&\n this.italic === font.italic &&\n this.variant === font.variant;\n }\n}\n\n\n/**\n * Array of font objects with already calculated heights */\nFont.ALREADY_CALCULATED_FONTS = [];\n\n/**\n * Array of font names already loaded from Google Fonts, or generic names provided by browsers by default\n * See: https://developer.mozilla.org/en-US/docs/Web/CSS/font-family */\nFont.ALREADY_LOADED_FONTS = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy'];\n\n/**\n * Google Fonts equivalent for special fonts used in some JClic projects.\n * More substitutions can be added to the list for specific projects indicating a\n * `fontSubstitutions` object in the `data-options` attribute of the HTML `div` element\n * containing the player.\n * For example:\n * `<div class =\"JClic\" data-project=\"demo.jclic\" data-options='{\"fontSubstitutions\":{\"arial\":\"Arimo\"}}'/>`\n */\nFont.SUBSTITUTIONS = {\n // Lowercase versions of JDK Logical Fonts (see: https://docs.oracle.com/javase/tutorial/2d/text/fonts.html)\n 'dialog': 'sans-serif',\n 'dialoginput': 'sans-serif',\n 'monospaced': 'monospace',\n //'serif': 'serif',\n 'sansserif': 'sans-serif',\n // Other fonts commonly used in JClic activities, mapped to similar Google Fonts\n 'abc': 'Kalam',\n 'a.c.m.e. secret agent': 'Permanent Marker',\n 'comic sans ms': 'Patrick Hand',\n 'impact': 'Oswald',\n 'massallera': 'Vibur',\n 'memima': 'Vibur',\n 'memima_n1': 'Vibur',\n 'memima_n2': 'Vibur',\n 'memimas-regularalternate': 'Vibur',\n 'palmemim': 'Vibur',\n 'zurichcalligraphic': 'Felipa'\n};\n/**\n * Google Fonts currently used in substitutions\n */\nFont.GOOGLEFONTS = [\n 'Kalam', 'Permanent Marker', 'Patrick Hand', 'Oswald', 'Vibur', 'Felipa',\n];\n\nObject.assign(Font.prototype, {\n /**\n * The `font-family` property\n * @name module:AWT.Font#family\n * @type {string} */\n family: 'Arial',\n /**\n * The font size\n * __Warning__: Do not change `size` directly. Use {@link module:AWT.Font#setSize setSize()} instead.\n * @name module:AWT.Font#size\n * @type {number} */\n size: 17,\n /**\n * The font _bold_ value\n * @name module:AWT.Font#bold\n * @type {number} */\n bold: 0,\n /**\n * The font _italic_ value\n * @name module:AWT.Font#italic\n * @type {number} */\n italic: 0,\n /**\n * The font _variant_ value\n * @name module:AWT.Font#variant\n * @type {string}*/\n variant: '',\n /**\n * The font *_metrics* property contains the values for `ascent`, `descent` and `height`\n * attributes. Vertical font metrics are calculated in\n * {@link module:AWT.Font#_calcHeight|_calcHeight()} as needed.\n * @name module:AWT.Font#_metrics\n * @private\n * @type {{ascent: number, descent: number, height: number}} */\n _metrics: { ascent: -1, descent: -1, height: -1 },\n});\n\n/**\n * Contains parameters and methods to draw complex color gradients\n */\nexport class Gradient {\n /**\n * Gradient constructor\n * @param {string} c1 - The initial color, in any CSS-valid form.\n * @param {string} c2 - The final color, in any CSS-valid form.\n * @param {number} [angle=0] - The inclination of the gradient relative to the horizontal line.\n * @param {number} [cycles=1] - The number of times the gradient will be repeated.\n */\n constructor(c1, c2, angle, cycles) {\n if (c1)\n this.c1 = c1;\n if (c2)\n this.c2 = c2;\n if (typeof angle === 'number')\n this.angle = angle % 360;\n if (typeof cycles === 'number')\n this.cycles = cycles;\n }\n\n /**\n * Reads the properties of this Gradient from an XML element\n * @param {external:jQuery} $xml - The xml element to be parsed\n * @returns {module:AWT.Gradient}\n */\n setProperties($xml) {\n this.c1 = checkColor($xml.attr('source'), 'black');\n this.c2 = checkColor($xml.attr('dest'), 'white');\n this.angle = Number($xml.attr('angle') || 0) % 360;\n this.cycles = Number($xml.attr('cycles') || 1);\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, [\n 'c1', 'c2', 'angle|0', 'cycles|1'\n ]);\n }\n\n /**\n * Reads the properties of this Gradient from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Gradient}\n */\n setAttributes(data) {\n return setAttr(this, data, ['c1', 'c2', 'angle', 'cycles']);\n }\n\n /**\n * Creates a {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient|CanvasGradient}\n * based on the provided context and rectangle.\n * @param {external:CanvasRenderingContext2D} ctx - The 2D rendering context\n * @param {module:AWT.Rectangle} rect - The rectangle where this gradient will be applied to\n * @returns {module:AWT.Gradient}\n */\n getGradient(ctx, rect) {\n const\n p2 = rect.getOppositeVertex(),\n gradient = ctx.createLinearGradient(rect.pos.x, rect.pos.y, p2.x, p2.y),\n step = 1 / Math.max(this.cycles, 1);\n for (let i = 0; i <= this.cycles; i++)\n gradient.addColorStop(i * step, i % 2 ? this.c1 : this.c2);\n return gradient;\n }\n\n /**\n * Gets the CSS 'linear-gradient' expression of this Gradient\n * @returns {string} - A string ready to be used as a value for the `linear-gradient` CSS attribute\n */\n getCss() {\n let result = `linear-gradient(${(this.angle + 90)}deg, ${this.c1}, ${this.c2}`;\n for (let i = 1; i < this.cycles; i++)\n result = `${result}, ${i % 2 > 0 ? this.c1 : this.c2}`;\n return `${result})`;\n }\n\n /**\n * Checks if any of the gradient colors has transparency\n * @returns {boolean} - `true` if this gradient uses colors with transparency, `false` otherwise.\n */\n hasTransparency() {\n return colorHasTransparency(this.c1) || colorHasTransparency(this.c2);\n }\n}\n\nObject.assign(Gradient.prototype, {\n /**\n * Initial color\n * @name module:AWT.Gradient#c1\n * @type {string} */\n c1: 'white',\n /**\n * Final color\n * @name module:AWT.Gradient#c2\n * @type {string} */\n c2: 'black',\n /**\n * Tilt angle\n * @name module:AWT.Gradient#angle\n * @type {number} */\n angle: 0,\n /**\n * Number of repetitions of the gradient\n * @name module:AWT.Gradient#cycles\n * @type {number} */\n cycles: 1,\n});\n\n/**\n * Contains properties used to draw lines in HTML `canvas` elements.\n * @see {@link http://bucephalus.org/text/CanvasHandbook/CanvasHandbook.html#line-caps-and-joins}\n */\nexport class Stroke {\n /**\n * Stroke constructor\n * @param {number} [lineWidth=1] - The line width of the stroke\n * @param {string} [lineCap='butt'] - The line ending type. Possible values are: `butt`, `round`\n * and `square`.\n * @param {string} [lineJoin='miter'] - The type of drawing used when two lines join. Possible\n * values are: `round`, `bevel` and `miter`.\n * @param {number} [miterLimit=10] - The ratio between the miter length and half `lineWidth`.\n */\n constructor(lineWidth, lineCap, lineJoin, miterLimit) {\n if (typeof lineWidth === 'number')\n this.lineWidth = lineWidth;\n if (lineCap)\n this.lineCap = lineCap;\n if (lineJoin)\n this.lineJoin = lineJoin;\n if (typeof miterLimit === 'number')\n this.miterLimit = miterLimit;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, [\n 'lineWidth|1', 'lineCap|butt', 'lineJoin|miter', 'miterLimit|10',\n ]);\n }\n\n /**\n * Reads the properties of this Stroke from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Stroke}\n */\n setAttributes(data) {\n return setAttr(this, data, ['lineWidth', 'lineCap', 'lineJoin', 'miterLimit']);\n }\n\n /**\n * Sets the properties of this stroke to a CanvasRenderingContext2D\n * @param {external:CanvasRenderingContext2D} ctx - The canvas 2D rendering context\n * @returns {external:CanvasRenderingContext2D}\n */\n setStroke(ctx) {\n ctx.lineWidth = this.lineWidth;\n ctx.lineCap = this.lineCap;\n ctx.lineJoin = this.lineJoin;\n ctx.miterLimit = this.miterLimit;\n return ctx;\n }\n}\n\nObject.assign(Stroke.prototype, {\n /**\n * The line width\n * @name module:AWT.Stroke#lineWidth\n * @type {number} */\n lineWidth: 1.0,\n /**\n * The line ending type (`butt`, `round` or `square`)\n * @name module:AWT.Stroke#lineCap\n * @type {string} */\n lineCap: 'butt',\n /**\n * The drawing used when two lines join (`round`, `bevel` or `miter`)\n * @name module:AWT.Stroke#lineJoin\n * @type {string} */\n lineJoin: 'miter',\n /**\n * Ratio between the miter length and half `lineWidth`\n * @name module:AWT.Stroke#miterLimit\n * @type {number} */\n miterLimit: 10.0,\n});\n\n/**\n * Contains the `x` andy `y` coordinates of a point, and provides some useful methods.\n */\nexport class Point {\n /**\n * Point constructor\n * @param {number|Point} x - When `x` is an `Point` object, a clone of it will be created.\n * @param {number} [y] - Not used when `x` is an `Point`\n */\n constructor(x, y) {\n if (x instanceof Point) {\n // Special case: constructor passing another point as unique parameter\n this.x = x.x;\n this.y = x.y;\n } else {\n this.x = x || 0;\n this.y = y || 0;\n }\n }\n\n /**\n * Reads the properties of this Point from an XML element\n * @param {external:jQuery} $xml - The xml element to be parsed\n * @returns {module:AWT.Point}\n */\n setProperties($xml) {\n this.x = Number($xml.attr('x'));\n this.y = Number($xml.attr('y'));\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, ['x', 'y']);\n }\n\n /**\n * Reads the properties of this Point from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Point}\n */\n setAttributes(data) {\n return setAttr(this, data, ['x', 'y']);\n }\n\n /**\n * Moves this Point to a new position, by a specified displacement\n * @param {Point|Dimension} delta - The amount to move\n * @returns {module:AWT.Point}\n */\n moveBy(delta) {\n this.x += delta.x || delta.width || 0;\n this.y += delta.y || delta.height || 0;\n return this;\n }\n\n /**\n * Moves this Point to a new position\n * @param {number|Point} newPos - The new position, or a x coordinate\n * @param {number} [y] - `null` or `undefined` when `newPos` is a Point\n * @returns {module:AWT.Point}\n */\n moveTo(newPos, y) {\n if (typeof newPos === 'number') {\n this.x = newPos;\n this.y = y;\n } else {\n this.x = newPos.x;\n this.y = newPos.y;\n }\n return this;\n }\n\n /**\n * Multiplies the `x` and `y` coordinates by a specified `delta`\n * @param {Point|Dimension} delta - The amount to multiply by.\n * @returns {module:AWT.Point}\n */\n multBy(delta) {\n this.x *= delta.x || delta.width || 0;\n this.y *= delta.y || delta.height || 0;\n return this;\n }\n\n /**\n * Checks if two points are at the same place\n * @param {module:AWT.Point} p - The Point to check against to\n * @returns {boolean}\n */\n equals(p) {\n return this.x === p.x && this.y === p.y;\n }\n\n /**\n * Calculates the distance between two points\n * @param {module:AWT.Point} point - The Point to calculate the distance against to\n * @returns {number} - The distance between the two points.\n */\n distanceTo(point) {\n return Math.sqrt(Math.pow(this.x - point.x, 2), Math.pow(this.y - point.y, 2));\n }\n\n /**\n * Clones this point\n * @returns {module:AWT.Point}\n */\n clone() {\n return new Point(this);\n }\n}\n\nObject.assign(Point.prototype, {\n /**\n * @name module:AWT.Point#x\n * @type {number} */\n x: 0,\n /**\n * @name module:AWT.Point#y\n * @type {number} */\n y: 0,\n});\n\n/**\n * This class encapsulates `width` and `height` properties.\n */\nexport class Dimension {\n /**\n * Dimension constructor\n * @param {number|Point} w - The width of this Dimension, or the upper-left vertex of a\n * virtual Rectangle\n * @param {number|Point} h - The height of this Dimension, or the bottom-right vertex of a\n * virtual Rectangle\n */\n constructor(w, h) {\n if (w instanceof Point && h instanceof Point) {\n this.width = h.x - w.x;\n this.height = h.y - w.y;\n } else {\n this.width = w || 0;\n this.height = h || 0;\n }\n }\n\n /**\n * Reads the properties of this Dimension from an XML element\n * @param {external:jQuery} $xml - The xml element to be parsed\n * @returns {module:AWT.Dimension}\n */\n setProperties($xml) {\n this.width = Number($xml.attr('width'));\n this.height = Number($xml.attr('height'));\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, ['width', 'height']);\n }\n\n /**\n * Reads the properties of this Dimension from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Dimension}\n */\n setAttributes(data) {\n return setAttr(this, data, ['width', 'height']);\n }\n\n /**\n * Check if two dimensions are equivalent\n * @param {module:AWT.Dimension} d\n * @returns {boolean}\n */\n equals(d) {\n return this.width === d.width && this.height === d.height;\n }\n\n /**\n * Multiplies the `w` and `h` co-ordinates by a specified `delta`\n * @param {Point|Dimension} delta\n * @returns {module:AWT.Dimension}\n */\n multBy(delta) {\n this.width *= delta.x || delta.width || 0;\n this.height *= delta.y || delta.height || 0;\n return this;\n }\n\n /**\n * Sets new values for width and height.\n * `width` can be a number or another `Dimension` object\n * @param {number|Dimension} width - The new width, or a full Dimension to copy it from.\n * @param {number} [height] - Not used when `width` is a Dimension\n * @returns {module:AWT.Dimension}\n */\n setDimension(width, height) {\n if (width instanceof Dimension) {\n height = width.height;\n width = width.width;\n }\n this.width = width;\n this.height = height;\n return this;\n }\n\n /**\n * Calculates the area of a Rectangle with this dimension\n * @returns {number} The resulting area\n */\n getSurface() {\n return this.width * this.height;\n }\n}\n\nObject.assign(Dimension.prototype, {\n /**\n * @name module:AWT.Dimension#width\n * @type {number} */\n width: 0,\n /**\n * @name module:AWT.Dimension#height\n * @type {number} */\n height: 0,\n});\n\n/**\n * Shape is a generic abstract class for rectangles, ellipses and stroke-free shapes.\n * @abstract\n */\nexport class Shape {\n /**\n * Shape constructor\n * @param {module:AWT.Point} pos - The top-left coordinates of this Shape\n */\n constructor(pos) {\n this.pos = pos || new Point();\n }\n\n /**\n * Shifts the shape a specified amount in horizontal and vertical directions\n * @param {Point|Dimension} delta - The amount to shift the Shape\n * @returns {module:AWT.Shape}\n */\n moveBy(delta) {\n this.pos.moveBy(delta);\n return this;\n }\n\n /**\n * Moves this shape to a new position\n * @param {module:AWT.Point} newPos - The new position of the shape\n * @returns {module:AWT.Shape}\n */\n moveTo(newPos) {\n this.pos.moveTo(newPos);\n return this;\n }\n\n /**\n * Gets the enclosing {@link module:AWT.Rectangle Rectangle} of this Shape.\n * @returns {module:AWT.Rectangle}\n */\n getBounds() {\n return new Rectangle(this.pos);\n }\n\n /**\n * Checks if two shapes are equivalent.\n * @param {module:AWT.Shape} p - The Shape to compare against\n * @returns {boolean}\n */\n equals(p) {\n return this.pos.equals(p.pos);\n }\n\n /**\n * Multiplies the dimension of the Shape by the specified `delta` amount.\n * @param {Point|Dimension} _delta - Object containing the X and Y ratio to be scaled.\n * @returns {module:AWT.Shape}\n */\n scaleBy(_delta) {\n // Nothing to scale in abstract shapes\n return this;\n }\n\n /**\n * Gets a clone of this shape moved to the `pos` component of the rectangle and scaled\n * by its `dim` value.\n * @param {module:AWT.Rectangle} rect - The rectangle to be taken as a base for moving and scaling\n * this shape.\n * @returns {module:AWT.Shape}\n */\n getShape(rect) {\n return this.clone().scaleBy(rect.dim).moveBy(rect.pos);\n }\n\n /**\n * Checks if the provided {@link module:AWT.Point} is inside this shape.\n * @param {module:AWT.Point} _p - The point to check\n * @returns {boolean}\n */\n contains(_p) {\n // Nothing to check in abstract shapes\n return false;\n }\n\n /**\n * Checks if the provided {@link module:AWT.Rectangle Rectangle} `r` intersects with this shape.\n * @param {module:AWT.Rectangle} _r\n * @returns {boolean}\n */\n intersects(_r) {\n // Nothing to check in abstract shapes\n return false;\n }\n\n /**\n * Fills the Shape with the current style in the provided HTML canvas context\n * @param {external:CanvasRenderingContext2D} ctx - The canvas 2D rendering context where to fill this shape.\n * @param {module:AWT.Rectangle} [dirtyRegion] - The context region to be updated. Used as clipping\n * region when drawing.\n * @returns {external:CanvasRenderingContext2D} - The provided rendering context\n */\n fill(ctx, dirtyRegion) {\n ctx.save();\n if (dirtyRegion && dirtyRegion.getSurface() > 0) {\n // Clip the dirty region\n ctx.beginPath();\n ctx.rect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);\n ctx.clip();\n }\n // Prepare shape path and fill\n this.preparePath(ctx);\n ctx.fill();\n ctx.restore();\n return ctx;\n }\n\n /**\n * Draws this shape in the provided HTML canvas 2D rendering context.\n * @param {external:CanvasRenderingContext2D} ctx - The canvas 2D rendering context where to draw the shape.\n * @returns {external:CanvasRenderingContext2D} - The provided rendering context\n */\n stroke(ctx) {\n this.preparePath(ctx);\n ctx.stroke();\n return ctx;\n }\n\n /**\n * Prepares an HTML canvas 2D rendering context with a path that can be used to stroke a line,\n * to fill a surface or to define a clipping region.\n * @param {external:CanvasRenderingContext2D} ctx\n * @returns {external:CanvasRenderingContext2D} - The provided rendering context\n */\n preparePath(ctx) {\n // Nothing to do in abstract shapes\n return ctx;\n }\n\n /**\n * Creates a clipping region on the specified HTML canvas 2D rendering context\n * @param {external:CanvasRenderingContext2D} ctx - The rendering context\n * @param {string} [fillRule='nonzero'] - Can be 'nonzero' (default when not set) or 'evenodd'\n * @returns {external:CanvasRenderingContext2D} - The provided rendering context\n */\n clip(ctx, fillRule) {\n this.preparePath(ctx);\n ctx.clip(fillRule || 'nonzero');\n return ctx;\n }\n\n /**\n * Shorthand method for determining if a Shape is an {@link module:AWT.Rectangle Rectangle}\n * @returns {boolean}\n */\n isRect() {\n return false;\n }\n\n /**\n * Overwrites the original 'Object.toString' method with a more descriptive text\n * @returns {string}\n */\n toString() {\n return `Shape enclosed in ${this.getBounds().getCoords()}`;\n }\n\n /**\n * Reads the properties of this Shape from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Shape}\n */\n setAttributes(data) {\n return Shape.buildShape(data);\n /*\n return setAttr(this, data, [\n 'type',\n { key: 'pos', fn: Point },\n ]);\n */\n }\n\n /**\n * Builds a shape based on the provided `data` object.\n * Data should contain a 'type' member, specifying the type of shape requested ('rect', 'ellipse', 'rectangle' or 'path')\n * @param {object} data - Specific data for this shape\n * @returns {module:AWT.Shape}\n */\n static buildShape(data) {\n const shapeType = (data.type === 'rect' && Rectangle) || (data.type === 'ellipse' && Ellipse) || (data.type === 'path' && Path) || null;\n if (!shapeType) {\n console.log('unknown shape:', data);\n } else\n return (new shapeType()).setAttributes(data);\n }\n}\n\nObject.assign(Shape.prototype, {\n /**\n * Shape type id\n * @name module:AWT.Shape#type\n * @type {string} */\n type: 'shape',\n /**\n * The current position of the shape\n * @name module:AWT.Shape#pos\n * @type {module:AWT.Point} */\n pos: new Point(),\n /**\n * The type of shape (Rectangle, ellipse, path...)\n * @name module:AWT.Shape#type\n * @type {string} */\n type: 'shape',\n});\n\n/**\n * The rectangular {@link module:AWT.Shape} accepts five different sets of parameters:\n * @example\n * // Calling Rectangle() with different sets of parameters\n * // A Point and a Dimension:\n * new Rectangle(pos, dim)\n * // Another Rectangle, to be cloned:\n * new Rectangle(rect)\n * // Two Point objects containing the coordinates of upper-left and lower-right vertexs:\n * new Rectangle(p0, p1)\n * // An array of four numbers with the coordinates of the same vertexs:\n * new Rectangle([x0, y0, x1, y1])\n * // Four single numbers, meaning the same coordinates as above:\n * new Rectangle(x0, y0, x1, y1)\n * @extends module:AWT.Shape\n */\nexport class Rectangle extends Shape {\n /**\n * Rectangle constructor\n * @param {Point|Rectangle|number|number[]} pos\n * @param {Dimension|number} [dim]\n * @param {number} [w]\n * @param {number} [h]\n */\n constructor(pos, dim, w, h) {\n let p = pos, d = dim;\n // Special case: constructor with a Rectangle as a unique parameter\n if (pos instanceof Rectangle) {\n d = new Dimension(pos.dim.width, pos.dim.height);\n p = new Point(pos.pos.x, pos.pos.y);\n } else if (pos instanceof Point) {\n p = new Point(pos.x, pos.y);\n if (dim instanceof Dimension)\n d = new Dimension(dim.width, dim.height);\n } else if (pos instanceof Array) {\n // Assume `pos` is an array of numbers indicating: x0, y0, x1, y1\n p = new Point(pos[0], pos[1]);\n d = new Dimension(pos[2] - pos[0], pos[3] - pos[1]);\n } else if (typeof w === 'number' && typeof h === 'number') {\n // width and height passed. Treat all parameters as co-ordinates:\n p = new Point(pos, dim);\n d = new Dimension(w, h);\n }\n super(p);\n\n if (d instanceof Dimension)\n this.dim = d;\n else if (d instanceof Point)\n this.dim = new Dimension(d.x - this.pos.x, d.y - this.pos.y);\n else\n this.dim = new Dimension();\n\n this.type = 'rect';\n }\n\n /**\n * Gets the enclosing {@link module:AWT.Rectangle Rectangle} of this Shape.\n * @returns {module:AWT.Rectangle}\n */\n getBounds() {\n return this;\n }\n\n /**\n * Sets this Rectangle the position and dimension of another one\n * @param {module:AWT.Rectangle} rect\n * @returns {module:AWT.Rectangle}\n */\n setBounds(rect) {\n if (!rect)\n rect = new Rectangle();\n this.pos.x = rect.pos.x;\n this.pos.y = rect.pos.y;\n this.dim.width = rect.dim.width;\n this.dim.height = rect.dim.height;\n return this;\n }\n\n /**\n * Checks if two shapes are equivalent.\n * @param {module:AWT.Shape} r - The Shape to compare against\n * @returns {boolean}\n */\n equals(r) {\n return r instanceof Rectangle && this.pos.equals(r.pos) && this.dim.equals(r.dim);\n }\n\n /**\n * Clones this Rectangle\n * @returns {module:AWT.Rectangle}\n */\n clone() {\n return new Rectangle(this);\n }\n\n /**\n * Multiplies the dimension of the Shape by the specified `delta` amount.\n * @param {Point|Dimension} delta - Object containing the X and Y ratio to be scaled.\n * @returns {module:AWT.Rectangle}\n */\n scaleBy(delta) {\n this.pos.multBy(delta);\n this.dim.multBy(delta);\n return this;\n }\n\n /**\n * Expands the boundaries of this shape. This affects the current position and dimension.\n * @param {number} dx - The amount to grow (or decrease) in horizontal direction\n * @param {number} dy - The amount to grow (or decrease) in vertical direction\n * @returns {module:AWT.Rectangle}\n */\n grow(dx, dy) {\n this.pos.x -= dx;\n this.pos.y -= dy;\n this.dim.width += 2 * dx;\n this.dim.height += 2 * dy;\n return this;\n }\n\n /**\n * Gets the {@link module:AWT.Point} corresponding to the lower-right vertex of the Rectangle.\n * @returns {module:AWT.Point}\n */\n getOppositeVertex() {\n return new Point(this.pos.x + this.dim.width, this.pos.y + this.dim.height);\n }\n\n /**\n * Adds the boundaries of another shape to the current one\n * @param {module:AWT.Shape} shape - The {@link module:AWT.Shape} to be added\n * @returns {module:AWT.Rectangle}\n */\n add(shape) {\n const\n myP2 = this.getOppositeVertex(),\n rectP2 = shape.getBounds().getOppositeVertex();\n\n this.pos.moveTo(\n Math.min(this.pos.x, shape.getBounds().pos.x),\n Math.min(this.pos.y, shape.getBounds().pos.y));\n this.dim.setDimension(\n Math.max(myP2.x, rectP2.x) - this.pos.x,\n Math.max(myP2.y, rectP2.y) - this.pos.y);\n return this;\n }\n\n //\n // Inherits the documentation of `contains` in Shape\n contains(p) {\n const p2 = this.getOppositeVertex();\n return p.x >= this.pos.x && p.x <= p2.x && p.y >= this.pos.y && p.y <= p2.y;\n }\n\n //\n // Inherits the documentation of `intersects` in Shape\n intersects(r) {\n const\n p1 = this.pos, p2 = this.getOppositeVertex(),\n r1 = r.pos, r2 = r.getOppositeVertex();\n return r2.x >= p1.x && r1.x <= p2.x && r2.y >= p1.y && r1.y <= p2.y;\n }\n\n //\n // Inherits the documentation of `preparePath` in Shape\n preparePath(ctx) {\n ctx.beginPath();\n ctx.rect(this.pos.x, this.pos.y, this.dim.width, this.dim.height);\n return ctx;\n }\n\n //\n // Inherits the documentation of `getSurface` in Shape\n getSurface() {\n return this.dim.getSurface();\n }\n\n //\n // Inherits the documentation of `isEmpty` in Shape\n isEmpty() {\n return this.getSurface() === 0;\n }\n\n //\n // Inherits the documentation of `isRect` in Shape\n isRect() {\n return true;\n }\n\n //\n // Inherits the documentation of `toString` in Shape\n toString() {\n return `Rectangle ${this.getCoords()}`;\n }\n\n /**\n * Gets a string with the co-ordinates of the upper-left and lower-right vertexs of this rectangle,\n * (with values rounded to int)\n * @returns {string}\n */\n getCoords() {\n return `[${Math.round(this.pos.x)},${Math.round(this.pos.y)},${Math.round(this.pos.x + this.dim.width)},${Math.round(this.pos.y + this.dim.height)}]`;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, ['type', 'pos', 'dim']);\n }\n\n /**\n * Reads the properties of this Rectangle from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Rectangle}\n */\n setAttributes(data) {\n return setAttr(this, data, [\n 'type',\n { key: 'pos', fn: Point },\n { key: 'dim', fn: Dimension },\n ]);\n }\n}\n\nObject.assign(Rectangle.prototype, {\n /**\n * Shape type id\n * @name module:AWT.Rectangle#type\n * @type {string} */\n type: 'rect',\n /**\n * The {@link module:AWT.Dimension Dimension} of the Rectangle\n * @name module:AWT.Rectangle#dim\n * @type {module:AWT.Dimension} */\n dim: new Dimension(),\n});\n\n/**\n * The Ellipse shape has the same constructor options as {@link module:AWT.Rectangle Rectangle}\n * @extends module:AWT.Rectangle\n */\nexport class Ellipse extends Rectangle {\n /**\n * Ellipse constructor\n * @param {Point|Rectangle|number|number[]} pos\n * @param {Dimension|number} [dim]\n * @param {number} [w]\n * @param {number} [h]\n */\n constructor(pos, dim, w, h) {\n super(pos, dim, w, h);\n }\n\n //\n // Inherits the documentation of `preparePath` in Rectangle\n preparePath(ctx) {\n\n // Using the solution 'drawEllipseWithBezier' proposed by Steve Tranby in:\n // [http://jsbin.com/sosugenegi/1/edit] as a response to:\n // [http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas]\n // Thanks Steve!!\n\n const kappa = 0.5522848,\n ox = kappa * this.dim.width / 2, // control point offset horizontal\n oy = kappa * this.dim.height / 2, // control point offset vertical\n xe = this.pos.x + this.dim.width, // x-end\n ye = this.pos.y + this.dim.height, // y-end\n xm = this.pos.x + this.dim.width / 2, // x-middle\n ym = this.pos.y + this.dim.height / 2; // y-middle\n\n ctx.beginPath();\n ctx.moveTo(this.pos.x, ym);\n ctx.bezierCurveTo(this.pos.x, ym - oy, xm - ox, this.pos.y, xm, this.pos.y);\n ctx.bezierCurveTo(xm + ox, this.pos.y, xe, ym - oy, xe, ym);\n ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);\n ctx.bezierCurveTo(xm - ox, ye, this.pos.x, ym + oy, this.pos.x, ym);\n ctx.closePath();\n return ctx;\n }\n\n //\n // Inherits the documentation of `contains` in Shape\n contains(p) {\n // First check if the point is inside the enclosing rectangle\n let result = super.contains(p);\n if (result) {\n const\n rx = this.dim.width / 2,\n ry = this.dim.height / 2,\n cx = this.pos.x + rx,\n cy = this.pos.y + ry;\n // Apply the general equation of an ellipse\n // See: [http://math.stackexchange.com/questions/76457/check-if-a-point-is-within-an-ellipse]\n // rx and ry are > 0 because we are inside the enclosing rect,\n // so don't care about division by zero\n result = Math.pow(p.x - cx, 2) / Math.pow(rx, 2) + Math.pow(p.y - cy, 2) / Math.pow(ry, 2) <= 1;\n }\n return result;\n }\n\n //\n // Inherits the documentation of `getSurface` in Rectangle\n getSurface() {\n return Math.PI * this.dim.width / 2 * this.dim.height / 2;\n }\n\n //\n // Inherits the documentation of `equals` in Rectangle\n equals(e) {\n return e instanceof Ellipse && super.equals(e);\n }\n\n //\n // Inherits the documentation of `clone` in Rectangle\n clone() {\n return new Ellipse(this.pos, this.dim);\n }\n\n //\n // Inherits the documentation of `isRect` in Rectangle\n isRect() {\n return false;\n }\n\n //\n // Inherits the documentation of `toString` in Shape\n toString() {\n return `Ellipse enclosed in ${this.getCoords()}`;\n }\n}\n\nObject.assign(Ellipse.prototype, {\n /**\n * Shape type id\n * @name module:AWT.Ellipse#type\n * @type {string} */\n type: 'ellipse',\n});\n\n/**\n * A `Path` is a {@link module:AWT.Shape} formed by a serie of strokes, represented by\n * {@link module:AWT.PathStroke} objects\n * @extends module:AWT.Shape\n */\nexport class Path extends Shape {\n /**\n * Path constructor\n * @param {module:AWT.PathStroke[]} strokes - The array of {@link module:AWT.PathStroke} objects defining this Path.\n */\n constructor(strokes) {\n super();\n // Deep copy of the array of strokes\n if (strokes)\n this.setStrokes(strokes);\n }\n\n setStrokes(strokes) {\n this.strokes = [];\n // In [Shaper](Shaper.html) objects, strokes have `action` instead of `type` and `data` instead of `points`\n strokes.forEach(str => this.strokes.push(new PathStroke(str.type || str.action, str.points || str.data)));\n // Calculate the enclosing rectangle\n this.enclosing = new Rectangle();\n this.enclosingPoints = [];\n this.calcEnclosingRect();\n this.pos = this.enclosing.pos;\n return this;\n }\n\n //\n // Inherits the documentation of `clone` in Shape\n clone() {\n return new Path(this.strokes.map(str => str.clone()));\n }\n\n /**\n * Adds a {@link module:AWT.PathStroke} to `strokes`\n * @param {module:AWT.PathStroke} stroke\n */\n addStroke(stroke) {\n this.strokes.push(stroke);\n return this;\n }\n\n /**\n * Calculates the polygon and the rectangle that (approximately) encloses this shape\n * @returns {module:AWT.Rectangle}\n */\n calcEnclosingRect() {\n this.enclosingPoints = [];\n let last = new Point();\n this.strokes.forEach(str => {\n str.getEnclosingPoints(last).forEach(pt => {\n last = new Point(pt);\n this.enclosingPoints.push(last);\n });\n });\n\n let l = this.enclosingPoints.length;\n if (l > 1 && this.enclosingPoints[0].equals(this.enclosingPoints[l - 1])) {\n this.enclosingPoints.pop();\n l--;\n }\n const\n p0 = new Point(this.enclosingPoints[0]),\n p1 = new Point(this.enclosingPoints[0]);\n\n for (let k = 1; k < l; k++) {\n const p = this.enclosingPoints[k];\n // Check if `p` is at left or above `p0`\n p0.x = Math.min(p.x, p0.x);\n p0.y = Math.min(p.y, p0.y);\n // Check if `p` is at right or below `p1`\n p1.x = Math.max(p.x, p1.x);\n p1.y = Math.max(p.y, p1.y);\n }\n this.enclosing.setBounds(new Rectangle(p0, new Dimension(p0, p1)));\n return this.enclosing;\n }\n\n //\n // Inherits the documentation of `getBounds` in Shape\n getBounds() {\n return this.enclosing;\n }\n\n //\n // Inherits the documentation of `moveBy` in Shape\n moveBy(delta) {\n this.strokes.forEach(str => str.moveBy(delta));\n this.enclosingPoints.forEach(pt => pt.moveBy(delta));\n this.enclosing.moveBy(delta);\n return this;\n }\n\n //\n // Inherits the documentation of `moveTo` in Shape\n moveTo(newPos) {\n return this.moveBy(new Dimension(newPos.x - this.pos.x, newPos.y - this.pos.y));\n }\n\n //\n // Inherits the documentation of `equals` in Shape\n // TODO: Implement comparision of complex paths\n equals(_p) {\n return false;\n }\n\n //\n // Inherits the documentation of `scaleBy` in Shape\n scaleBy(delta) {\n this.strokes.forEach(str => str.multBy(delta));\n this.enclosingPoints.forEach(pt => pt.multBy(delta));\n this.enclosing.scaleBy(delta);\n return this;\n }\n\n //\n // Inherits the documentation of `contains` in Shape\n contains(p) {\n let result = this.enclosing.contains(p);\n if (result) {\n // Let's see if the point really lies inside the polygon formed by enclosingPoints\n // Using the \"Ray casting algorithm\" described in [https://en.wikipedia.org/wiki/Point_in_polygon]\n const N = this.enclosingPoints.length;\n let\n xinters = 0,\n counter = 0,\n p1 = this.enclosingPoints[0];\n\n for (let i = 1; i <= N; i++) {\n const p2 = this.enclosingPoints[i % N];\n if (p.y > Math.min(p1.y, p2.y)) {\n if (p.y <= Math.max(p1.y, p2.y)) {\n if (p.x <= Math.max(p1.x, p2.x)) {\n if (p1.y !== p2.y) {\n xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;\n if (p1.x === p2.x || p.x <= xinters)\n counter++;\n }\n }\n }\n }\n p1 = p2;\n }\n if (counter % 2 === 0)\n result = false;\n }\n return result;\n }\n\n //\n // Inherits the documentation of `intersects` in Shape\n // TODO: Implement a check algorithm based on the real shape\n intersects(r) {\n return this.enclosing.intersects(r);\n }\n\n //\n // Inherits the documentation of `preparePath` in Shape\n preparePath(ctx) {\n // TODO: Implement filling paths\n ctx.beginPath();\n this.strokes.forEach(str => str.stroke(ctx));\n return ctx;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return {\n type: this.type,\n strokes: this.strokes.map(s => s.getAttributes()).join('|'),\n };\n }\n\n /**\n * Reads the properties of this Path from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:AWT.Path}\n */\n setAttributes(data) {\n const strData = data.strokes.split('|');\n const strokes = strData.map(s => {\n const [type, points] = s.split(':');\n return new PathStroke(type, points ? points.split(',') : []);\n });\n return this.setStrokes(strokes);\n }\n}\n\nObject.assign(Path.prototype, {\n /**\n * Shape type id\n * @name module:AWT.Path#type\n * @type {string} */\n type: 'path',\n /**\n * The strokes forming this Path.\n * @name module:AWT.Path#strokes\n * @type {module:AWT.PathStroke[]} */\n strokes: [],\n /**\n * The {@link module:AWT.Rectangle Rectangle} enclosing this Path (when drawing, this Rectangle don't include border width!)\n * @name module:AWT.Path#enclosing\n * @type {module:AWT.Rectangle} */\n enclosing: new Rectangle(),\n /**\n * Set of vertexs of a polygon close to the real path of this shape\n * @name module:AWT.Path#enclosingPoints\n * @type {module:AWT.Point[]} */\n enclosingPoints: [],\n});\n\n/**\n * PathStroke is the basic component of {@link module:AWT.Path} objects\n */\nexport class PathStroke {\n /**\n * PathStroke constructor\n * @param {string} type - The type of stroke. Possible values are: `M` (move to), `L` (line to),\n * `Q` (quadratic to), `B` (bezier to) and `X` (close path).\n * @param {module:AWT.Point[]} points - The array of {@link module:AWT.Point} objects used in this Stroke.\n */\n constructor(type, points) {\n this.type = type;\n // Points are deep cloned, to avoid change the original values\n if (points && points.length > 0) {\n // Check if 'points' is an array of objects of type 'Point'\n if (points[0] instanceof Point)\n this.points = points.map(p => new Point(p));\n // otherwise assume that 'points' contains just numbers\n // to be readed in pairs of x and y co-ordinates\n else {\n this.points = [];\n for (let i = 0; i < points.length; i += 2)\n this.points.push(new Point(points[i], points[i + 1]));\n }\n }\n }\n\n /**\n * Calculates some of the points included in a quadratic Bézier curve\n * The number of points being calculated is defined in Utils.settings.BEZIER_POINTS\n * @see {@link https://en.wikipedia.org/wiki/B%C3%A9zier_curve}\n * @see {@link https://www.jasondavies.com/animated-bezier/}\n *\n * @param {module:AWT.Point} p0 - Starting point of the quadratic Bézier curve\n * @param {module:AWT.Point} p1 - Control point\n * @param {module:AWT.Point} p2 - Ending point\n * @param {number} [numPoints] - The number of intermediate points to calculate. When not defined,\n * the value will be obtained from {@link module:Utils.settings.BEZIER_POINTS}.\n * @returns {module:AWT.Point[]} - Array with some intermediate points from the resulting Bézier curve\n */\n static getQuadraticPoints(p0, p1, p2, numPoints) {\n if (!numPoints)\n numPoints = settings.BEZIER_POINTS;\n const\n result = [],\n pxa = new Point(),\n pxb = new Point();\n for (let i = 0; i < numPoints; i++) {\n const n = (i + 1) / (numPoints + 1);\n pxa.x = p0.x + (p1.x - p0.x) * n;\n pxa.y = p0.y - (p0.y - p1.y) * n;\n pxb.x = p1.x + (p2.x - p1.x) * n;\n pxb.y = p1.y + (p2.y - p1.y) * n;\n result.push(new Point(pxa.x + (pxb.x - pxa.x) * n, pxa.y - (pxa.y - pxb.y) * n));\n }\n return result;\n }\n\n /**\n * Calculates some of the points included in a cubic Bézier (curve with two control points)\n * The number of points being calculated is defined in Utils.settings.BEZIER_POINTS\n * @param {module:AWT.Point} p0 - Starting point of the cubic Bézier curve\n * @param {module:AWT.Point} p1 - First control point\n * @param {module:AWT.Point} p2 - Second control point\n * @param {module:AWT.Point} p3 - Ending point\n * @param {number} [numPoints] - The number of intermediate points to calculate. When not defined,\n * the value will be obtained from {@link module:Utils.settings.BEZIER_POINTS}.\n * @returns {module:AWT.Point[]} - Array with some intermediate points from the resulting Bézier curve\n */\n static getCubicPoints(p0, p1, p2, p3, numPoints) {\n const result = [];\n if (!numPoints)\n numPoints = settings.BEZIER_POINTS;\n const pr = PathStroke.getQuadraticPoints(p0, p1, p2, numPoints);\n const pq = PathStroke.getQuadraticPoints(p1, p2, p3, numPoints);\n for (let i = 0; i < numPoints; i++) {\n const n = (i + 1) / (numPoints + 1);\n result.push(new Point(pr[i].x + (pq[i].x - pr[i].x) * n, pr[i].y - (pr[0].y - pq[0].y) * n));\n }\n return result;\n }\n\n /**\n * Clones this PathStroke\n * @returns {module:AWT.PathStroke}\n */\n clone() {\n // The constructors of PathStroke always make a deep copy of the `points` array\n return new PathStroke(this.type, this.points);\n }\n\n /**\n * Increments or decrements by `delta` the x and y coordinates of all points\n * @param {Point|Dimension} delta - The amount to add to the `x` and `y`\n * coordinates of each point.\n */\n moveBy(delta) {\n if (this.points)\n this.points.forEach(pt => pt.moveBy(delta));\n return this;\n }\n\n /**\n * Multiplies each point coordinates by the `x` and `y` (or `w` and `h`) values of the\n * passed {@link module:AWT.Point} or {@link module:AWT.Dimension Dimension}.\n * @param {Point|Dimension} delta\n */\n multBy(delta) {\n if (this.points)\n this.points.forEach(pt => pt.multBy(delta));\n return this;\n }\n\n /**\n * Draws this PathStroke in the provided HTML canvas context\n * @param {external:CanvasRenderingContext2D} ctx - The HTML canvas 2D rendering context\n */\n stroke(ctx) {\n switch (this.type) {\n case 'M':\n ctx.moveTo(this.points[0].x, this.points[0].y);\n break;\n case 'L':\n ctx.lineTo(this.points[0].x, this.points[0].y);\n break;\n case 'Q':\n ctx.quadraticCurveTo(\n this.points[0].x, this.points[0].y,\n this.points[1].x, this.points[1].y);\n break;\n case 'B':\n ctx.bezierCurveTo(\n this.points[0].x, this.points[0].y,\n this.points[1].x, this.points[1].y,\n this.points[2].x, this.points[2].y);\n break;\n case 'X':\n ctx.closePath();\n break;\n }\n return ctx;\n }\n\n /**\n * Gets the set of points that will be included as a vertexs on the owner's shape\n * enclosing polygon.\n * @param {module:AWT.Point} from - The starting point for this stroke\n * @returns {module:AWT.Point[]}\n */\n getEnclosingPoints(from) {\n let result = [];\n switch (this.type) {\n case 'M':\n case 'L':\n result.push(this.points[0]);\n break;\n case 'Q':\n result = PathStroke.getQuadraticPoints(from, this.points[0], this.points[1]);\n result.push(this.points[1]);\n break;\n case 'B':\n result = PathStroke.getCubicPoints(from, this.points[0], this.points[1], this.points[2]);\n result.push(this.points[2]);\n break;\n }\n return result;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return `${this.type}:${this.points ? this.points.map(p => `${fx(p.x)},${fx(p.y)}`).join(',') : ''}`;\n }\n}\n\nObject.assign(PathStroke.prototype, {\n /**\n * The Stroke type. Possible values are: `M` (move to), `L` (line to), `Q` (quadratic to),\n * `B` (bezier to) and `X` (close path).\n * @name module:AWT.PathStroke#type\n * @type {string} */\n type: 'X',\n /**\n * The array of points used by this stroke. Can be `null`.\n * @name module:AWT.PathStroke#points\n * @type {module:AWT.Point[]} */\n points: null,\n});\n\n/**\n * This class encapsulates actions that can be linked to buttons, menus and other active objects\n */\nexport class Action {\n /**\n * Action constructor\n * @param {string} name - The name of this Action\n * @param {function} actionPerformed - The callback to be triggered by this Action\n */\n constructor(name, actionPerformed) {\n this.name = name;\n this.actionPerformed = actionPerformed;\n this._statusListeners = [];\n }\n\n /**\n * Here is where subclasses must define the callback to be triggered when\n * this Action object is called\n * @param {module:AWT.Action} _thisAction - Pointer to this Action object\n * @param {object} _event - The original action event that has originated this action\n */\n actionPerformed(_thisAction, _event) {\n return this;\n }\n\n /**\n * This is the method to be passed to DOM event triggers\n * @example\n * const myFunc = () => { alert('Hello!') }\n * const myAction = new Action('hello', myFunc)\n * $( \"#foo\" ).bind( \"click\", myAction.processEvent)\n * @param {object} event - The event object passed by the DOM event trigger\n */\n processEvent(event) {\n return this.actionPerformed(this, event);\n }\n\n /**\n * Adds a status listener\n * @param {function} listener - The callback method to be called when the status of this\n * Action changes\n */\n addStatusListener(listener) {\n this._statusListeners.push(listener);\n }\n\n /**\n * Removes a previously registered status listener\n * @param {function} listener - The listener to be removed\n */\n removeStatusListener(listener) {\n this._statusListeners = this._statusListeners.map(l => l !== listener);\n }\n\n /**\n * Enables or disables this action\n * @param {boolean} enabled\n */\n setEnabled(enabled) {\n this.enabled = enabled;\n this._statusListeners.forEach(listener => listener.call(this, this));\n return this;\n }\n}\n\nObject.assign(Action.prototype, {\n /**\n * The action's name\n * @name module:AWT.Action#name\n * @type {string} */\n name: null,\n /**\n * An optional description\n * @name module:AWT.Action#description\n * @type {string} */\n description: null,\n /**\n * Action status. `true` means enabled, `false` disabled\n * @name module:AWT.Action#enabled\n * @type {boolean} */\n enabled: false,\n /**\n * Array of callback functions to be triggered when the `enabled` flag changes\n * @name module:AWT.Action#_statusListeners\n * @private\n * @type {function[]} */\n _statusListeners: null,\n});\n\n/**\n * This class provides a timer that will launch a function at specific intervals\n */\nexport class Timer {\n /**\n * Timer constructor\n * @param {function} actionPerformed - The function to be triggered when the timer is enabled.\n * @param {number} interval - The interval between action calls, specified in milliseconds.\n * @param {boolean} [enabled=false] - Flag to indicate if the timer will be initially enabled.\n */\n constructor(actionPerformed, interval, enabled) {\n this.actionPerformed = actionPerformed;\n this.interval = interval;\n this.setEnabled(enabled === true);\n }\n\n /**\n * Here is where subclasses must define the function to be performed when this timer ticks.\n * @param {module:AWT.Timer} _thisTimer\n */\n actionPerformed(_thisTimer) {\n return this;\n }\n\n /**\n * This is the method called by `window.setInterval`\n * @param {external:Event} _event\n */\n processTimer(_event) {\n this.ticks++;\n if (!this.repeats)\n this.stop();\n return this.actionPerformed.call(this);\n }\n\n /**\n * Enables or disables this timer\n * @param {boolean} enabled - Indicates if the timer should be enabled or disabled\n * @param {boolean} [retainCounter=false] - When `true`, the ticks counter will not be cleared\n */\n setEnabled(enabled, retainCounter) {\n if (!retainCounter)\n this.ticks = 0;\n if (enabled && this.timer !== null) {\n // Timer already running\n return;\n }\n\n if (enabled) {\n this.timer = window.setInterval(() => this.processTimer(null), this.interval);\n } else {\n if (this.timer !== null) {\n window.clearInterval(this.timer);\n this.timer = null;\n }\n }\n return this;\n }\n\n /**\n * Checks if this timer is running\n * @returns {boolean}\n */\n isRunning() {\n return this.timer !== null;\n }\n\n /**\n * Starts this timer\n * @param {boolean} [retainCounter=false] - When `true`, the ticks counter will not be cleared\n */\n start(retainCounter) {\n return this.setEnabled(true, retainCounter);\n }\n\n /**\n * Stops this timer\n * @param {boolean} [retainCounter=false] - When `true`, the ticks counter will not be cleared\n */\n stop(retainCounter) {\n return this.setEnabled(false, retainCounter);\n }\n}\n\nObject.assign(Timer.prototype, {\n /**\n * The timer interval, in milliseconds\n * @name module:AWT.Timer#interval\n * @type {number} */\n interval: 0,\n /**\n * The ticks counter\n * @name module:AWT.Timer#ticks\n * @type {number} */\n ticks: 0,\n /**\n * The object returned by `window.setInterval`\n * @name module:AWT.Timer#timer\n * @type {object} */\n timer: null,\n /**\n * When `true`, the timer should repeat until `stop` is called\n * @name module:AWT.Timer#repeats\n * @type {boolean} */\n repeats: true,\n});\n\n/**\n * Logic object that takes care of an \"invalidated\" rectangle that will be repainted\n * at the next update of a 2D object, usually an HTML Canvas.\n * Container has the same constructor options as {@link module:AWT.Rectangle Rectangle}\n * @extends module:AWT.Rectangle\n */\nexport class Container extends Rectangle {\n /**\n * Container constructor\n * @param {Point|Rectangle|number|number[]} pos\n * @param {Dimension|number} [dim]\n * @param {number} [w]\n * @param {number} [h]\n */\n constructor(pos, dim, w, h) {\n super(pos, dim, w, h);\n }\n\n /**\n * Adds the provided rectangle to the invalidated area.\n * @param {module:AWT.Rectangle} rect\n */\n invalidate(rect) {\n if (rect) {\n if (this.invalidatedRect === null)\n this.invalidatedRect = rect.clone();\n else\n this.invalidatedRect.add(rect);\n } else\n this.invalidatedRect = null;\n return this;\n }\n\n /**\n * Updates the invalidated area\n */\n update() {\n this.updateContent(this.invalidatedRect);\n this.invalidatedRect = null;\n return this;\n }\n\n /**\n * Containers should implement this method to update its graphic contents. It should\n * be called from {@link module:AWT.Container#update}\n * @param {module:AWT.Shape} _dirtyRegion - Specifies the area to be updated. When `null`, it's the whole\n * Container.\n */\n updateContent(_dirtyRegion) {\n // To be overrided by subclasses. Here does nothing.\n return this;\n }\n}\n\nObject.assign(Container.prototype, {\n /**\n * The currently \"invalidated\" area\n * @name module:AWT.Container#invalidatedRect\n * @type {module:AWT.Rectangle} */\n invalidatedRect: null,\n});\n\n/**\n * This object contains utility clases for painting graphics and images,\n * as found in the Java [Abstract Window Toolkit](http://docs.oracle.com/javase/7/docs/api/java/awt/package-summary.html)\n *\n * The objects defined here are: {@link module:AWT.Font Font}, {@link module:AWT.Gradient Gradient}, {@link module:AWT.Stroke Stroke},\n * {@link module:AWT.Point Point}, {@link module:AWT.Dimension Dimension}, {@link module:AWT.Shape Shape}, {@link module:AWT.Rectangle Rectangle},\n * {@link module:AWT.Ellipse Ellipse}, {@link module:AWT.Path Path}, {@link module:AWT.PathStroke PathStroke}, {@link module:AWT.Action Action},\n * {@link module:AWT.Timer Timer} and {@link module:AWT.Container Container}.\n */\nexport default {\n Font,\n Gradient,\n Stroke,\n Point,\n Dimension,\n Shape,\n Rectangle,\n Ellipse,\n Path,\n PathStroke,\n Action,\n Timer,\n Container\n};\n"],"names":[],"sourceRoot":""}