@next2d/player 1.14.6 → 1.14.8

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 (415) hide show
  1. package/@types/next2d.d.ts +4 -0
  2. package/@types/window.d.ts +74 -0
  3. package/README.ja.md +8 -7
  4. package/README.md +17 -12
  5. package/dist/interface/AjaxEventImpl.d.ts +5 -0
  6. package/dist/interface/AjaxEventImpl.js +1 -0
  7. package/dist/interface/AjaxOptionImpl.d.ts +13 -0
  8. package/dist/interface/AjaxOptionImpl.js +1 -0
  9. package/dist/interface/AttachmentImpl.d.ts +11 -0
  10. package/dist/interface/AttachmentImpl.js +1 -0
  11. package/dist/interface/BitmapDataChannelImpl.d.ts +1 -0
  12. package/dist/interface/BitmapDataChannelImpl.js +1 -0
  13. package/dist/interface/BitmapDrawObjectImpl.d.ts +6 -0
  14. package/dist/interface/BitmapDrawObjectImpl.js +1 -0
  15. package/dist/interface/BitmapFilterTypeImpl.d.ts +1 -0
  16. package/dist/interface/BitmapFilterTypeImpl.js +1 -0
  17. package/dist/interface/BlendModeImpl.d.ts +1 -0
  18. package/dist/interface/BlendModeImpl.js +1 -0
  19. package/dist/interface/BoundsImpl.d.ts +6 -0
  20. package/dist/interface/BoundsImpl.js +1 -0
  21. package/dist/interface/Character.d.ts +2 -0
  22. package/dist/interface/Character.js +1 -0
  23. package/dist/interface/CharacterImpl.d.ts +2 -0
  24. package/dist/interface/CharacterImpl.js +1 -0
  25. package/dist/interface/ClassNameMap.d.ts +4 -0
  26. package/dist/interface/ClassNameMap.js +1 -0
  27. package/dist/interface/ClipObjectImpl.d.ts +14 -0
  28. package/dist/interface/ClipObjectImpl.js +1 -0
  29. package/dist/interface/ColorStopImpl.d.ts +7 -0
  30. package/dist/interface/ColorStopImpl.js +1 -0
  31. package/dist/interface/DictionaryTagImpl.d.ts +7 -0
  32. package/dist/interface/DictionaryTagImpl.js +1 -0
  33. package/dist/interface/DisplacementMapFilterModeImpl.d.ts +1 -0
  34. package/dist/interface/DisplacementMapFilterModeImpl.js +1 -0
  35. package/dist/interface/DisplayImpl.d.ts +28 -0
  36. package/dist/interface/DisplayImpl.js +1 -0
  37. package/dist/interface/DisplayObjectImpl.d.ts +2 -0
  38. package/dist/interface/DisplayObjectImpl.js +1 -0
  39. package/dist/interface/DragRulesImpl.d.ts +7 -0
  40. package/dist/interface/DragRulesImpl.js +1 -0
  41. package/dist/interface/DropTargetImpl.d.ts +2 -0
  42. package/dist/interface/DropTargetImpl.js +1 -0
  43. package/dist/interface/EventDispatcherImpl.d.ts +2 -0
  44. package/dist/interface/EventDispatcherImpl.js +1 -0
  45. package/dist/interface/EventListenerImpl.d.ts +6 -0
  46. package/dist/interface/EventListenerImpl.js +1 -0
  47. package/dist/interface/EventsImpl.d.ts +20 -0
  48. package/dist/interface/EventsImpl.js +1 -0
  49. package/dist/interface/FillMeshImpl.d.ts +5 -0
  50. package/dist/interface/FillMeshImpl.js +1 -0
  51. package/dist/interface/FilterArrayImpl.d.ts +10 -0
  52. package/dist/interface/FilterArrayImpl.js +1 -0
  53. package/dist/interface/FilterQualityImpl.d.ts +1 -0
  54. package/dist/interface/FilterQualityImpl.js +1 -0
  55. package/dist/interface/FiltersImpl.d.ts +20 -0
  56. package/dist/interface/FiltersImpl.js +1 -0
  57. package/dist/interface/GeomImpl.d.ts +12 -0
  58. package/dist/interface/GeomImpl.js +1 -0
  59. package/dist/interface/GradientTypeImpl.d.ts +3 -0
  60. package/dist/interface/GradientTypeImpl.js +1 -0
  61. package/dist/interface/GraphicsParentImpl.d.ts +2 -0
  62. package/dist/interface/GraphicsParentImpl.js +1 -0
  63. package/dist/interface/GridImpl.d.ts +6 -0
  64. package/dist/interface/GridImpl.js +1 -0
  65. package/dist/interface/ImageTypeImpl.d.ts +1 -0
  66. package/dist/interface/ImageTypeImpl.js +1 -0
  67. package/dist/interface/IndexRangeImpl.d.ts +4 -0
  68. package/dist/interface/IndexRangeImpl.js +1 -0
  69. package/dist/interface/LoaderInfoDataImpl.d.ts +7 -0
  70. package/dist/interface/LoaderInfoDataImpl.js +1 -0
  71. package/dist/interface/LoopConfigImpl.d.ts +8 -0
  72. package/dist/interface/LoopConfigImpl.js +1 -0
  73. package/dist/interface/LoopTypeImpl.d.ts +1 -0
  74. package/dist/interface/LoopTypeImpl.js +1 -0
  75. package/dist/interface/MediaImpl.d.ts +10 -0
  76. package/dist/interface/MediaImpl.js +1 -0
  77. package/dist/interface/MovieClipActionObjectImpl.d.ts +5 -0
  78. package/dist/interface/MovieClipActionObjectImpl.js +1 -0
  79. package/dist/interface/MovieClipCharacterImpl.d.ts +18 -0
  80. package/dist/interface/MovieClipCharacterImpl.js +1 -0
  81. package/dist/interface/MovieClipLabelObjectImpl.d.ts +4 -0
  82. package/dist/interface/MovieClipLabelObjectImpl.js +1 -0
  83. package/dist/interface/MovieClipSoundObjectImpl.d.ts +5 -0
  84. package/dist/interface/MovieClipSoundObjectImpl.js +1 -0
  85. package/dist/interface/NetImpl.d.ts +6 -0
  86. package/dist/interface/NetImpl.js +1 -0
  87. package/dist/interface/NoCodeDataImpl.d.ts +7 -0
  88. package/dist/interface/NoCodeDataImpl.js +1 -0
  89. package/dist/interface/NoCodeDataZlibImpl.d.ts +4 -0
  90. package/dist/interface/NoCodeDataZlibImpl.js +1 -0
  91. package/dist/interface/ParentImpl.d.ts +2 -0
  92. package/dist/interface/ParentImpl.js +1 -0
  93. package/dist/interface/PlaceObjectImpl.d.ts +12 -0
  94. package/dist/interface/PlaceObjectImpl.js +1 -0
  95. package/dist/interface/PlayerHitObjectImpl.d.ts +7 -0
  96. package/dist/interface/PlayerHitObjectImpl.js +1 -0
  97. package/dist/interface/PlayerModeImpl.d.ts +1 -0
  98. package/dist/interface/PlayerModeImpl.js +1 -0
  99. package/dist/interface/PlayerOptionsImpl.d.ts +8 -0
  100. package/dist/interface/PlayerOptionsImpl.js +1 -0
  101. package/dist/interface/PointImpl.d.ts +4 -0
  102. package/dist/interface/PointImpl.js +1 -0
  103. package/dist/interface/PreObjectImpl.d.ts +23 -0
  104. package/dist/interface/PreObjectImpl.js +1 -0
  105. package/dist/interface/PropertyContainerMessageImpl.d.ts +6 -0
  106. package/dist/interface/PropertyContainerMessageImpl.js +1 -0
  107. package/dist/interface/PropertyMessageImpl.d.ts +41 -0
  108. package/dist/interface/PropertyMessageImpl.js +1 -0
  109. package/dist/interface/PropertyMessageMapImpl.d.ts +2 -0
  110. package/dist/interface/PropertyMessageMapImpl.js +1 -0
  111. package/dist/interface/PropertyShapeMessageImpl.d.ts +6 -0
  112. package/dist/interface/PropertyShapeMessageImpl.js +1 -0
  113. package/dist/interface/PropertyTextMessageImpl.d.ts +25 -0
  114. package/dist/interface/PropertyTextMessageImpl.js +1 -0
  115. package/dist/interface/PropertyVideoMessageImpl.d.ts +5 -0
  116. package/dist/interface/PropertyVideoMessageImpl.js +1 -0
  117. package/dist/interface/RGBAImpl.d.ts +6 -0
  118. package/dist/interface/RGBAImpl.js +1 -0
  119. package/dist/interface/RenderDisplayObjectImpl.d.ts +2 -0
  120. package/dist/interface/RenderDisplayObjectImpl.js +1 -0
  121. package/dist/interface/ShapeCharacterImpl.d.ts +14 -0
  122. package/dist/interface/ShapeCharacterImpl.js +1 -0
  123. package/dist/interface/SoundCharacterImpl.d.ts +5 -0
  124. package/dist/interface/SoundCharacterImpl.js +1 -0
  125. package/dist/interface/SoundTagImpl.d.ts +6 -0
  126. package/dist/interface/SoundTagImpl.js +1 -0
  127. package/dist/interface/SpriteImpl.d.ts +2 -0
  128. package/dist/interface/SpriteImpl.js +1 -0
  129. package/dist/interface/StageDataImpl.d.ts +6 -0
  130. package/dist/interface/StageDataImpl.js +1 -0
  131. package/dist/interface/StageQualityImpl.d.ts +1 -0
  132. package/dist/interface/StageQualityImpl.js +1 -0
  133. package/dist/interface/StrokeMethImpl.d.ts +4 -0
  134. package/dist/interface/StrokeMethImpl.js +1 -0
  135. package/dist/interface/StrokeTypeImpl.d.ts +2 -0
  136. package/dist/interface/StrokeTypeImpl.js +1 -0
  137. package/dist/interface/SurfaceFilterImpl.d.ts +6 -0
  138. package/dist/interface/SurfaceFilterImpl.js +1 -0
  139. package/dist/interface/TextBreakObjectImpl.d.ts +9 -0
  140. package/dist/interface/TextBreakObjectImpl.js +1 -0
  141. package/dist/interface/TextCharacterImpl.d.ts +27 -0
  142. package/dist/interface/TextCharacterImpl.js +1 -0
  143. package/dist/interface/TextDataImpl.d.ts +2 -0
  144. package/dist/interface/TextDataImpl.js +1 -0
  145. package/dist/interface/TextFieldAutoSizeImpl.d.ts +1 -0
  146. package/dist/interface/TextFieldAutoSizeImpl.js +1 -0
  147. package/dist/interface/TextFieldTypeImpl.d.ts +1 -0
  148. package/dist/interface/TextFieldTypeImpl.js +1 -0
  149. package/dist/interface/TextFormatAlignImpl.d.ts +1 -0
  150. package/dist/interface/TextFormatAlignImpl.js +1 -0
  151. package/dist/interface/TextFormatImpl.d.ts +16 -0
  152. package/dist/interface/TextFormatImpl.js +1 -0
  153. package/dist/interface/TextFormatVerticalAlignImpl.d.ts +1 -0
  154. package/dist/interface/TextFormatVerticalAlignImpl.js +1 -0
  155. package/dist/interface/TextImageObjectImpl.d.ts +11 -0
  156. package/dist/interface/TextImageObjectImpl.js +1 -0
  157. package/dist/interface/TextImpl.d.ts +6 -0
  158. package/dist/interface/TextImpl.js +1 -0
  159. package/dist/interface/TextModeImpl.d.ts +1 -0
  160. package/dist/interface/TextModeImpl.js +1 -0
  161. package/dist/interface/TextObjectImpl.d.ts +7 -0
  162. package/dist/interface/TextObjectImpl.js +1 -0
  163. package/dist/interface/TextObjectModeImpl.d.ts +1 -0
  164. package/dist/interface/TextObjectModeImpl.js +1 -0
  165. package/dist/interface/TextStringObjectImpl.d.ts +7 -0
  166. package/dist/interface/TextStringObjectImpl.js +1 -0
  167. package/dist/interface/UIImpl.d.ts +8 -0
  168. package/dist/interface/UIImpl.js +1 -0
  169. package/dist/interface/URLLoaderDataFormatImpl.d.ts +1 -0
  170. package/dist/interface/URLLoaderDataFormatImpl.js +1 -0
  171. package/dist/interface/URLRequestMethodImpl.d.ts +1 -0
  172. package/dist/interface/URLRequestMethodImpl.js +1 -0
  173. package/dist/interface/UniformDataImpl.d.ts +5 -0
  174. package/dist/interface/UniformDataImpl.js +1 -0
  175. package/dist/interface/UnzipQueueImpl.d.ts +6 -0
  176. package/dist/interface/UnzipQueueImpl.js +1 -0
  177. package/dist/interface/VerticesImpl.d.ts +1 -0
  178. package/dist/interface/VerticesImpl.js +1 -0
  179. package/dist/interface/VideoCharacterImpl.d.ts +12 -0
  180. package/dist/interface/VideoCharacterImpl.js +1 -0
  181. package/dist/player/index.d.ts +1 -0
  182. package/dist/player/index.js +40 -0
  183. package/dist/player/next2d/display/BitmapData.d.ts +143 -0
  184. package/dist/player/next2d/display/BitmapData.js +390 -0
  185. package/dist/player/next2d/display/BlendMode.d.ts +204 -0
  186. package/dist/player/next2d/display/BlendMode.js +240 -0
  187. package/dist/player/next2d/display/DisplayObject.d.ts +571 -0
  188. package/dist/player/next2d/display/DisplayObject.js +1733 -0
  189. package/dist/player/next2d/display/DisplayObjectContainer.d.ts +351 -0
  190. package/dist/player/next2d/display/DisplayObjectContainer.js +1765 -0
  191. package/dist/player/next2d/display/FrameLabel.d.ts +98 -0
  192. package/dist/player/next2d/display/FrameLabel.js +122 -0
  193. package/dist/player/next2d/display/Graphics.d.ts +577 -0
  194. package/dist/player/next2d/display/Graphics.js +2193 -0
  195. package/dist/player/next2d/display/GraphicsBitmapFill.d.ts +49 -0
  196. package/dist/player/next2d/display/GraphicsBitmapFill.js +90 -0
  197. package/dist/player/next2d/display/GraphicsGradientFill.d.ts +66 -0
  198. package/dist/player/next2d/display/GraphicsGradientFill.js +162 -0
  199. package/dist/player/next2d/display/InteractiveObject.d.ts +32 -0
  200. package/dist/player/next2d/display/InteractiveObject.js +44 -0
  201. package/dist/player/next2d/display/Loader.d.ts +131 -0
  202. package/dist/player/next2d/display/Loader.js +324 -0
  203. package/dist/player/next2d/display/LoaderInfo.d.ts +122 -0
  204. package/dist/player/next2d/display/LoaderInfo.js +191 -0
  205. package/dist/player/next2d/display/LoopConfig.d.ts +108 -0
  206. package/dist/player/next2d/display/LoopConfig.js +160 -0
  207. package/dist/player/next2d/display/LoopType.d.ts +104 -0
  208. package/dist/player/next2d/display/LoopType.js +122 -0
  209. package/dist/player/next2d/display/MovieClip.d.ts +312 -0
  210. package/dist/player/next2d/display/MovieClip.js +959 -0
  211. package/dist/player/next2d/display/Shape.d.ts +167 -0
  212. package/dist/player/next2d/display/Shape.js +514 -0
  213. package/dist/player/next2d/display/Sprite.d.ts +174 -0
  214. package/dist/player/next2d/display/Sprite.js +288 -0
  215. package/dist/player/next2d/display/Stage.d.ts +164 -0
  216. package/dist/player/next2d/display/Stage.js +255 -0
  217. package/dist/player/next2d/events/Event.d.ts +424 -0
  218. package/dist/player/next2d/events/Event.js +569 -0
  219. package/dist/player/next2d/events/EventDispatcher.d.ts +138 -0
  220. package/dist/player/next2d/events/EventDispatcher.js +624 -0
  221. package/dist/player/next2d/events/EventPhase.d.ts +80 -0
  222. package/dist/player/next2d/events/EventPhase.js +94 -0
  223. package/dist/player/next2d/events/FocusEvent.d.ts +89 -0
  224. package/dist/player/next2d/events/FocusEvent.js +103 -0
  225. package/dist/player/next2d/events/HTTPStatusEvent.d.ts +107 -0
  226. package/dist/player/next2d/events/HTTPStatusEvent.js +142 -0
  227. package/dist/player/next2d/events/IOErrorEvent.d.ts +82 -0
  228. package/dist/player/next2d/events/IOErrorEvent.js +102 -0
  229. package/dist/player/next2d/events/MouseEvent.d.ts +163 -0
  230. package/dist/player/next2d/events/MouseEvent.js +207 -0
  231. package/dist/player/next2d/events/ProgressEvent.d.ts +97 -0
  232. package/dist/player/next2d/events/ProgressEvent.js +125 -0
  233. package/dist/player/next2d/events/VideoEvent.d.ts +145 -0
  234. package/dist/player/next2d/events/VideoEvent.js +183 -0
  235. package/dist/player/next2d/filters/BevelFilter.d.ts +254 -0
  236. package/dist/player/next2d/filters/BevelFilter.js +501 -0
  237. package/dist/player/next2d/filters/BitmapFilter.d.ts +75 -0
  238. package/dist/player/next2d/filters/BitmapFilter.js +96 -0
  239. package/dist/player/next2d/filters/BlurFilter.d.ts +150 -0
  240. package/dist/player/next2d/filters/BlurFilter.js +373 -0
  241. package/dist/player/next2d/filters/ColorMatrixFilter.d.ts +116 -0
  242. package/dist/player/next2d/filters/ColorMatrixFilter.js +180 -0
  243. package/dist/player/next2d/filters/ConvolutionFilter.d.ts +210 -0
  244. package/dist/player/next2d/filters/ConvolutionFilter.js +375 -0
  245. package/dist/player/next2d/filters/DisplacementMapFilter.d.ts +212 -0
  246. package/dist/player/next2d/filters/DisplacementMapFilter.js +381 -0
  247. package/dist/player/next2d/filters/DropShadowFilter.d.ts +240 -0
  248. package/dist/player/next2d/filters/DropShadowFilter.js +470 -0
  249. package/dist/player/next2d/filters/GlowFilter.d.ts +204 -0
  250. package/dist/player/next2d/filters/GlowFilter.js +362 -0
  251. package/dist/player/next2d/filters/GradientBevelFilter.d.ts +243 -0
  252. package/dist/player/next2d/filters/GradientBevelFilter.js +483 -0
  253. package/dist/player/next2d/filters/GradientGlowFilter.d.ts +243 -0
  254. package/dist/player/next2d/filters/GradientGlowFilter.js +473 -0
  255. package/dist/player/next2d/geom/ColorTransform.d.ts +201 -0
  256. package/dist/player/next2d/geom/ColorTransform.js +279 -0
  257. package/dist/player/next2d/geom/Matrix.d.ts +299 -0
  258. package/dist/player/next2d/geom/Matrix.js +455 -0
  259. package/dist/player/next2d/geom/Point.d.ts +213 -0
  260. package/dist/player/next2d/geom/Point.js +276 -0
  261. package/dist/player/next2d/geom/Rectangle.d.ts +364 -0
  262. package/dist/player/next2d/geom/Rectangle.js +517 -0
  263. package/dist/player/next2d/geom/Transform.d.ts +213 -0
  264. package/dist/player/next2d/geom/Transform.js +497 -0
  265. package/dist/player/next2d/media/Sound.d.ts +208 -0
  266. package/dist/player/next2d/media/Sound.js +515 -0
  267. package/dist/player/next2d/media/SoundMixer.d.ts +68 -0
  268. package/dist/player/next2d/media/SoundMixer.js +115 -0
  269. package/dist/player/next2d/media/SoundTransform.d.ts +80 -0
  270. package/dist/player/next2d/media/SoundTransform.js +113 -0
  271. package/dist/player/next2d/media/Video.d.ts +329 -0
  272. package/dist/player/next2d/media/Video.js +871 -0
  273. package/dist/player/next2d/net/URLRequest.d.ts +143 -0
  274. package/dist/player/next2d/net/URLRequest.js +239 -0
  275. package/dist/player/next2d/net/URLRequestHeader.d.ts +82 -0
  276. package/dist/player/next2d/net/URLRequestHeader.js +107 -0
  277. package/dist/player/next2d/text/TextField.d.ts +642 -0
  278. package/dist/player/next2d/text/TextField.js +2707 -0
  279. package/dist/player/next2d/text/TextFormat.d.ts +250 -0
  280. package/dist/player/next2d/text/TextFormat.js +473 -0
  281. package/dist/player/next2d/ui/Easing.d.ts +359 -0
  282. package/dist/player/next2d/ui/Easing.js +481 -0
  283. package/dist/player/next2d/ui/Job.d.ts +155 -0
  284. package/dist/player/next2d/ui/Job.js +344 -0
  285. package/dist/player/next2d/ui/Tween.d.ts +62 -0
  286. package/dist/player/next2d/ui/Tween.js +72 -0
  287. package/dist/player/packages/Display.d.ts +3 -0
  288. package/dist/player/packages/Display.js +36 -0
  289. package/dist/player/packages/Events.d.ts +3 -0
  290. package/dist/player/packages/Events.js +28 -0
  291. package/dist/player/packages/Filters.d.ts +3 -0
  292. package/dist/player/packages/Filters.js +28 -0
  293. package/dist/player/packages/Geom.d.ts +3 -0
  294. package/dist/player/packages/Geom.js +20 -0
  295. package/dist/player/packages/Media.d.ts +3 -0
  296. package/dist/player/packages/Media.js +18 -0
  297. package/dist/player/packages/Net.d.ts +3 -0
  298. package/dist/player/packages/Net.js +14 -0
  299. package/dist/player/packages/Text.d.ts +3 -0
  300. package/dist/player/packages/Text.js +14 -0
  301. package/dist/player/packages/UI.d.ts +3 -0
  302. package/dist/player/packages/UI.js +16 -0
  303. package/dist/player/player/Next2D.d.ts +71 -0
  304. package/dist/player/player/Next2D.js +206 -0
  305. package/dist/player/player/Player.d.ts +334 -0
  306. package/dist/player/player/Player.js +1912 -0
  307. package/dist/player/util/CacheStore.d.ts +115 -0
  308. package/dist/player/util/CacheStore.js +280 -0
  309. package/dist/player/util/Global.d.ts +23 -0
  310. package/dist/player/util/Global.js +67 -0
  311. package/dist/player/util/RenderUtil.d.ts +472 -0
  312. package/dist/player/util/RenderUtil.js +686 -0
  313. package/dist/player/util/Shortcut.d.ts +28 -0
  314. package/dist/player/util/Shortcut.js +28 -0
  315. package/dist/player/util/Util.d.ts +337 -0
  316. package/dist/player/util/Util.js +841 -0
  317. package/dist/renderer/RenderDisplayObject.d.ts +129 -0
  318. package/dist/renderer/RenderDisplayObject.js +567 -0
  319. package/dist/renderer/RenderDisplayObjectContainer.d.ts +70 -0
  320. package/dist/renderer/RenderDisplayObjectContainer.js +670 -0
  321. package/dist/renderer/RenderGlobal.d.ts +76 -0
  322. package/dist/renderer/RenderGlobal.js +88 -0
  323. package/dist/renderer/RenderGraphics.d.ts +90 -0
  324. package/dist/renderer/RenderGraphics.js +597 -0
  325. package/dist/renderer/RenderPlayer.d.ts +164 -0
  326. package/dist/renderer/RenderPlayer.js +421 -0
  327. package/dist/renderer/RenderShape.d.ts +32 -0
  328. package/dist/renderer/RenderShape.js +104 -0
  329. package/dist/renderer/RenderTextField.d.ts +119 -0
  330. package/dist/renderer/RenderTextField.js +709 -0
  331. package/dist/renderer/RenderVideo.d.ts +59 -0
  332. package/dist/renderer/RenderVideo.js +272 -0
  333. package/dist/webgl/BezierConverter.d.ts +59 -0
  334. package/dist/webgl/BezierConverter.js +107 -0
  335. package/dist/webgl/CanvasGradientToWebGL.d.ts +94 -0
  336. package/dist/webgl/CanvasGradientToWebGL.js +187 -0
  337. package/dist/webgl/CanvasPatternToWebGL.d.ts +39 -0
  338. package/dist/webgl/CanvasPatternToWebGL.js +70 -0
  339. package/dist/webgl/CanvasToWebGLContext.d.ts +596 -0
  340. package/dist/webgl/CanvasToWebGLContext.js +1453 -0
  341. package/dist/webgl/CanvasToWebGLContextBlend.d.ts +97 -0
  342. package/dist/webgl/CanvasToWebGLContextBlend.js +303 -0
  343. package/dist/webgl/CanvasToWebGLContextGrid.d.ts +74 -0
  344. package/dist/webgl/CanvasToWebGLContextGrid.js +314 -0
  345. package/dist/webgl/CanvasToWebGLContextMask.d.ts +113 -0
  346. package/dist/webgl/CanvasToWebGLContextMask.js +443 -0
  347. package/dist/webgl/CanvasToWebGLContextPath.d.ts +111 -0
  348. package/dist/webgl/CanvasToWebGLContextPath.js +213 -0
  349. package/dist/webgl/CanvasToWebGLContextStyle.d.ts +77 -0
  350. package/dist/webgl/CanvasToWebGLContextStyle.js +145 -0
  351. package/dist/webgl/ColorBufferPool.d.ts +58 -0
  352. package/dist/webgl/ColorBufferPool.js +137 -0
  353. package/dist/webgl/FrameBufferManager.d.ts +135 -0
  354. package/dist/webgl/FrameBufferManager.js +367 -0
  355. package/dist/webgl/StencilBufferPool.d.ts +56 -0
  356. package/dist/webgl/StencilBufferPool.js +147 -0
  357. package/dist/webgl/TextureManager.d.ts +130 -0
  358. package/dist/webgl/TextureManager.js +303 -0
  359. package/dist/webgl/VertexArrayObjectManager.d.ts +95 -0
  360. package/dist/webgl/VertexArrayObjectManager.js +289 -0
  361. package/dist/webgl/WebGLFillMeshGenerator.d.ts +31 -0
  362. package/dist/webgl/WebGLFillMeshGenerator.js +104 -0
  363. package/dist/webgl/WebGLStrokeMeshGenerator.d.ts +182 -0
  364. package/dist/webgl/WebGLStrokeMeshGenerator.js +510 -0
  365. package/dist/webgl/shader/CanvasToWebGLShader.d.ts +85 -0
  366. package/dist/webgl/shader/CanvasToWebGLShader.js +196 -0
  367. package/dist/webgl/shader/CanvasToWebGLShaderList.d.ts +70 -0
  368. package/dist/webgl/shader/CanvasToWebGLShaderList.js +115 -0
  369. package/dist/webgl/shader/GradientLUTGenerator.d.ts +36 -0
  370. package/dist/webgl/shader/GradientLUTGenerator.js +129 -0
  371. package/dist/webgl/shader/WebGLShaderUniform.d.ts +52 -0
  372. package/dist/webgl/shader/WebGLShaderUniform.js +168 -0
  373. package/dist/webgl/shader/fragment/FragmentShaderLibrary.d.ts +18 -0
  374. package/dist/webgl/shader/fragment/FragmentShaderLibrary.js +35 -0
  375. package/dist/webgl/shader/fragment/FragmentShaderSource.d.ts +29 -0
  376. package/dist/webgl/shader/fragment/FragmentShaderSource.js +99 -0
  377. package/dist/webgl/shader/fragment/FragmentShaderSourceBlend.d.ts +67 -0
  378. package/dist/webgl/shader/fragment/FragmentShaderSourceBlend.js +319 -0
  379. package/dist/webgl/shader/fragment/FragmentShaderSourceGradient.d.ts +44 -0
  380. package/dist/webgl/shader/fragment/FragmentShaderSourceGradient.js +114 -0
  381. package/dist/webgl/shader/fragment/FragmentShaderSourceGradientLUT.d.ts +14 -0
  382. package/dist/webgl/shader/fragment/FragmentShaderSourceGradientLUT.js +58 -0
  383. package/dist/webgl/shader/fragment/FragmentShaderSourceTexture.d.ts +12 -0
  384. package/dist/webgl/shader/fragment/FragmentShaderSourceTexture.js +36 -0
  385. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceBlurFilter.d.ts +12 -0
  386. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceBlurFilter.js +42 -0
  387. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.d.ts +11 -0
  388. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceColorMatrixFilter.js +35 -0
  389. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.d.ts +16 -0
  390. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceConvolutionFilter.js +80 -0
  391. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.d.ts +15 -0
  392. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceDisplacementMapFilter.js +106 -0
  393. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceFilter.d.ts +112 -0
  394. package/dist/webgl/shader/fragment/filter/FragmentShaderSourceFilter.js +275 -0
  395. package/dist/webgl/shader/variants/BlendShaderVariantCollection.d.ts +99 -0
  396. package/dist/webgl/shader/variants/BlendShaderVariantCollection.js +242 -0
  397. package/dist/webgl/shader/variants/FilterShaderVariantCollection.d.ts +150 -0
  398. package/dist/webgl/shader/variants/FilterShaderVariantCollection.js +398 -0
  399. package/dist/webgl/shader/variants/GradientLUTShaderVariantCollection.d.ts +49 -0
  400. package/dist/webgl/shader/variants/GradientLUTShaderVariantCollection.js +110 -0
  401. package/dist/webgl/shader/variants/GradientShapeShaderVariantCollection.d.ts +61 -0
  402. package/dist/webgl/shader/variants/GradientShapeShaderVariantCollection.js +199 -0
  403. package/dist/webgl/shader/variants/ShapeShaderVariantCollection.d.ts +117 -0
  404. package/dist/webgl/shader/variants/ShapeShaderVariantCollection.js +430 -0
  405. package/dist/webgl/shader/vertex/VertexShaderLibrary.d.ts +18 -0
  406. package/dist/webgl/shader/vertex/VertexShaderLibrary.js +75 -0
  407. package/dist/webgl/shader/vertex/VertexShaderSource.d.ts +23 -0
  408. package/dist/webgl/shader/vertex/VertexShaderSource.js +92 -0
  409. package/dist/webgl/shader/vertex/VertexShaderSourceFill.d.ts +45 -0
  410. package/dist/webgl/shader/vertex/VertexShaderSourceFill.js +112 -0
  411. package/dist/webgl/shader/vertex/VertexShaderSourceStroke.d.ts +27 -0
  412. package/dist/webgl/shader/vertex/VertexShaderSourceStroke.js +149 -0
  413. package/package.json +31 -25
  414. package/SECURITY.md +0 -3
  415. package/next2d.js +0 -7
@@ -0,0 +1,2707 @@
1
+ import { InteractiveObject } from "../display/InteractiveObject";
2
+ import { TextFormat } from "./TextFormat";
3
+ import { FocusEvent } from "../events/FocusEvent";
4
+ import { Event as Next2DEvent } from "../events/Event";
5
+ import { MouseEvent as Next2DMouseEvent } from "../events/MouseEvent";
6
+ import { Sprite } from "../display/Sprite";
7
+ import { Tween } from "../ui/Tween";
8
+ import { Rectangle } from "../geom/Rectangle";
9
+ import { $doUpdated } from "../../util/Global";
10
+ import { $currentPlayer, $DIV, $isSafari, $MOUSE_DOWN, $MOUSE_UP, $MOUSE_WHEEL, $P_TAG, $PREFIX, $rendererWorker, $SCROLL, $textContext, $TOUCH_END, $TOUCH_START } from "../../util/Util";
11
+ import { $devicePixelRatio, $document, $RegExp } from "../../util/Shortcut";
12
+ import { $clamp, $getArray, $intToRGBA, $isNaN, $Math, $requestAnimationFrame, $toColorInt, $getMap, $poolFloat32Array6, $boundsMatrix, $multiplicationMatrix, $poolBoundsObject, $multiplicationColor, $Infinity, $Number, $poolArray, $poolFloat32Array8, $generateFontStyle, $getBoundsObject } from "../../util/RenderUtil";
13
+ /**
14
+ * TextField クラスは、テキストの表示と入力用の表示オブジェクトを作成するために使用されます。
15
+ * プロパティインスペクターを使用して、テキストフィールドにインスタンス名を付けることができます。
16
+ * また、TextField クラスのメソッドとプロパティを使用して、JavaScript でテキストフィールドを操作できます。
17
+ *
18
+ * The TextField class is used to create display objects for text display and input.
19
+ * You can give a text field an instance name in the Property inspector
20
+ * and use the methods and properties of the TextField class to manipulate it with JavaScript.
21
+ *
22
+ * @class
23
+ * @memberOf next2d.text
24
+ * @extends InteractiveObject
25
+ */
26
+ export class TextField extends InteractiveObject {
27
+ _$bounds;
28
+ _$originBounds;
29
+ _$textData;
30
+ _$widthTable;
31
+ _$heightTable;
32
+ _$textFormatTable;
33
+ _$objectTable;
34
+ _$imageData;
35
+ _$textHeightTable;
36
+ _$heightCache;
37
+ _$background;
38
+ _$backgroundColor;
39
+ _$border;
40
+ _$borderColor;
41
+ _$htmlText;
42
+ _$multiline;
43
+ _$text;
44
+ _$wordWrap;
45
+ _$scrollH;
46
+ _$scrollV;
47
+ _$maxScrollV;
48
+ _$maxScrollH;
49
+ _$maxChars;
50
+ _$defaultTextFormat;
51
+ _$rawHtmlText;
52
+ _$restrict;
53
+ _$isHTML;
54
+ _$textHeight;
55
+ _$textWidth;
56
+ _$textarea;
57
+ _$autoSize;
58
+ _$autoFontSize;
59
+ _$textAreaActive;
60
+ _$totalWidth;
61
+ _$scrollEnabled;
62
+ _$scrollSprite;
63
+ _$type;
64
+ _$focus;
65
+ _$isComposing;
66
+ _$thickness;
67
+ _$thicknessColor;
68
+ _$verticalAlign;
69
+ _$createdTextData;
70
+ /**
71
+ * @constructor
72
+ * @public
73
+ */
74
+ constructor() {
75
+ super();
76
+ /**
77
+ * @type {boolean}
78
+ * @default false
79
+ * @private
80
+ */
81
+ this._$background = false;
82
+ /**
83
+ * @type {number}
84
+ * @default 0xffffff
85
+ * @private
86
+ */
87
+ this._$backgroundColor = 0xffffff;
88
+ /**
89
+ * @type {boolean}
90
+ * @default false
91
+ * @private
92
+ */
93
+ this._$border = false;
94
+ /**
95
+ * @type {number}
96
+ * @default 0x000000
97
+ * @private
98
+ */
99
+ this._$borderColor = 0x000000;
100
+ /**
101
+ * @type {string}
102
+ * @default ""
103
+ * @private
104
+ */
105
+ this._$htmlText = "";
106
+ /**
107
+ * @type {boolean}
108
+ * @default false
109
+ * @private
110
+ */
111
+ this._$multiline = false;
112
+ /**
113
+ * @type {string}
114
+ * @default ""
115
+ * @private
116
+ */
117
+ this._$text = "";
118
+ /**
119
+ * @type {boolean}
120
+ * @default false
121
+ * @private
122
+ */
123
+ this._$wordWrap = false;
124
+ /**
125
+ * @type {number}
126
+ * @default 0
127
+ * @private
128
+ */
129
+ this._$scrollH = 0;
130
+ /**
131
+ * @type {number}
132
+ * @default 1
133
+ * @private
134
+ */
135
+ this._$scrollV = 1;
136
+ /**
137
+ * @type {number}
138
+ * @default null
139
+ * @private
140
+ */
141
+ this._$maxScrollV = null;
142
+ /**
143
+ * @type {number}
144
+ * @default null
145
+ * @private
146
+ */
147
+ this._$maxScrollH = null;
148
+ /**
149
+ * @type {number}
150
+ * @default 0
151
+ * @private
152
+ */
153
+ this._$maxChars = 0;
154
+ // TextFormat
155
+ const textFormat = new TextFormat();
156
+ textFormat._$setDefault();
157
+ /**
158
+ * @type {TextFormat}
159
+ * @private
160
+ */
161
+ this._$defaultTextFormat = textFormat;
162
+ /**
163
+ * @type {string}
164
+ * @default ""
165
+ * @private
166
+ */
167
+ this._$rawHtmlText = "";
168
+ /**
169
+ * @type {object}
170
+ * @private
171
+ */
172
+ this._$bounds = {
173
+ "xMin": 0,
174
+ "xMax": 100,
175
+ "yMin": 0,
176
+ "yMax": 100
177
+ };
178
+ /**
179
+ * @type {object}
180
+ * @private
181
+ */
182
+ this._$originBounds = {
183
+ "xMin": 0,
184
+ "xMax": 100,
185
+ "yMin": 0,
186
+ "yMax": 100
187
+ };
188
+ /**
189
+ * @type {string}
190
+ * @default null
191
+ * @private
192
+ */
193
+ this._$restrict = "";
194
+ /**
195
+ * @type {boolean}
196
+ * @default false
197
+ * @private
198
+ */
199
+ this._$isHTML = false;
200
+ /**
201
+ * @type {boolean}
202
+ * @default false
203
+ * @private
204
+ */
205
+ this._$createdTextData = false;
206
+ /**
207
+ * @type {array}
208
+ * @private
209
+ */
210
+ this._$textData = $getArray();
211
+ /**
212
+ * @type {number}
213
+ * @default null
214
+ * @private
215
+ */
216
+ this._$textHeight = null;
217
+ /**
218
+ * @type {number}
219
+ * @default null
220
+ * @private
221
+ */
222
+ this._$textWidth = null;
223
+ /**
224
+ * @type {array}
225
+ * @private
226
+ */
227
+ this._$widthTable = $getArray();
228
+ /**
229
+ * @type {HTMLTextAreaElement}
230
+ * @default null
231
+ * @private
232
+ */
233
+ this._$textarea = null;
234
+ /**
235
+ * @type {string}
236
+ * @default TextFieldAutoSize.NONE
237
+ * @private
238
+ */
239
+ this._$autoSize = "none";
240
+ /**
241
+ * @type {boolean}
242
+ * @default false
243
+ * @private
244
+ */
245
+ this._$autoFontSize = false;
246
+ /**
247
+ * @type {array}
248
+ * @default null
249
+ * @private
250
+ */
251
+ this._$heightTable = $getArray();
252
+ /**
253
+ * @type {array}
254
+ * @private
255
+ */
256
+ this._$textFormatTable = $getArray();
257
+ /**
258
+ * @type {boolean}
259
+ * @default false
260
+ * @private
261
+ */
262
+ this._$textAreaActive = false;
263
+ /**
264
+ * @type {number}
265
+ * @default 0
266
+ * @private
267
+ */
268
+ this._$totalWidth = 0;
269
+ /**
270
+ * @type {array}
271
+ * @private
272
+ */
273
+ this._$objectTable = $getArray();
274
+ /**
275
+ * @type {array}
276
+ * @private
277
+ */
278
+ this._$imageData = $getArray();
279
+ /**
280
+ * @type {boolean}
281
+ * @default true
282
+ * @private
283
+ */
284
+ this._$scrollEnabled = true;
285
+ /**
286
+ * @type {Sprite}
287
+ * @default null
288
+ * @private
289
+ */
290
+ this._$scrollSprite = null;
291
+ /**
292
+ * @type {string}
293
+ * @default null
294
+ * @private
295
+ */
296
+ this._$type = "static";
297
+ /**
298
+ * @type {array}
299
+ * @default null
300
+ * @private
301
+ */
302
+ this._$textHeightTable = $getArray();
303
+ /**
304
+ * @type {boolean}
305
+ * @default false
306
+ * @private
307
+ */
308
+ this._$focus = false;
309
+ /**
310
+ * @type {boolean}
311
+ * @default false
312
+ * @private
313
+ */
314
+ this._$isComposing = false;
315
+ /**
316
+ * @type {number}
317
+ * @default 0
318
+ * @private
319
+ */
320
+ this._$thickness = 0;
321
+ /**
322
+ * @type {number}
323
+ * @default 0
324
+ * @private
325
+ */
326
+ this._$thicknessColor = 0;
327
+ /**
328
+ * @type {string}
329
+ * @default TextFormatVerticalAlign.TOP
330
+ * @private
331
+ */
332
+ this._$verticalAlign = "top";
333
+ /**
334
+ * @type {Map}
335
+ * @private
336
+ */
337
+ this._$heightCache = $getMap();
338
+ }
339
+ /**
340
+ * @description 指定されたクラスのストリングを返します。
341
+ * Returns the string representation of the specified class.
342
+ *
343
+ * @return {string}
344
+ * @default [class TextField]
345
+ * @method
346
+ * @static
347
+ */
348
+ static toString() {
349
+ return "[class TextField]";
350
+ }
351
+ /**
352
+ * @description 指定されたクラスの空間名を返します。
353
+ * Returns the space name of the specified class.
354
+ *
355
+ * @return {string}
356
+ * @default next2d.text.TextField
357
+ * @const
358
+ * @static
359
+ */
360
+ static get namespace() {
361
+ return "next2d.text.TextField";
362
+ }
363
+ /**
364
+ * @description 指定されたオブジェクトのストリングを返します。
365
+ * Returns the string representation of the specified object.
366
+ *
367
+ * @return {string}
368
+ * @default [object TextField]
369
+ * @method
370
+ * @public
371
+ */
372
+ toString() {
373
+ return "[object TextField]";
374
+ }
375
+ /**
376
+ * @description 指定されたオブジェクトの空間名を返します。
377
+ * Returns the space name of the specified object.
378
+ *
379
+ * @return {string}
380
+ * @default next2d.text.TextField
381
+ * @const
382
+ * @public
383
+ */
384
+ get namespace() {
385
+ return "next2d.text.TextField";
386
+ }
387
+ /**
388
+ * @description テキストサイズの自動的な拡大 / 縮小および整列を制御します。
389
+ * Controls automatic sizing and alignment of text size.
390
+ *
391
+ * @member {boolean}
392
+ * @default false
393
+ * @public
394
+ */
395
+ get autoFontSize() {
396
+ return this._$autoFontSize;
397
+ }
398
+ set autoFontSize(auto_font_size) {
399
+ if (auto_font_size !== this._$autoFontSize) {
400
+ this._$autoFontSize = auto_font_size;
401
+ this._$reload();
402
+ }
403
+ }
404
+ /**
405
+ * @description テキストフィールドの自動的な拡大 / 縮小および整列を制御します。
406
+ * Controls automatic sizing and alignment of text fields.
407
+ *
408
+ * @member {string}
409
+ * @default TextFieldAutoSize.NONE
410
+ * @public
411
+ */
412
+ get autoSize() {
413
+ return this._$autoSize;
414
+ }
415
+ set autoSize(auto_size) {
416
+ if (auto_size !== this._$autoSize) {
417
+ this._$autoSize = auto_size;
418
+ this._$reload();
419
+ }
420
+ }
421
+ /**
422
+ * @description テキストフィールドに背景の塗りつぶしがあるかどうかを指定します。
423
+ * Specifies whether the text field has a background fill.
424
+ *
425
+ * @member {boolean}
426
+ * @default false
427
+ * @public
428
+ */
429
+ get background() {
430
+ return this._$background;
431
+ }
432
+ set background(background) {
433
+ if (background !== this._$background) {
434
+ this._$background = !!background;
435
+ this._$reset();
436
+ }
437
+ }
438
+ /**
439
+ * @description テキストフィールドの背景の色です。
440
+ * The color of the text field background.
441
+ *
442
+ * @member {number}
443
+ * @default 0xffffff
444
+ * @public
445
+ */
446
+ get backgroundColor() {
447
+ return this._$backgroundColor;
448
+ }
449
+ set backgroundColor(background_color) {
450
+ background_color = $clamp($toColorInt(background_color), 0, 0xffffff, 0xffffff);
451
+ if (background_color !== this._$backgroundColor) {
452
+ this._$backgroundColor = background_color;
453
+ this._$reset();
454
+ }
455
+ }
456
+ /**
457
+ * @description テキストフィールドに境界線があるかどうかを指定します。
458
+ * Specifies whether the text field has a border.
459
+ *
460
+ * @member {boolean}
461
+ * @default false
462
+ * @public
463
+ */
464
+ get border() {
465
+ return this._$border;
466
+ }
467
+ set border(border) {
468
+ if (border !== this._$border) {
469
+ this._$border = !!border;
470
+ this._$reset();
471
+ }
472
+ }
473
+ /**
474
+ * @description テキストフィールドの境界線の色です。
475
+ * The color of the text field border.
476
+ *
477
+ * @member {number}
478
+ * @default 0x000000
479
+ * @public
480
+ */
481
+ get borderColor() {
482
+ return this._$borderColor;
483
+ }
484
+ set borderColor(border_color) {
485
+ border_color = $clamp($toColorInt(border_color), 0, 0xffffff, 0);
486
+ if (border_color !== this._$borderColor) {
487
+ this._$borderColor = border_color;
488
+ this._$reset();
489
+ }
490
+ }
491
+ /**
492
+ * @description テキストに適用するフォーマットを指定します。
493
+ * Specifies the formatting to be applied to the text.
494
+ *
495
+ * @member {TextFormat}
496
+ * @public
497
+ */
498
+ get defaultTextFormat() {
499
+ return this._$defaultTextFormat._$clone();
500
+ }
501
+ set defaultTextFormat(text_format) {
502
+ text_format._$merge(this._$defaultTextFormat);
503
+ this._$defaultTextFormat = text_format;
504
+ this._$reset();
505
+ }
506
+ /**
507
+ * @description このオブジェクトでマウスまたはその他のユーザー入力メッセージを
508
+ *
509
+ * @member {boolean}
510
+ * @default false
511
+ * @public
512
+ */
513
+ get focus() {
514
+ return this._$focus;
515
+ }
516
+ set focus(focus) {
517
+ if (this._$focus === focus) {
518
+ return;
519
+ }
520
+ this._$focus = focus;
521
+ if (this._$focus) {
522
+ if (this._$type === "input") {
523
+ const player = $currentPlayer();
524
+ const div = $document
525
+ .getElementById(player.contentElementId);
526
+ if (!div) {
527
+ return;
528
+ }
529
+ this._$createTextAreaElement(player._$scale);
530
+ // setup
531
+ const element = this._$textarea;
532
+ if (!element) {
533
+ return;
534
+ }
535
+ const matrix = this._$transform.concatenatedMatrix;
536
+ const bounds = this._$getBounds(null);
537
+ const color = $intToRGBA($toColorInt(this._$defaultTextFormat.color), 100);
538
+ element.style.color = `rgb(${color.R},${color.G},${color.B})`;
539
+ element.style.left = `${(matrix.tx + bounds.xMin + player.x / player._$scale / $devicePixelRatio) * player._$scale}px`;
540
+ element.style.top = `${(matrix.ty + bounds.yMin + player.y / player._$scale / $devicePixelRatio) * player._$scale}px`;
541
+ element.style.width = `${$Math.ceil((this.width - 1) * player._$scale)}px`;
542
+ element.style.height = `${$Math.ceil((this.height - 1) * player._$scale)}px`;
543
+ // set text
544
+ element.value = this.text;
545
+ div.appendChild(element);
546
+ $requestAnimationFrame(() => {
547
+ element.focus();
548
+ });
549
+ this._$doChanged();
550
+ $doUpdated();
551
+ this._$textAreaActive = true;
552
+ // focus in event
553
+ if (this.willTrigger(FocusEvent.FOCUS_IN)) {
554
+ this.dispatchEvent(new FocusEvent(FocusEvent.FOCUS_IN));
555
+ }
556
+ }
557
+ }
558
+ else {
559
+ // execute
560
+ if (this._$textarea) {
561
+ this._$textarea.dispatchEvent(new Event(`${$PREFIX}_blur`));
562
+ if (this.willTrigger(FocusEvent.FOCUS_OUT)) {
563
+ this.dispatchEvent(new FocusEvent(FocusEvent.FOCUS_OUT));
564
+ }
565
+ this._$textarea.remove();
566
+ }
567
+ }
568
+ }
569
+ /**
570
+ * @description テキストフィールドの内容を HTML で表します。
571
+ * Contains the HTML representation of the text field contents.
572
+ *
573
+ * @member {string}
574
+ * @default ""
575
+ * @public
576
+ */
577
+ get htmlText() {
578
+ return this._$htmlText;
579
+ }
580
+ set htmlText(html_text) {
581
+ if (this._$htmlText !== html_text) {
582
+ this._$htmlText = `${html_text}`;
583
+ this._$rawHtmlText = "";
584
+ this._$text = "";
585
+ this._$isHTML = true;
586
+ this._$textFormatTable.length = 0;
587
+ this._$reload();
588
+ }
589
+ }
590
+ /**
591
+ * @description テキストフィールド内の文字数です。
592
+ * The int of characters in a text field.
593
+ *
594
+ * @member {number}
595
+ * @readonly
596
+ * @public
597
+ */
598
+ get length() {
599
+ return this.text.length;
600
+ }
601
+ /**
602
+ * @description ユーザーが入力するときに、テキストフィールドに入力できる最大の文字数です。
603
+ * The maximum number of characters that the text field can contain,
604
+ * as entered by a user.
605
+ *
606
+ * @member {number}
607
+ * @default 0
608
+ * @public
609
+ */
610
+ get maxChars() {
611
+ return this._$maxChars;
612
+ }
613
+ set maxChars(max_chars) {
614
+ this._$maxChars = max_chars | 0;
615
+ }
616
+ /**
617
+ * TODO
618
+ * @description scrollH の最大値です。
619
+ * The maximum value of scrollH.
620
+ *
621
+ * @member {number}
622
+ * @readonly
623
+ * @public
624
+ */
625
+ get maxScrollH() {
626
+ if (this._$maxScrollH === null) {
627
+ this._$maxScrollH = 0;
628
+ }
629
+ return this._$maxScrollH;
630
+ }
631
+ /**
632
+ * @description scrollV の最大値です。
633
+ * The maximum value of scrollV.
634
+ *
635
+ * @member {number}
636
+ * @readonly
637
+ * @public
638
+ */
639
+ get maxScrollV() {
640
+ if (this._$maxScrollV === null) {
641
+ this._$maxScrollV = 1;
642
+ this._$getTextData();
643
+ if (!this._$textHeightTable.length) {
644
+ return this._$maxScrollV;
645
+ }
646
+ const length = this._$textHeightTable.length;
647
+ const maxHeight = this.height;
648
+ if (maxHeight > this.textHeight) {
649
+ return this._$maxScrollV;
650
+ }
651
+ let textHeight = 0;
652
+ let idx = 0;
653
+ while (length > idx) {
654
+ textHeight += this._$textHeightTable[idx++];
655
+ if (textHeight > maxHeight) {
656
+ break;
657
+ }
658
+ this._$maxScrollV++;
659
+ }
660
+ }
661
+ return this._$maxScrollV;
662
+ }
663
+ /**
664
+ * @description フィールドが複数行テキストフィールドであるかどうかを示します。
665
+ * Indicates whether field is a multiline text field.
666
+ *
667
+ * @member {boolean}
668
+ * @default false
669
+ * @public
670
+ */
671
+ get multiline() {
672
+ return this._$multiline;
673
+ }
674
+ set multiline(multiline) {
675
+ if (multiline !== this._$multiline) {
676
+ this._$multiline = !!multiline;
677
+ this._$reset();
678
+ }
679
+ }
680
+ /**
681
+ * @description フィールドが複数行テキストフィールドであるかどうかを示します。
682
+ * Indicates whether field is a multiline text field.
683
+ *
684
+ * @member {number}
685
+ * @readonly
686
+ * @public
687
+ */
688
+ get numLines() {
689
+ if (!this._$createdTextData) {
690
+ this._$getTextData();
691
+ }
692
+ return this._$objectTable.length;
693
+ }
694
+ /**
695
+ * @description ユーザーがテキストフィールドに入力できる文字のセットを指定します。
696
+ * Indicates the set of characters that a user can enter into the text field.
697
+ *
698
+ * @member {string}
699
+ * @default null
700
+ * @public
701
+ */
702
+ get restrict() {
703
+ return this._$restrict;
704
+ }
705
+ set restrict(restrict) {
706
+ this._$restrict = `${restrict}`;
707
+ }
708
+ /**
709
+ * @description スクロール機能のON/OFFの制御。
710
+ * Control ON/OFF of the scroll function.
711
+ *
712
+ * @member {boolean}
713
+ * @default true
714
+ * @public
715
+ */
716
+ get scrollEnabled() {
717
+ return this._$scrollEnabled;
718
+ }
719
+ set scrollEnabled(scroll_enabled) {
720
+ this._$scrollEnabled = scroll_enabled;
721
+ }
722
+ /**
723
+ * TODO
724
+ * @description 現在の水平スクロール位置です。
725
+ * The current horizontal scrolling position.
726
+ *
727
+ * @member {number}
728
+ * @public
729
+ */
730
+ get scrollH() {
731
+ return this._$scrollH;
732
+ }
733
+ set scrollH(scroll_h) {
734
+ scroll_h = $clamp(scroll_h | 0, 0, this.maxScrollH);
735
+ if (this._$scrollH !== scroll_h) {
736
+ this._$scrollH = scroll_h;
737
+ this._$reset();
738
+ if (this.willTrigger(Next2DEvent.SCROLL)) {
739
+ this.dispatchEvent(new Next2DEvent(Next2DEvent.SCROLL, true));
740
+ }
741
+ }
742
+ }
743
+ /**
744
+ * @description テキストフィールドのテキストの垂直位置です。
745
+ * The vertical position of text in a text field.
746
+ *
747
+ * @member {number}
748
+ * @public
749
+ */
750
+ get scrollV() {
751
+ return this._$scrollV;
752
+ }
753
+ set scrollV(scroll_v) {
754
+ scroll_v = $clamp(scroll_v | 0, 1, this.maxScrollV);
755
+ if (this._$scrollV !== scroll_v) {
756
+ this._$scrollV = $Math.max(1, scroll_v);
757
+ this._$reset();
758
+ if (this._$scrollSprite && this.textHeight > this.height) {
759
+ this._$scrollSprite.height = this.height * this.height / this.textHeight - 1;
760
+ const parent = this._$parent;
761
+ if (parent) {
762
+ // view start
763
+ this._$scrollSprite.alpha = 1;
764
+ // set position
765
+ this._$scrollSprite.x = this.x + this.width - this._$scrollSprite.width - 0.5;
766
+ this._$scrollSprite.y = this.y + 0.5
767
+ + (this.height - 1 - this._$scrollSprite.height)
768
+ / (this.maxScrollV - 1)
769
+ * (this._$scrollV - 1);
770
+ // added sprite
771
+ parent.addChildAt(this._$scrollSprite, parent.getChildIndex(this) + 1);
772
+ // start animation
773
+ if (this._$scrollSprite.hasLocalVariable("job")) {
774
+ this._$scrollSprite.getLocalVariable("job").stop();
775
+ }
776
+ const job = Tween.add(this._$scrollSprite, { "alpha": 1 }, { "alpha": 0 }, 1);
777
+ job.addEventListener(Next2DEvent.COMPLETE, (event) => {
778
+ const sprite = event.target.target;
779
+ sprite.deleteLocalVariable("job");
780
+ if (sprite.parent) {
781
+ sprite.parent.removeChild(sprite);
782
+ }
783
+ });
784
+ job.start();
785
+ this._$scrollSprite.setLocalVariable("job", job);
786
+ }
787
+ }
788
+ if (this.willTrigger(Next2DEvent.SCROLL)) {
789
+ this.dispatchEvent(new Next2DEvent(Next2DEvent.SCROLL, true));
790
+ }
791
+ }
792
+ }
793
+ /**
794
+ * @description テキストフィールド内の現在のテキストであるストリングです。
795
+ * A string that is the current text in the text field.
796
+ *
797
+ * @member {string}
798
+ * @default ""
799
+ * @public
800
+ */
801
+ get text() {
802
+ if (!this._$isHTML) {
803
+ return this._$text;
804
+ }
805
+ if (this._$rawHtmlText) {
806
+ return this._$rawHtmlText;
807
+ }
808
+ let text = "";
809
+ const textData = this._$getTextData();
810
+ for (let idx = 1; idx < textData.length; ++idx) {
811
+ const object = textData[idx];
812
+ switch (object.mode) {
813
+ case "text":
814
+ text += object.text;
815
+ break;
816
+ case "break":
817
+ text += "\r";
818
+ break;
819
+ }
820
+ }
821
+ this._$rawHtmlText = text;
822
+ return text;
823
+ }
824
+ set text(text) {
825
+ if (text === null) {
826
+ text = "";
827
+ }
828
+ text = `${text}`;
829
+ if (text !== this._$text) {
830
+ this._$text = text;
831
+ this._$htmlText = "";
832
+ this._$isHTML = false;
833
+ this._$textFormatTable.length = 0;
834
+ this._$reload();
835
+ }
836
+ }
837
+ /**
838
+ * @description テキストフィールドのテキストの色です(16 進数形式)。
839
+ * The color of the text in a text field, in hexadecimal format.
840
+ *
841
+ * @member {number}
842
+ * @public
843
+ */
844
+ get textColor() {
845
+ return this._$defaultTextFormat.color || 0;
846
+ }
847
+ set textColor(text_color) {
848
+ this._$defaultTextFormat.color = text_color;
849
+ this._$reload();
850
+ }
851
+ /**
852
+ * @description テキストの高さです(ピクセル単位)。
853
+ * The height of the text in pixels.
854
+ *
855
+ * @member {number}
856
+ * @readonly
857
+ * @public
858
+ */
859
+ get textHeight() {
860
+ if (this.text === "") {
861
+ return 0;
862
+ }
863
+ if (this._$textHeight === null) {
864
+ // setup
865
+ this._$textHeight = 2;
866
+ this._$getTextData();
867
+ const length = this._$textHeightTable.length;
868
+ if (length === 1) {
869
+ this._$textHeight += this._$defaultTextFormat.leading || 0;
870
+ }
871
+ for (let idx = 0; idx < length; ++idx) {
872
+ this._$textHeight += this._$textHeightTable[idx];
873
+ }
874
+ }
875
+ return this._$textHeight;
876
+ }
877
+ /**
878
+ * @description テキストの幅です(ピクセル単位)。
879
+ * The width of the text in pixels.
880
+ *
881
+ * @member {number}
882
+ * @readonly
883
+ * @public
884
+ */
885
+ get textWidth() {
886
+ if (this._$textWidth === null) {
887
+ // setup
888
+ this._$textWidth = 0;
889
+ this._$getTextData();
890
+ for (let idx = 0; idx < this._$widthTable.length; ++idx) {
891
+ this._$textWidth = $Math.max(this._$textWidth, this._$widthTable[idx]);
892
+ }
893
+ }
894
+ return this._$textWidth;
895
+ }
896
+ /**
897
+ * @description 輪郭のテキスト幅です。0(デフォルト値)で無効にできます。
898
+ * The text width of the outline, which can be disabled with 0 (the default value).
899
+ *
900
+ * @member {number}
901
+ * @default 0
902
+ * @public
903
+ */
904
+ get thickness() {
905
+ return this._$thickness;
906
+ }
907
+ set thickness(thickness) {
908
+ thickness |= 0;
909
+ if (thickness !== this._$thickness) {
910
+ this._$thickness = thickness;
911
+ this._$reset();
912
+ }
913
+ }
914
+ /**
915
+ * @description 輪郭のテキストの色です(16 進数形式)。
916
+ * The color of the outline text. (Hexadecimal format)
917
+ *
918
+ * @member {number}
919
+ * @default 0
920
+ * @public
921
+ */
922
+ get thicknessColor() {
923
+ return this._$thicknessColor;
924
+ }
925
+ set thicknessColor(thickness_color) {
926
+ thickness_color = $clamp($toColorInt(thickness_color), 0, 0xffffff, 0);
927
+ if (thickness_color !== this._$thicknessColor) {
928
+ this._$thicknessColor = thickness_color;
929
+ this._$reset();
930
+ }
931
+ }
932
+ /**
933
+ * @description テキストフィールドのタイプです。
934
+ * The type of the text field.
935
+ *
936
+ * @member {string}
937
+ * @default TextFieldType.STATIC
938
+ * @public
939
+ */
940
+ get type() {
941
+ return this._$type;
942
+ }
943
+ set type(type) {
944
+ this._$type = type;
945
+ if (type === "static") {
946
+ this._$textarea = null;
947
+ }
948
+ }
949
+ /**
950
+ * @description 縦方向の揃え位置を指定するプロパティです。
951
+ * This property specifies the vertical alignment position.
952
+ *
953
+ * @member {string}
954
+ * @default TextFormatVerticalAlign.TOP
955
+ * @public
956
+ */
957
+ get verticalAlign() {
958
+ return this._$verticalAlign;
959
+ }
960
+ set verticalAlign(vertical_align) {
961
+ if (vertical_align !== this._$verticalAlign) {
962
+ this._$verticalAlign = vertical_align;
963
+ this._$reset();
964
+ }
965
+ }
966
+ /**
967
+ * @description テキストフィールドのテキストを折り返すかどうかを示すブール値です。
968
+ * A Boolean value that indicates whether the text field has word wrap.
969
+ *
970
+ * @member {boolean}
971
+ * @default false
972
+ * @public
973
+ */
974
+ get wordWrap() {
975
+ return this._$wordWrap;
976
+ }
977
+ set wordWrap(word_wrap) {
978
+ if (this._$wordWrap !== word_wrap) {
979
+ this._$wordWrap = !!word_wrap;
980
+ this._$reset();
981
+ }
982
+ }
983
+ /**
984
+ * @description 表示オブジェクトの幅を示します(ピクセル単位)。
985
+ * Indicates the width of the display object, in pixels.
986
+ *
987
+ * @member {number}
988
+ * @public
989
+ */
990
+ get width() {
991
+ return super.width;
992
+ }
993
+ set width(width) {
994
+ width = +width;
995
+ if (!$isNaN(width) && width > -1) {
996
+ const bounds = this._$getBounds(null);
997
+ const xMin = $Math.abs(bounds.xMin);
998
+ this._$originBounds.xMax = width + xMin;
999
+ this._$originBounds.xMin = xMin;
1000
+ this._$bounds.xMax = this._$originBounds.xMax;
1001
+ this._$bounds.xMin = this._$originBounds.xMin;
1002
+ super.width = width;
1003
+ this._$reload();
1004
+ }
1005
+ }
1006
+ /**
1007
+ * @description 表示オブジェクトの高さを示します(ピクセル単位)。
1008
+ * Indicates the height of the display object, in pixels.
1009
+ *
1010
+ * @member {number}
1011
+ * @public
1012
+ */
1013
+ get height() {
1014
+ return super.height;
1015
+ }
1016
+ set height(height) {
1017
+ height = +height;
1018
+ if (!$isNaN(height) && height > -1) {
1019
+ const bounds = this._$getBounds(null);
1020
+ const yMin = $Math.abs(bounds.yMin);
1021
+ this._$originBounds.yMax = height + yMin;
1022
+ this._$bounds.yMax = this._$originBounds.yMax;
1023
+ this._$bounds.yMin = this._$originBounds.yMin;
1024
+ super.height = height;
1025
+ this._$reload();
1026
+ }
1027
+ }
1028
+ /**
1029
+ * @description 親 DisplayObjectContainer のローカル座標を基準にした
1030
+ * DisplayObject インスタンスの x 座標を示します。
1031
+ * Indicates the x coordinate
1032
+ * of the DisplayObject instance relative to the local coordinates
1033
+ * of the parent DisplayObjectContainer.
1034
+ *
1035
+ * @member {number}
1036
+ * @public
1037
+ */
1038
+ get x() {
1039
+ const matrix = this._$transform.matrix;
1040
+ const bounds = this._$getBounds(null);
1041
+ return matrix._$matrix[4] + bounds.xMin;
1042
+ }
1043
+ set x(x) {
1044
+ const bounds = this._$getBounds(null);
1045
+ super.x = x - bounds.xMin;
1046
+ }
1047
+ /**
1048
+ * @description 親 DisplayObjectContainer のローカル座標を基準にした
1049
+ * DisplayObject インスタンスの y 座標を示します。
1050
+ * Indicates the y coordinate
1051
+ * of the DisplayObject instance relative to the local coordinates
1052
+ * of the parent DisplayObjectContainer.
1053
+ *
1054
+ * @member {number}
1055
+ * @public
1056
+ */
1057
+ get y() {
1058
+ const matrix = this._$transform.matrix;
1059
+ const bounds = this._$getBounds(null);
1060
+ return matrix._$matrix[5] + bounds.yMin;
1061
+ }
1062
+ set y(y) {
1063
+ const bounds = this._$getBounds(null);
1064
+ super.y = y - bounds.yMin;
1065
+ }
1066
+ /**
1067
+ * @description newText パラメーターで指定されたストリングを、
1068
+ * テキストフィールドのテキストの最後に付加します。
1069
+ * Appends the string specified by the newText parameter
1070
+ * to the end of the text of the text field.
1071
+ *
1072
+ * @param {string} new_text
1073
+ * @return void
1074
+ * @method
1075
+ * @public
1076
+ */
1077
+ appendText(new_text) {
1078
+ const currentText = this.text;
1079
+ this.text = currentText + `${new_text}`;
1080
+ }
1081
+ /**
1082
+ * @description beginIndex パラメーターと endIndex パラメーターで指定された範囲の
1083
+ * テキストのフォーマット情報を含む TextFormat オブジェクトを返します。
1084
+ * Returns a TextFormat object that contains formatting information
1085
+ * for the range of text that the beginIndex and endIndex parameters specify.
1086
+ *
1087
+ * @param {int} [begin_index=-1]
1088
+ * @param {int} [end_index=-1]
1089
+ * @return {TextFormat}
1090
+ * @method
1091
+ * @public
1092
+ */
1093
+ getTextFormat(begin_index = -1, end_index = -1) {
1094
+ begin_index |= 0;
1095
+ end_index |= 0;
1096
+ const data = this._$getTextData();
1097
+ const length = end_index > -1 ? end_index : data.length;
1098
+ let init = false;
1099
+ let textFormat = new TextFormat();
1100
+ let idx = begin_index > -1 ? begin_index : 0;
1101
+ for (; idx < length; ++idx) {
1102
+ if (data[idx].mode === "break") {
1103
+ continue;
1104
+ }
1105
+ const tf = data[idx].textFormat;
1106
+ if (!init) {
1107
+ init = true;
1108
+ textFormat = tf._$clone();
1109
+ continue;
1110
+ }
1111
+ textFormat.align = textFormat.align !== tf.align ? null : tf.align;
1112
+ textFormat.blockIndent = textFormat.blockIndent !== tf.blockIndent ? null : tf.blockIndent;
1113
+ textFormat.bold = textFormat.bold !== tf.bold ? null : tf.bold;
1114
+ textFormat.color = textFormat.color !== tf.color ? null : tf.color;
1115
+ textFormat.font = textFormat.font !== tf.font ? null : tf.font;
1116
+ textFormat.indent = textFormat.indent !== tf.indent ? null : tf.indent;
1117
+ textFormat.italic = textFormat.italic !== tf.italic ? null : tf.italic;
1118
+ textFormat.leading = textFormat.leading !== tf.leading ? null : tf.leading;
1119
+ textFormat.leftMargin = textFormat.leftMargin !== tf.leftMargin ? null : tf.leftMargin;
1120
+ textFormat.letterSpacing = textFormat.letterSpacing !== tf.letterSpacing ? null : tf.letterSpacing;
1121
+ textFormat.rightMargin = textFormat.rightMargin !== tf.rightMargin ? null : tf.rightMargin;
1122
+ textFormat.size = textFormat.size !== tf.size ? null : tf.size;
1123
+ textFormat.underline = textFormat.underline !== tf.underline ? null : tf.underline;
1124
+ }
1125
+ return textFormat;
1126
+ }
1127
+ /**
1128
+ * @description lineIndex パラメーターで指定された行のテキストを返します。
1129
+ * Returns the text of the line specified by the lineIndex parameter.
1130
+ *
1131
+ * @param {number} line_index
1132
+ * @return {string}
1133
+ * @public
1134
+ */
1135
+ getLineText(line_index) {
1136
+ if (!this._$text && !this._$htmlText) {
1137
+ return "";
1138
+ }
1139
+ line_index |= 0;
1140
+ let lineText = "";
1141
+ const textData = this._$getTextData();
1142
+ for (let idx = 0; idx < textData.length; idx++) {
1143
+ const obj = textData[idx];
1144
+ if (obj.yIndex > line_index) {
1145
+ break;
1146
+ }
1147
+ if (obj.yIndex !== line_index) {
1148
+ continue;
1149
+ }
1150
+ if (obj.mode !== "text") {
1151
+ continue;
1152
+ }
1153
+ lineText += obj.text;
1154
+ }
1155
+ return lineText;
1156
+ }
1157
+ /**
1158
+ * @description beginIndex パラメーターと endIndex パラメーターで指定された文字範囲を、
1159
+ * newText パラメーターの内容に置き換えます。
1160
+ * Replaces the range of characters that the beginIndex
1161
+ * and endIndex parameters specify with the contents of the newText parameter.
1162
+ *
1163
+ * @param {number} begin_index
1164
+ * @param {number} end_index
1165
+ * @param {string} new_text
1166
+ * @return {void}
1167
+ * @method
1168
+ * @public
1169
+ */
1170
+ replaceText(begin_index, end_index, new_text) {
1171
+ begin_index |= 0;
1172
+ end_index |= 0;
1173
+ if (begin_index > -1 && end_index > -1 && end_index >= begin_index) {
1174
+ const text = this.text;
1175
+ if (begin_index >= text.length) {
1176
+ if (end_index >= text.length && end_index >= begin_index) {
1177
+ this.text = text + `${new_text}`;
1178
+ }
1179
+ }
1180
+ else {
1181
+ this.text = text.slice(0, begin_index)
1182
+ + `${new_text}`
1183
+ + text.slice(end_index, text.length);
1184
+ }
1185
+ }
1186
+ }
1187
+ /**
1188
+ * @description format パラメーターで指定したテキストフォーマットを、
1189
+ * テキストフィールド内の指定されたテキストに適用します。
1190
+ * Applies the text formatting that the format parameter specifies
1191
+ * to the specified text in a text field.
1192
+ *
1193
+ * @param {TextFormat} text_format
1194
+ * @param {number} [begin_index=-1]
1195
+ * @param {number} [end_index=-1]
1196
+ * @return {void}
1197
+ * @method
1198
+ * @public
1199
+ */
1200
+ setTextFormat(text_format, begin_index = -1, end_index = -1) {
1201
+ // setup
1202
+ begin_index |= 0;
1203
+ end_index |= 0;
1204
+ const textData = this._$getTextData();
1205
+ this._$reset();
1206
+ switch (true) {
1207
+ case begin_index === -1 && end_index === -1:
1208
+ for (let idx = 0; idx < textData.length; ++idx) {
1209
+ this._$textFormatTable[idx] = text_format._$clone();
1210
+ }
1211
+ break;
1212
+ case begin_index > -1 && end_index === -1:
1213
+ {
1214
+ let idx = begin_index + 1;
1215
+ let obj = textData[idx];
1216
+ if (obj.mode === "wrap") {
1217
+ obj = textData[++idx];
1218
+ }
1219
+ this._$textFormatTable[idx] = text_format._$clone();
1220
+ }
1221
+ break;
1222
+ case begin_index > -1 && end_index > -1 && end_index > begin_index:
1223
+ {
1224
+ let offset = 0;
1225
+ for (let idx = begin_index; idx < end_index; ++idx) {
1226
+ const obj = textData[idx];
1227
+ if (!obj) {
1228
+ continue;
1229
+ }
1230
+ if (obj.mode === "wrap" || obj.mode === "break") {
1231
+ ++end_index;
1232
+ --offset;
1233
+ continue;
1234
+ }
1235
+ this._$textFormatTable[idx + offset] = text_format._$clone();
1236
+ }
1237
+ }
1238
+ break;
1239
+ }
1240
+ this._$getTextData();
1241
+ this._$resize();
1242
+ }
1243
+ /**
1244
+ * @return {array}
1245
+ * @method
1246
+ * @private
1247
+ */
1248
+ _$getTextData() {
1249
+ if (!this._$createdTextData) {
1250
+ this._$createdTextData = true;
1251
+ // reset
1252
+ this._$textData.length = 0;
1253
+ this._$imageData.length = 0;
1254
+ this._$heightTable.length = 0;
1255
+ this._$textHeightTable.length = 0;
1256
+ this._$objectTable.length = 0;
1257
+ this._$widthTable.length = 0;
1258
+ this._$heightCache.clear();
1259
+ let tfCopyOffset = -1;
1260
+ if (this._$isHTML) {
1261
+ // html text
1262
+ let htmlText = this._$htmlText;
1263
+ const index = htmlText.search(/(< .*>|<>)/g);
1264
+ if (index > -1) {
1265
+ htmlText = htmlText.slice(0, index);
1266
+ }
1267
+ htmlText = htmlText.replace(/\r\n/g, "\r\r");
1268
+ if ($P_TAG.innerHTML !== htmlText) {
1269
+ $P_TAG.textContent = "";
1270
+ $P_TAG.insertAdjacentHTML("afterbegin", htmlText);
1271
+ }
1272
+ // setup
1273
+ let tf = this._$defaultTextFormat;
1274
+ if (this._$textData.length in this._$textFormatTable) {
1275
+ const tft = this._$textFormatTable[this._$textData.length]._$clone();
1276
+ tft._$merge(tf);
1277
+ tf = tft;
1278
+ }
1279
+ // init
1280
+ this._$totalWidth = 0;
1281
+ this._$heightTable[0] = 0;
1282
+ this._$textHeightTable[0] = this._$getTextHeight(tf);
1283
+ this._$widthTable[0] = 0;
1284
+ const obj = {
1285
+ "mode": "break",
1286
+ "x": 0,
1287
+ "yIndex": 0,
1288
+ "textFormat": tf._$clone()
1289
+ };
1290
+ this._$objectTable[0] = obj;
1291
+ this._$textData[0] = obj;
1292
+ this._$parseTag($P_TAG, tf._$clone(), tfCopyOffset);
1293
+ }
1294
+ else {
1295
+ // plain text
1296
+ const texts = this._$multiline
1297
+ ? this._$text.split("\n")
1298
+ : [this._$text.replace("\n", "")];
1299
+ for (let idx = 0; idx < texts.length; ++idx) {
1300
+ // reset
1301
+ this._$totalWidth = 0;
1302
+ let tf = this.defaultTextFormat;
1303
+ const yIndex = this._$wordWrap || this._$multiline
1304
+ ? this._$heightTable.length
1305
+ : 0;
1306
+ this._$heightTable[yIndex] = 0;
1307
+ this._$textHeightTable[yIndex] = this._$getTextHeight(tf);
1308
+ this._$widthTable[yIndex] = 0;
1309
+ if (yIndex) {
1310
+ this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
1311
+ this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
1312
+ }
1313
+ if (this._$textData.length in this._$textFormatTable) {
1314
+ const tft = this._$textFormatTable[this._$textData.length]._$clone();
1315
+ tft._$merge(tf);
1316
+ tf = tft;
1317
+ }
1318
+ const obj = {
1319
+ "mode": "break",
1320
+ "x": 0,
1321
+ "yIndex": yIndex,
1322
+ "textFormat": tf._$clone()
1323
+ };
1324
+ tf = this.defaultTextFormat;
1325
+ this._$objectTable[yIndex] = obj;
1326
+ this._$textData[this._$textData.length] = obj;
1327
+ // parse text data
1328
+ const text = texts[idx];
1329
+ if (text) {
1330
+ tfCopyOffset = this._$parseText(text, tf, tfCopyOffset);
1331
+ }
1332
+ }
1333
+ }
1334
+ // clear
1335
+ this._$heightCache.clear();
1336
+ }
1337
+ return this._$textData;
1338
+ }
1339
+ /**
1340
+ * @param {Element} tag
1341
+ * @param {TextFormat} text_format
1342
+ * @param {number} tf_copy_offset
1343
+ * @return {void}
1344
+ * @private
1345
+ */
1346
+ _$parseTag(tag, text_format, tf_copy_offset) {
1347
+ const childNodes = tag.childNodes;
1348
+ const length = childNodes.length;
1349
+ for (let idx = 0; idx < length; ++idx) {
1350
+ let tf = text_format._$clone();
1351
+ const node = childNodes[idx];
1352
+ if (node.nodeType === 3) {
1353
+ tf_copy_offset = this._$parseText(node.nodeValue || "", tf, tf_copy_offset);
1354
+ continue;
1355
+ }
1356
+ switch (node.nodeName) {
1357
+ case "P":
1358
+ {
1359
+ if (node.hasAttribute("align")) {
1360
+ const align = node.getAttribute("align");
1361
+ if (align === "center" || align === "left" || align === "right") {
1362
+ tf.align = align;
1363
+ if (this._$textData.length === 1) {
1364
+ this._$textData[0].textFormat.align = tf.align;
1365
+ }
1366
+ }
1367
+ }
1368
+ this._$parseTag(node, tf, tf_copy_offset);
1369
+ if (!this._$multiline) {
1370
+ break;
1371
+ }
1372
+ // reset
1373
+ this._$totalWidth = this._$getImageOffsetX();
1374
+ const yIndex = this._$heightTable.length;
1375
+ this._$heightTable[yIndex] = 0;
1376
+ this._$textHeightTable[yIndex] = 0;
1377
+ this._$widthTable[yIndex] = 0;
1378
+ if (yIndex) {
1379
+ this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
1380
+ this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
1381
+ }
1382
+ if (this._$textData.length in this._$textFormatTable) {
1383
+ const tft = this._$textFormatTable[this._$textData.length]._$clone();
1384
+ tft._$merge(tf);
1385
+ tf = tft;
1386
+ }
1387
+ const obj = {
1388
+ "mode": "break",
1389
+ "x": 0,
1390
+ "yIndex": yIndex,
1391
+ "textFormat": tf
1392
+ };
1393
+ this._$objectTable[yIndex] = obj;
1394
+ this._$textData.push(obj);
1395
+ }
1396
+ break;
1397
+ case "B": // bold
1398
+ tf.bold = true;
1399
+ this._$parseTag(node, tf, tf_copy_offset);
1400
+ break;
1401
+ case "I": // italic
1402
+ tf.italic = true;
1403
+ this._$parseTag(node, tf, tf_copy_offset);
1404
+ break;
1405
+ case "U": // underline
1406
+ tf.underline = true;
1407
+ this._$parseTag(node, tf, tf_copy_offset);
1408
+ break;
1409
+ case "FONT": // FONT
1410
+ if (node.hasAttribute("face")) {
1411
+ tf.font = node.getAttribute("face");
1412
+ }
1413
+ if (node.hasAttribute("size")) {
1414
+ const size = node.getAttribute("size");
1415
+ if (size) {
1416
+ tf.size = +size;
1417
+ }
1418
+ }
1419
+ if (node.hasAttribute("color")) {
1420
+ tf.color = $toColorInt(node.getAttribute("color"));
1421
+ }
1422
+ if (node.hasAttribute("letterSpacing")) {
1423
+ const letterSpacing = node.getAttribute("size");
1424
+ if (letterSpacing) {
1425
+ tf.letterSpacing = +letterSpacing;
1426
+ }
1427
+ }
1428
+ this._$parseTag(node, tf, tf_copy_offset);
1429
+ break;
1430
+ case "BR": // br
1431
+ {
1432
+ if (!this._$multiline) {
1433
+ break;
1434
+ }
1435
+ // add y index
1436
+ const yIndex = this._$heightTable.length;
1437
+ this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
1438
+ this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
1439
+ this._$widthTable[yIndex] = 0;
1440
+ // reset
1441
+ this._$totalWidth = this._$getImageOffsetX();
1442
+ // new clone
1443
+ tf.indent = 0;
1444
+ // set x offset
1445
+ const obj = {
1446
+ "mode": "break",
1447
+ "x": 0,
1448
+ "yIndex": yIndex,
1449
+ "textFormat": tf
1450
+ };
1451
+ this._$objectTable[yIndex] = obj;
1452
+ this._$textData[this._$textData.length] = obj;
1453
+ }
1454
+ break;
1455
+ case "IMG":
1456
+ {
1457
+ if (!node.hasAttribute("src")) {
1458
+ break;
1459
+ }
1460
+ const src = node.getAttribute("src");
1461
+ if (!src) {
1462
+ break;
1463
+ }
1464
+ let width = 0;
1465
+ if (node.hasAttribute("width")) {
1466
+ const attribute = node.getAttribute("width");
1467
+ if (attribute) {
1468
+ width = +attribute;
1469
+ }
1470
+ }
1471
+ let height = 0;
1472
+ if (node.hasAttribute("height")) {
1473
+ const attribute = node.getAttribute("height");
1474
+ if (attribute) {
1475
+ height = +attribute;
1476
+ }
1477
+ }
1478
+ let vspace = 8;
1479
+ if (node.hasAttribute("vspace")) {
1480
+ const attribute = node.getAttribute("vspace");
1481
+ if (attribute) {
1482
+ vspace = +attribute;
1483
+ }
1484
+ }
1485
+ let hspace = 8;
1486
+ if (node.hasAttribute("hspace")) {
1487
+ const attribute = node.getAttribute("hspace");
1488
+ if (attribute) {
1489
+ hspace = +attribute;
1490
+ }
1491
+ }
1492
+ let totalTextHeight = 0;
1493
+ for (let idx = 0; idx < this._$textHeightTable.length; idx++) {
1494
+ totalTextHeight += this._$textHeightTable[idx];
1495
+ }
1496
+ const image = new Image();
1497
+ const obj = {
1498
+ "mode": "image",
1499
+ "image": image,
1500
+ "src": src,
1501
+ "loaded": false,
1502
+ "x": 0,
1503
+ "y": totalTextHeight,
1504
+ "width": width,
1505
+ "height": height,
1506
+ "hspace": hspace,
1507
+ "vspace": vspace,
1508
+ "textFormat": tf._$clone()
1509
+ };
1510
+ image.crossOrigin = "anonymous";
1511
+ image.addEventListener("load", () => {
1512
+ if (!obj.width) {
1513
+ obj.width = image.width;
1514
+ }
1515
+ if (!obj.height) {
1516
+ obj.height = image.height;
1517
+ }
1518
+ obj.loaded = true;
1519
+ this._$reload();
1520
+ });
1521
+ image.src = src;
1522
+ if (this._$imageData.length > 0) {
1523
+ const prevImage = this._$imageData[this._$imageData.length - 1];
1524
+ const imageBottom = prevImage.y + prevImage.height + prevImage.vspace * 2;
1525
+ obj.y = $Math.max(totalTextHeight, imageBottom);
1526
+ }
1527
+ this._$textData[this._$textData.length] = obj;
1528
+ this._$imageData[this._$imageData.length] = obj;
1529
+ }
1530
+ break;
1531
+ default:
1532
+ this._$parseTag(node, tf, tf_copy_offset);
1533
+ break;
1534
+ }
1535
+ }
1536
+ }
1537
+ /**
1538
+ * @param {string} text
1539
+ * @param {TextFormat} text_format
1540
+ * @param {number} tf_copy_offset
1541
+ * @returns {number}
1542
+ * @method
1543
+ * @private
1544
+ */
1545
+ _$parseText(text, text_format, tf_copy_offset) {
1546
+ let yIndex = this._$heightTable.length - 1;
1547
+ // new format
1548
+ let tf = text_format._$clone();
1549
+ const matrix = this._$transform.concatenatedMatrix._$matrix;
1550
+ const boundsWidth = (this._$originBounds.xMax - this._$originBounds.xMin)
1551
+ * (matrix[0] / matrix[3]);
1552
+ $poolFloat32Array6(matrix);
1553
+ const maxWidth = boundsWidth - tf._$widthMargin() - 4;
1554
+ for (let idx = 0; idx < text.length; ++idx) {
1555
+ tf = text_format._$clone();
1556
+ if (this._$textData.length + tf_copy_offset in this._$textFormatTable) {
1557
+ const tft = this._$textFormatTable[this._$textData.length + tf_copy_offset]._$clone();
1558
+ tft._$merge(tf);
1559
+ tf = tft;
1560
+ }
1561
+ // reset object
1562
+ const obj = {
1563
+ "mode": "text",
1564
+ "text": text[idx],
1565
+ "x": 0,
1566
+ "width": 0,
1567
+ "height": 0,
1568
+ "yIndex": yIndex,
1569
+ "textFormat": tf
1570
+ };
1571
+ let breakCode = false;
1572
+ if (this._$multiline) {
1573
+ breakCode = obj.text === "\n" || obj.text === "\r" || obj.text === "\n\r";
1574
+ }
1575
+ const leading = yIndex ? tf.leading || 0 : 0;
1576
+ let width = 0;
1577
+ let height = 0;
1578
+ let textHeight = 0;
1579
+ let wrapObj;
1580
+ if (!$textContext) {
1581
+ continue;
1582
+ }
1583
+ $textContext.font = tf._$generateFontStyle();
1584
+ width = $textContext.measureText(obj.text || "").width;
1585
+ width += tf.letterSpacing || 0;
1586
+ height = this._$getTextHeight(tf);
1587
+ textHeight = height + leading;
1588
+ obj.height = height;
1589
+ if (breakCode ||
1590
+ this._$wordWrap && this._$totalWidth + width > maxWidth) {
1591
+ // add y index
1592
+ this._$widthTable[++yIndex] = 0;
1593
+ obj.yIndex = yIndex;
1594
+ this._$heightTable[yIndex] = this._$heightTable[yIndex - 1];
1595
+ this._$textHeightTable[yIndex] = this._$textHeightTable[yIndex - 1];
1596
+ // reset
1597
+ this._$totalWidth = this._$getImageOffsetX();
1598
+ // new clone
1599
+ tf = tf._$clone();
1600
+ tf.indent = 0;
1601
+ // set x offset
1602
+ const mode = breakCode ? "break" : "wrap";
1603
+ wrapObj = {
1604
+ "mode": mode,
1605
+ "x": 0,
1606
+ "yIndex": yIndex,
1607
+ "textFormat": tf
1608
+ };
1609
+ this._$objectTable[yIndex] = wrapObj;
1610
+ if (!breakCode) {
1611
+ --tf_copy_offset;
1612
+ }
1613
+ let text = obj.text || "";
1614
+ let chunkLength = 0;
1615
+ let isSeparated = true;
1616
+ const pattern = /[0-9a-zA-Z?!;:.,?!。、;:〜]/g;
1617
+ while (text.match(pattern)) {
1618
+ ++chunkLength;
1619
+ const prevObj = this._$textData[this._$textData.length - chunkLength];
1620
+ if (prevObj.mode !== "text") {
1621
+ isSeparated = false;
1622
+ break;
1623
+ }
1624
+ text = prevObj.text || "";
1625
+ }
1626
+ if (chunkLength > 1 && this._$textData) {
1627
+ const text = this._$textData[this._$textData.length - chunkLength + 1].text || "";
1628
+ if (text.match(/[0-9a-zA-Z]/g)) {
1629
+ --chunkLength;
1630
+ }
1631
+ }
1632
+ if (chunkLength > 0 && isSeparated) {
1633
+ const insertIdx = this._$textData.length - chunkLength;
1634
+ this._$textData.splice(insertIdx, 0, wrapObj);
1635
+ // prev line
1636
+ let offset = 1;
1637
+ let targetObj = this._$textData[insertIdx - offset];
1638
+ this._$widthTable[yIndex - 1] = 0;
1639
+ this._$heightTable[yIndex - 1] = 0;
1640
+ this._$textHeightTable[yIndex - 1] = 0;
1641
+ while (targetObj.mode === "text") {
1642
+ height = this._$getTextHeight(targetObj.textFormat);
1643
+ textHeight = height + leading;
1644
+ this._$widthTable[yIndex - 1] += targetObj.width || 0;
1645
+ this._$heightTable[yIndex - 1] = $Math.max(this._$heightTable[yIndex - 1], height);
1646
+ this._$textHeightTable[yIndex - 1] = $Math.max(this._$textHeightTable[yIndex - 1], textHeight);
1647
+ ++offset;
1648
+ targetObj = this._$textData[insertIdx - offset];
1649
+ }
1650
+ // new line
1651
+ offset = 1;
1652
+ while (this._$textData.length > insertIdx + offset) {
1653
+ targetObj = this._$textData[insertIdx + offset];
1654
+ ++offset;
1655
+ height = this._$getTextHeight(targetObj.textFormat);
1656
+ textHeight = height + leading;
1657
+ this._$heightTable[yIndex] = $Math.max(this._$heightTable[yIndex], height);
1658
+ this._$textHeightTable[yIndex] = $Math.max(this._$textHeightTable[yIndex], textHeight);
1659
+ targetObj.x = this._$totalWidth;
1660
+ targetObj.yIndex = yIndex;
1661
+ this._$totalWidth += targetObj.width || 0;
1662
+ }
1663
+ }
1664
+ else {
1665
+ this._$textData[this._$textData.length] = wrapObj;
1666
+ }
1667
+ }
1668
+ if (!breakCode) {
1669
+ // width data
1670
+ obj.width = width;
1671
+ obj.x = this._$totalWidth;
1672
+ this._$totalWidth += width;
1673
+ if (this._$widthTable) {
1674
+ this._$widthTable[yIndex] = $Math.max(this._$widthTable[yIndex], this._$totalWidth);
1675
+ }
1676
+ // height data
1677
+ this._$heightTable[yIndex] = $Math.max(this._$heightTable[yIndex], height);
1678
+ this._$textHeightTable[yIndex] = $Math.max(this._$textHeightTable[yIndex], textHeight);
1679
+ this._$textData[this._$textData.length] = obj;
1680
+ }
1681
+ }
1682
+ return tf_copy_offset;
1683
+ }
1684
+ /**
1685
+ * @param {TextFormat} text_format
1686
+ * @return {number}
1687
+ * @private
1688
+ */
1689
+ _$getTextHeight(text_format) {
1690
+ const size = text_format.size || 0;
1691
+ const font = text_format.font || "";
1692
+ const weight = text_format.bold ? "bold" : "normal";
1693
+ // use cache
1694
+ const key = `${size}_${font}_${weight}`;
1695
+ if (this._$heightCache.has(key)) {
1696
+ return this._$heightCache.get(key) || 0;
1697
+ }
1698
+ // update dom data
1699
+ const style = $DIV.style;
1700
+ const fontSize = `${size}px`;
1701
+ if (style.fontSize !== fontSize) {
1702
+ style.fontSize = fontSize;
1703
+ }
1704
+ if (style.fontFamily !== font) {
1705
+ style.fontFamily = font;
1706
+ }
1707
+ if (style.fontWeight !== weight) {
1708
+ style.fontWeight = weight;
1709
+ }
1710
+ const height = 10 > size
1711
+ ? $DIV.clientHeight * size * 0.1
1712
+ : $DIV.clientHeight;
1713
+ // cache
1714
+ this._$heightCache.set(key, height);
1715
+ return height;
1716
+ }
1717
+ /**
1718
+ * @return {number}
1719
+ * @private
1720
+ */
1721
+ _$getImageOffsetX() {
1722
+ if (!this._$imageData.length) {
1723
+ return 0;
1724
+ }
1725
+ let totalTextHeight = 0;
1726
+ for (let idx = 0; idx < this._$textHeightTable.length; ++idx) {
1727
+ totalTextHeight += this._$textHeightTable[idx];
1728
+ }
1729
+ if (this._$imageData) {
1730
+ for (let idx = 0; idx < this._$imageData.length; ++idx) {
1731
+ const image = this._$imageData[idx];
1732
+ const imageHeight = image.height + image.vspace * 2;
1733
+ if (image.y <= totalTextHeight
1734
+ && totalTextHeight < image.y + imageHeight) {
1735
+ return image.width + image.hspace * 2;
1736
+ }
1737
+ }
1738
+ }
1739
+ return 0;
1740
+ }
1741
+ /**
1742
+ * @return {void}
1743
+ * @method
1744
+ * @private
1745
+ */
1746
+ _$reset() {
1747
+ this._$createdTextData = false;
1748
+ this._$textData.length = 0;
1749
+ this._$imageData.length = 0;
1750
+ this._$heightTable.length = 0;
1751
+ this._$textHeightTable.length = 0;
1752
+ this._$widthTable.length = 0;
1753
+ this._$objectTable.length = 0;
1754
+ this._$textHeight = null;
1755
+ this._$textWidth = null;
1756
+ this._$totalWidth = 0;
1757
+ this._$maxScrollH = null;
1758
+ this._$maxScrollV = null;
1759
+ this._$doChanged();
1760
+ $doUpdated();
1761
+ // cache clear
1762
+ const player = $currentPlayer();
1763
+ player.cacheStore.removeCache(this._$instanceId);
1764
+ }
1765
+ /**
1766
+ * @return {void}
1767
+ * @method
1768
+ * @private
1769
+ */
1770
+ _$reload() {
1771
+ this._$reset();
1772
+ this._$getTextData();
1773
+ if (this._$autoSize === "none" && this._$autoFontSize) {
1774
+ let fontSize = this._$defaultTextFormat.size || 0;
1775
+ const cacheSize = fontSize;
1776
+ if (this.width && this.textWidth
1777
+ && this.textWidth > this.width) {
1778
+ while (this.textWidth > this.width) {
1779
+ this._$defaultTextFormat.size = fontSize--;
1780
+ if (1 > fontSize) {
1781
+ this._$defaultTextFormat.size = 1;
1782
+ break;
1783
+ }
1784
+ this._$reset();
1785
+ this._$getTextData();
1786
+ }
1787
+ }
1788
+ if (this.height && this.textHeight
1789
+ && this.textHeight > this.height) {
1790
+ while (this.textHeight > this.height) {
1791
+ this._$defaultTextFormat.size = fontSize--;
1792
+ if (1 > fontSize) {
1793
+ this._$defaultTextFormat.size = 1;
1794
+ break;
1795
+ }
1796
+ this._$reset();
1797
+ this._$getTextData();
1798
+ }
1799
+ }
1800
+ // restore
1801
+ this._$defaultTextFormat.size = cacheSize;
1802
+ }
1803
+ this._$resize();
1804
+ }
1805
+ /**
1806
+ * @return {void}
1807
+ * @method
1808
+ * @private
1809
+ */
1810
+ _$resize() {
1811
+ // update bounds
1812
+ if (this._$autoSize !== "none") {
1813
+ const tf = this._$defaultTextFormat;
1814
+ const width = this.textWidth + 4 + tf._$widthMargin();
1815
+ if (this._$wordWrap) {
1816
+ this._$bounds.xMax = this._$originBounds.xMax;
1817
+ this._$bounds.xMin = this._$originBounds.xMin;
1818
+ }
1819
+ else {
1820
+ switch (this._$autoSize) {
1821
+ case "left":
1822
+ this._$bounds.xMax = width + this._$bounds.xMin;
1823
+ break;
1824
+ case "center":
1825
+ this._$bounds.xMax = width + this._$bounds.xMin;
1826
+ break;
1827
+ case "right":
1828
+ this._$bounds.xMax = this._$originBounds.xMax
1829
+ - (this._$originBounds.xMax - this._$originBounds.xMin
1830
+ - (width - this._$originBounds.xMin));
1831
+ break;
1832
+ default:
1833
+ break;
1834
+ }
1835
+ }
1836
+ // set height
1837
+ this._$bounds.yMax = this.textHeight
1838
+ + 4 + this._$originBounds.yMin;
1839
+ }
1840
+ else {
1841
+ if (this._$scrollEnabled && !this._$scrollSprite) {
1842
+ this._$scrollSprite = new Sprite();
1843
+ this._$scrollSprite
1844
+ .graphics
1845
+ .beginFill("#000", 0.3)
1846
+ .drawRoundRect(0, 0, 3, 3, 3);
1847
+ this._$scrollSprite.scale9Grid = new Rectangle(1.5, 1.5, 0.1, 0.1);
1848
+ }
1849
+ }
1850
+ }
1851
+ /**
1852
+ * @param {object} obj
1853
+ * @param {number} width
1854
+ * @return {number}
1855
+ * @private
1856
+ */
1857
+ _$getAlignOffset(obj, width) {
1858
+ // default
1859
+ const totalWidth = this._$widthTable[obj.yIndex];
1860
+ const textFormat = obj.textFormat;
1861
+ let indent = 0;
1862
+ indent += textFormat.blockIndent || 0;
1863
+ indent += textFormat.leftMargin || 0;
1864
+ const rightMargin = textFormat.rightMargin || 0;
1865
+ switch (true) {
1866
+ // wordWrap case
1867
+ case !this._$wordWrap && totalWidth > width:
1868
+ return $Math.max(0, indent);
1869
+ case textFormat.align === "center": // format CENTER
1870
+ case this._$autoSize === "center": // autoSize CENTER
1871
+ return $Math.max(0, width / 2 - indent - rightMargin - totalWidth / 2);
1872
+ case textFormat.align === "right": // format RIGHT
1873
+ case this._$autoSize === "right": // autoSize RIGHT
1874
+ return $Math.max(0, width - indent - totalWidth - rightMargin - 2);
1875
+ // autoSize LEFT
1876
+ // format LEFT
1877
+ default:
1878
+ return $Math.max(0, indent + 2);
1879
+ }
1880
+ }
1881
+ /**
1882
+ * @param {Float32Array} [matrix=null]
1883
+ * @returns {object}
1884
+ * @method
1885
+ * @private
1886
+ */
1887
+ _$getBounds(matrix = null) {
1888
+ if (matrix) {
1889
+ let multiMatrix = matrix;
1890
+ const rawMatrix = this._$transform._$rawMatrix();
1891
+ if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
1892
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
1893
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
1894
+ multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
1895
+ }
1896
+ return $boundsMatrix(this._$bounds, multiMatrix);
1897
+ }
1898
+ return $getBoundsObject(this._$bounds.xMin, this._$bounds.xMax, this._$bounds.yMin, this._$bounds.yMax);
1899
+ }
1900
+ /**
1901
+ * @param {object} character
1902
+ * @return {void}
1903
+ * @method
1904
+ * @private
1905
+ */
1906
+ _$buildCharacter(character) {
1907
+ const textFormat = this._$defaultTextFormat;
1908
+ textFormat.font = character.font;
1909
+ textFormat.size = character.size | 0;
1910
+ textFormat.align = character.align;
1911
+ textFormat.color = character.color | 0;
1912
+ textFormat.leading = character.leading;
1913
+ textFormat.letterSpacing = character.letterSpacing;
1914
+ textFormat.leftMargin = character.leftMargin;
1915
+ textFormat.rightMargin = character.rightMargin;
1916
+ switch (character.fontType) {
1917
+ case 1:
1918
+ textFormat.bold = true;
1919
+ break;
1920
+ case 2:
1921
+ textFormat.italic = true;
1922
+ break;
1923
+ case 3:
1924
+ textFormat.bold = true;
1925
+ textFormat.italic = true;
1926
+ break;
1927
+ }
1928
+ // setup
1929
+ this._$type = character.inputType;
1930
+ this._$multiline = !!character.multiline;
1931
+ this._$wordWrap = !!character.wordWrap;
1932
+ this._$border = !!character.border;
1933
+ this._$scrollEnabled = !!character.scroll;
1934
+ this._$thickness = character.thickness | 0;
1935
+ this._$thicknessColor = character.thicknessColor | 0;
1936
+ // bounds
1937
+ this._$bounds.xMin = character.originBounds.xMin;
1938
+ this._$bounds.xMax = character.originBounds.xMax;
1939
+ this._$bounds.yMin = character.originBounds.yMin;
1940
+ this._$bounds.yMax = character.originBounds.yMax;
1941
+ this._$originBounds.xMin = character.originBounds.xMin;
1942
+ this._$originBounds.xMax = character.originBounds.xMax;
1943
+ this._$originBounds.yMin = character.originBounds.yMin;
1944
+ this._$originBounds.yMax = character.originBounds.yMax;
1945
+ switch (character.autoSize) {
1946
+ case 1:
1947
+ this.autoSize = character.align;
1948
+ break;
1949
+ case 2:
1950
+ this.autoFontSize = true;
1951
+ break;
1952
+ }
1953
+ this.text = character.text;
1954
+ if ($rendererWorker && this._$stage) {
1955
+ this._$createWorkerInstance();
1956
+ }
1957
+ }
1958
+ /**
1959
+ * @return {object}
1960
+ * @method
1961
+ * @private
1962
+ */
1963
+ _$sync() {
1964
+ const character = super._$sync();
1965
+ if (character) {
1966
+ this._$buildCharacter(character);
1967
+ }
1968
+ return character;
1969
+ }
1970
+ /**
1971
+ * @param {object} tag
1972
+ * @param {DisplayObjectContainer} parent
1973
+ * @return {object}
1974
+ * @method
1975
+ * @private
1976
+ */
1977
+ _$build(tag, parent) {
1978
+ const character = this
1979
+ ._$baseBuild(tag, parent);
1980
+ this._$buildCharacter(character);
1981
+ return character;
1982
+ }
1983
+ /**
1984
+ * @param {CanvasToWebGLContext} context
1985
+ * @param {Float32Array} matrix
1986
+ * @returns {void}
1987
+ * @method
1988
+ * @private
1989
+ */
1990
+ _$clip(context, matrix) {
1991
+ // size
1992
+ const bounds = this._$getBounds();
1993
+ const xMax = bounds.xMax;
1994
+ const xMin = bounds.xMin;
1995
+ const yMax = bounds.yMax;
1996
+ const yMin = bounds.yMin;
1997
+ $poolBoundsObject(bounds);
1998
+ const width = $Math.ceil($Math.abs(xMax - xMin));
1999
+ const height = $Math.ceil($Math.abs(yMax - yMin));
2000
+ if (!width || !height) {
2001
+ return;
2002
+ }
2003
+ let multiMatrix = matrix;
2004
+ const rawMatrix = this._$transform._$rawMatrix();
2005
+ if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
2006
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
2007
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
2008
+ multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
2009
+ }
2010
+ context.reset();
2011
+ context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
2012
+ context.beginPath();
2013
+ context.moveTo(0, 0);
2014
+ context.lineTo(width, 0);
2015
+ context.lineTo(width, height);
2016
+ context.lineTo(0, height);
2017
+ context.lineTo(0, 0);
2018
+ context.clip();
2019
+ if (multiMatrix !== matrix) {
2020
+ $poolFloat32Array6(multiMatrix);
2021
+ }
2022
+ }
2023
+ /**
2024
+ * @param {CanvasToWebGLContext} context
2025
+ * @param {Float32Array} matrix
2026
+ * @param {Float32Array} color_transform
2027
+ * @return {void}
2028
+ * @method
2029
+ * @private
2030
+ */
2031
+ _$draw(context, matrix, color_transform) {
2032
+ if (!this._$visible || this._$textAreaActive) {
2033
+ return;
2034
+ }
2035
+ if (!this._$background && !this._$border && !this.text) {
2036
+ return;
2037
+ }
2038
+ let multiColor = color_transform;
2039
+ const rawColor = this._$transform._$rawColorTransform();
2040
+ if (rawColor[0] !== 1 || rawColor[1] !== 1
2041
+ || rawColor[2] !== 1 || rawColor[3] !== 1
2042
+ || rawColor[4] !== 0 || rawColor[5] !== 0
2043
+ || rawColor[6] !== 0 || rawColor[7] !== 0) {
2044
+ multiColor = $multiplicationColor(color_transform, rawColor);
2045
+ }
2046
+ const alpha = $clamp(multiColor[3] + multiColor[7] / 255, 0, 1);
2047
+ if (!alpha) {
2048
+ return;
2049
+ }
2050
+ let multiMatrix = matrix;
2051
+ const rawMatrix = this._$transform._$rawMatrix();
2052
+ if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
2053
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
2054
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
2055
+ multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
2056
+ }
2057
+ const baseBounds = this._$getBounds(null);
2058
+ baseBounds.xMin -= this._$thickness;
2059
+ baseBounds.xMax += this._$thickness;
2060
+ baseBounds.yMin -= this._$thickness;
2061
+ baseBounds.yMax += this._$thickness;
2062
+ const bounds = $boundsMatrix(baseBounds, multiMatrix);
2063
+ const xMax = +bounds.xMax;
2064
+ const xMin = +bounds.xMin;
2065
+ const yMax = +bounds.yMax;
2066
+ const yMin = +bounds.yMin;
2067
+ $poolBoundsObject(bounds);
2068
+ const width = $Math.ceil($Math.abs(xMax - xMin));
2069
+ const height = $Math.ceil($Math.abs(yMax - yMin));
2070
+ switch (true) {
2071
+ case width === 0:
2072
+ case height === 0:
2073
+ case width === -$Infinity:
2074
+ case height === -$Infinity:
2075
+ case width === $Infinity:
2076
+ case height === $Infinity:
2077
+ return;
2078
+ default:
2079
+ break;
2080
+ }
2081
+ if (0 > xMin + width || 0 > yMin + height) {
2082
+ return;
2083
+ }
2084
+ // cache current buffer
2085
+ const manager = context.frameBuffer;
2086
+ const currentAttachment = manager.currentAttachment;
2087
+ if (!currentAttachment
2088
+ || xMin > currentAttachment.width
2089
+ || yMin > currentAttachment.height) {
2090
+ return;
2091
+ }
2092
+ let xScale = +$Math.sqrt(multiMatrix[0] * multiMatrix[0]
2093
+ + multiMatrix[1] * multiMatrix[1]);
2094
+ if (!$Number.isInteger(xScale)) {
2095
+ const value = xScale.toString();
2096
+ const index = value.indexOf("e");
2097
+ if (index !== -1) {
2098
+ xScale = +value.slice(0, index);
2099
+ }
2100
+ xScale = +xScale.toFixed(4);
2101
+ }
2102
+ let yScale = +$Math.sqrt(multiMatrix[2] * multiMatrix[2]
2103
+ + multiMatrix[3] * multiMatrix[3]);
2104
+ if (!$Number.isInteger(yScale)) {
2105
+ const value = yScale.toString();
2106
+ const index = value.indexOf("e");
2107
+ if (index !== -1) {
2108
+ yScale = +value.slice(0, index);
2109
+ }
2110
+ yScale = +yScale.toFixed(4);
2111
+ }
2112
+ const filters = this._$filters || this.filters;
2113
+ if (0 > xMin + width || 0 > yMin + height) {
2114
+ if (filters.length && this._$canApply(filters)) {
2115
+ let rect = new Rectangle(0, 0, width, height);
2116
+ for (let idx = 0; idx < filters.length; ++idx) {
2117
+ rect = filters[idx]._$generateFilterRect(rect, xScale, yScale);
2118
+ }
2119
+ if (0 > rect.x + rect.width || 0 > rect.y + rect.height) {
2120
+ return;
2121
+ }
2122
+ }
2123
+ else {
2124
+ return;
2125
+ }
2126
+ }
2127
+ const blendMode = this._$blendMode || this.blendMode;
2128
+ const keys = $getArray(xScale, yScale);
2129
+ const instanceId = this._$instanceId;
2130
+ const player = $currentPlayer();
2131
+ const cacheStore = player.cacheStore;
2132
+ const cacheKeys = cacheStore.generateKeys(instanceId, keys);
2133
+ let texture = cacheStore.get(cacheKeys);
2134
+ // texture is small or renew
2135
+ if (this._$isUpdated()) {
2136
+ cacheStore.removeCache(instanceId);
2137
+ texture = null;
2138
+ }
2139
+ if (!texture) {
2140
+ // resize
2141
+ const lineWidth = $Math.min(1, $Math.max(xScale, yScale));
2142
+ const baseWidth = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
2143
+ const baseHeight = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
2144
+ // alpha reset
2145
+ multiColor[3] = 1;
2146
+ // new canvas
2147
+ const canvas = cacheStore.getCanvas();
2148
+ canvas.width = baseWidth + lineWidth * 2;
2149
+ canvas.height = baseHeight + lineWidth * 2;
2150
+ const ctx = canvas.getContext("2d");
2151
+ if (!ctx) {
2152
+ throw new Error("the context is null.");
2153
+ }
2154
+ // border and background
2155
+ if (this._$background || this._$border) {
2156
+ ctx.beginPath();
2157
+ ctx.moveTo(0, 0);
2158
+ ctx.lineTo(baseWidth, 0);
2159
+ ctx.lineTo(baseWidth, baseHeight);
2160
+ ctx.lineTo(0, baseHeight);
2161
+ ctx.lineTo(0, 0);
2162
+ if (this._$background) {
2163
+ const rgb = $intToRGBA(this._$backgroundColor);
2164
+ const alpha = $Math.max(0, $Math.min(rgb.A * 255 * multiColor[3] + multiColor[7], 255)) / 255;
2165
+ ctx.fillStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
2166
+ ctx.fill();
2167
+ }
2168
+ if (this._$border) {
2169
+ const rgb = $intToRGBA(this._$borderColor);
2170
+ const alpha = $Math.max(0, $Math.min(rgb.A * 255 * multiColor[3] + multiColor[7], 255)) / 255;
2171
+ ctx.lineWidth = lineWidth;
2172
+ ctx.strokeStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
2173
+ ctx.stroke();
2174
+ }
2175
+ }
2176
+ // mask start
2177
+ ctx.save();
2178
+ ctx.beginPath();
2179
+ ctx.moveTo(2, 2);
2180
+ ctx.lineTo(baseWidth - 2, 2);
2181
+ ctx.lineTo(baseWidth - 2, baseHeight - 2);
2182
+ ctx.lineTo(2, baseHeight - 2);
2183
+ ctx.lineTo(2, 2);
2184
+ ctx.clip();
2185
+ ctx.beginPath();
2186
+ ctx.setTransform(xScale, 0, 0, yScale, 0, 0);
2187
+ this._$doDraw(ctx, matrix, multiColor, baseWidth / xScale);
2188
+ ctx.restore();
2189
+ texture = manager.createTextureFromCanvas(ctx.canvas);
2190
+ // set cache
2191
+ cacheStore.set(cacheKeys, texture);
2192
+ // destroy cache
2193
+ cacheStore.destroy(ctx);
2194
+ }
2195
+ let drawFilter = false;
2196
+ let offsetX = 0;
2197
+ let offsetY = 0;
2198
+ if (filters && filters.length
2199
+ && this._$canApply(filters)) {
2200
+ drawFilter = true;
2201
+ texture = this._$drawFilter(context, texture, multiMatrix, filters, width, height);
2202
+ offsetX = texture._$offsetX;
2203
+ offsetY = texture._$offsetY;
2204
+ }
2205
+ const radianX = $Math.atan2(multiMatrix[1], multiMatrix[0]);
2206
+ const radianY = $Math.atan2(-multiMatrix[2], multiMatrix[3]);
2207
+ if (!drawFilter && (radianX || radianY)) {
2208
+ const tx = baseBounds.xMin * xScale;
2209
+ const ty = baseBounds.yMin * yScale;
2210
+ const cosX = $Math.cos(radianX);
2211
+ const sinX = $Math.sin(radianX);
2212
+ const cosY = $Math.cos(radianY);
2213
+ const sinY = $Math.sin(radianY);
2214
+ context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + multiMatrix[4], tx * sinX + ty * cosY + multiMatrix[5]);
2215
+ }
2216
+ else {
2217
+ context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
2218
+ }
2219
+ // draw
2220
+ context.reset();
2221
+ context.globalAlpha = alpha;
2222
+ context.imageSmoothingEnabled = true;
2223
+ context.globalCompositeOperation = blendMode;
2224
+ context.drawImage(texture, 0, 0, texture.width, texture.height, multiColor);
2225
+ // get cache
2226
+ $poolArray(cacheKeys);
2227
+ $poolBoundsObject(baseBounds);
2228
+ // pool
2229
+ if (multiMatrix !== matrix) {
2230
+ $poolFloat32Array6(multiMatrix);
2231
+ }
2232
+ if (multiColor !== color_transform) {
2233
+ $poolFloat32Array8(multiColor);
2234
+ }
2235
+ }
2236
+ /**
2237
+ * @param {CanvasRenderingContext2D} context
2238
+ * @param {Float32Array} matrix
2239
+ * @param {Float32Array} color_transform
2240
+ * @param {number} width
2241
+ * @return {void}
2242
+ * @method
2243
+ * @private
2244
+ */
2245
+ _$doDraw(context, matrix, color_transform, width) {
2246
+ // init
2247
+ const textData = this._$getTextData();
2248
+ const limitWidth = this.width;
2249
+ const limitHeight = this.height;
2250
+ // setup
2251
+ let xOffset = 0;
2252
+ let offsetHeight = 0;
2253
+ let currentV = 0;
2254
+ let yOffset = 0;
2255
+ if (this._$verticalAlign !== "top"
2256
+ && this.height > this.textHeight) {
2257
+ switch (this._$verticalAlign) {
2258
+ case "middle":
2259
+ yOffset = (this.height - this.textHeight + 2) / 2;
2260
+ break;
2261
+ case "bottom":
2262
+ yOffset = this.height - this.textHeight + 2;
2263
+ break;
2264
+ }
2265
+ }
2266
+ for (let idx = 0; idx < textData.length; ++idx) {
2267
+ const obj = textData[idx];
2268
+ if (obj.width === 0) {
2269
+ continue;
2270
+ }
2271
+ // check
2272
+ const offsetWidth = xOffset + obj.x;
2273
+ if (this._$autoSize === "none"
2274
+ && (offsetHeight > limitHeight || offsetWidth > limitWidth)) {
2275
+ continue;
2276
+ }
2277
+ const tf = obj.textFormat;
2278
+ // color
2279
+ const rgb = $intToRGBA(tf.color || 0);
2280
+ const alpha = $Math.max(0, $Math.min(rgb.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
2281
+ context.fillStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
2282
+ if (this._$thickness) {
2283
+ const rgb = $intToRGBA(this._$thicknessColor);
2284
+ const alpha = $Math.max(0, $Math.min(rgb.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
2285
+ context.lineWidth = this._$thickness;
2286
+ context.strokeStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
2287
+ }
2288
+ const yIndex = obj.yIndex | 0;
2289
+ switch (obj.mode) {
2290
+ case "break":
2291
+ case "wrap":
2292
+ currentV++;
2293
+ if (this.scrollV > currentV) {
2294
+ continue;
2295
+ }
2296
+ offsetHeight += this._$textHeightTable[yIndex];
2297
+ xOffset = this._$getAlignOffset(this._$objectTable[yIndex], width);
2298
+ if (tf.underline) {
2299
+ const offset = tf.size ? tf.size / 12 : 0;
2300
+ const rgb = $intToRGBA(tf.color || 0);
2301
+ const alpha = $Math.max(0, $Math.min(rgb.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
2302
+ context.lineWidth = $Math.max(1, 1 / $Math.min(matrix[0], matrix[3]));
2303
+ context.strokeStyle = `rgba(${rgb.R},${rgb.G},${rgb.B},${alpha})`;
2304
+ context.beginPath();
2305
+ context.moveTo(xOffset, yOffset + offsetHeight - offset);
2306
+ context.lineTo(xOffset + this._$widthTable[yIndex], yOffset + offsetHeight - offset);
2307
+ context.stroke();
2308
+ }
2309
+ break;
2310
+ case "text":
2311
+ {
2312
+ if (this.scrollV > currentV) {
2313
+ continue;
2314
+ }
2315
+ let offsetY = offsetHeight - this._$heightTable[0];
2316
+ if (!$isSafari && tf.size) {
2317
+ offsetY += $devicePixelRatio * (tf.size / 12);
2318
+ }
2319
+ context.beginPath();
2320
+ context.textBaseline = "top";
2321
+ context.font = $generateFontStyle(tf.font || "", tf.size || 0, !!tf.italic, !!tf.bold);
2322
+ if (this._$thickness) {
2323
+ context.strokeText(obj.text, offsetWidth, yOffset + offsetY);
2324
+ }
2325
+ context.fillText(obj.text, offsetWidth, yOffset + offsetY);
2326
+ }
2327
+ break;
2328
+ case "image":
2329
+ if (!obj.loaded) {
2330
+ continue;
2331
+ }
2332
+ context.beginPath();
2333
+ context.drawImage(obj.image, obj.hspace, yOffset + obj.y, obj.width, obj.height);
2334
+ break;
2335
+ }
2336
+ }
2337
+ }
2338
+ /**
2339
+ * @param {CanvasRenderingContext2D} context
2340
+ * @param {Float32Array} matrix
2341
+ * @param {object} options
2342
+ * @return {boolean}
2343
+ * @method
2344
+ * @private
2345
+ */
2346
+ _$mouseHit(context, matrix, options) {
2347
+ if (!this._$visible) {
2348
+ return false;
2349
+ }
2350
+ return this._$hit(context, matrix, options);
2351
+ }
2352
+ /**
2353
+ * @param {CanvasRenderingContext2D} context
2354
+ * @param {Float32Array} matrix
2355
+ * @param {object} options
2356
+ * @return {boolean}
2357
+ * @method
2358
+ * @private
2359
+ */
2360
+ _$hit(context, matrix, options) {
2361
+ let multiMatrix = matrix;
2362
+ const rawMatrix = this._$transform._$rawMatrix();
2363
+ if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
2364
+ || rawMatrix[2] !== 0 || rawMatrix[3] !== 1
2365
+ || rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
2366
+ multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
2367
+ }
2368
+ const baseBounds = this._$getBounds(null);
2369
+ const bounds = $boundsMatrix(baseBounds, multiMatrix);
2370
+ const xMax = +bounds.xMax;
2371
+ const xMin = +bounds.xMin;
2372
+ const yMax = +bounds.yMax;
2373
+ const yMin = +bounds.yMin;
2374
+ $poolBoundsObject(bounds);
2375
+ $poolBoundsObject(baseBounds);
2376
+ const width = $Math.ceil($Math.abs(xMax - xMin));
2377
+ const height = $Math.ceil($Math.abs(yMax - yMin));
2378
+ context.setTransform(1, 0, 0, 1, xMin, yMin);
2379
+ context.beginPath();
2380
+ context.moveTo(0, 0);
2381
+ context.lineTo(width, 0);
2382
+ context.lineTo(width, height);
2383
+ context.lineTo(0, height);
2384
+ context.lineTo(0, 0);
2385
+ if (multiMatrix !== matrix) {
2386
+ $poolFloat32Array6(multiMatrix);
2387
+ }
2388
+ return context.isPointInPath(options.x, options.y);
2389
+ }
2390
+ /**
2391
+ * @param {number} scale
2392
+ * @return {void}
2393
+ * @method
2394
+ * @private
2395
+ */
2396
+ _$createTextAreaElement(scale) {
2397
+ // new text area
2398
+ if (!this._$textarea) {
2399
+ this._$textarea = $document.createElement("textarea");
2400
+ this._$textarea.value = this.text;
2401
+ this._$textarea.id = `${$PREFIX}_TextField_${this._$instanceId}`;
2402
+ if (!this._$wordWrap) {
2403
+ this._$textarea.wrap = "off";
2404
+ }
2405
+ const textFormat = this._$defaultTextFormat;
2406
+ // setup
2407
+ let style = "";
2408
+ style += "position: absolute;";
2409
+ style += "outline: 0;";
2410
+ style += `padding: 2px 2px 2px ${$Math.max(3, textFormat.leftMargin || 0)}px;`;
2411
+ style += "margin: 0;";
2412
+ style += "appearance: none;";
2413
+ style += "resize: none;";
2414
+ style += "overflow: hidden;";
2415
+ style += `z-index: ${0x7fffffff};`;
2416
+ style += "vertical-align: top;";
2417
+ if (this._$border) {
2418
+ style += `solid 1px #${this.borderColor.toString(16)};`;
2419
+ }
2420
+ else {
2421
+ style += "border: none;";
2422
+ }
2423
+ if (this._$border || this._$background) {
2424
+ style += `background-color: #${this.backgroundColor.toString(16)};`;
2425
+ }
2426
+ else {
2427
+ style += "background-color: top;";
2428
+ }
2429
+ this._$textarea.setAttribute("style", style);
2430
+ // add blur event
2431
+ this._$textarea.addEventListener(`${$PREFIX}_blur`, (event) => {
2432
+ // set new text
2433
+ const element = event.target;
2434
+ let value = element.value;
2435
+ if (value && this._$restrict) {
2436
+ let pattern = this._$restrict;
2437
+ if (pattern[0] !== "[") {
2438
+ pattern = "[" + pattern;
2439
+ }
2440
+ if (pattern[pattern.length - 1] !== "]") {
2441
+ pattern += "]";
2442
+ }
2443
+ const found = value.match(new $RegExp(pattern, "gm"));
2444
+ value = found ? found.join("") : "";
2445
+ }
2446
+ const player = $currentPlayer();
2447
+ const div = $document.getElementById(player.contentElementId);
2448
+ if (div) {
2449
+ const element = $document.getElementById(`${$PREFIX}_TextField_${this._$instanceId}`);
2450
+ if (element) {
2451
+ element.remove();
2452
+ }
2453
+ }
2454
+ this.text = value;
2455
+ this._$focus = false;
2456
+ this._$textAreaActive = false;
2457
+ this._$doChanged();
2458
+ $doUpdated();
2459
+ });
2460
+ // input event
2461
+ this._$textarea.addEventListener("input", (event) => {
2462
+ // set new text
2463
+ const element = event.target;
2464
+ const player = $currentPlayer();
2465
+ let value = element.value;
2466
+ // SafariではInputEvent.isComposingがundefined
2467
+ if (this._$restrict && !this._$isComposing && value) {
2468
+ let pattern = this._$restrict;
2469
+ if (pattern[0] !== "[") {
2470
+ pattern = "[" + pattern;
2471
+ }
2472
+ if (pattern[pattern.length - 1] !== "]") {
2473
+ pattern += "]";
2474
+ }
2475
+ const found = value.match(new $RegExp(pattern, "gm"));
2476
+ value = found ? found.join("") : "";
2477
+ }
2478
+ if (!this._$isComposing && this.text !== value) {
2479
+ // update
2480
+ this.text = value;
2481
+ element.value = value;
2482
+ if (this.willTrigger(Next2DEvent.CHANGE)) {
2483
+ this.dispatchEvent(new Next2DEvent(Next2DEvent.CHANGE, true));
2484
+ }
2485
+ // setup
2486
+ // const element = this._$textarea;
2487
+ const matrix = this._$transform.concatenatedMatrix;
2488
+ const bounds = this._$getBounds(null);
2489
+ element.style.left = `${$Math.floor((matrix.tx + bounds.xMin + player.x / player._$scale / $devicePixelRatio) * player._$scale)}px`;
2490
+ element.style.top = `${$Math.floor((matrix.ty + bounds.yMin + player.y / player._$scale / $devicePixelRatio) * player._$scale)}px`;
2491
+ element.style.width = `${$Math.ceil((this.width - 1) * player._$scale)}px`;
2492
+ element.style.height = `${$Math.ceil((this.height - 1) * player._$scale)}px`;
2493
+ }
2494
+ });
2495
+ // IME入力開始時のevent
2496
+ this._$textarea.addEventListener("compositionstart", () => {
2497
+ this._$isComposing = true;
2498
+ });
2499
+ // IME入力確定時のevent
2500
+ this._$textarea.addEventListener("compositionend", (event) => {
2501
+ this._$isComposing = false;
2502
+ const element = event.target;
2503
+ let value = element.value;
2504
+ if (!this._$restrict || !value) {
2505
+ return;
2506
+ }
2507
+ let pattern = this._$restrict;
2508
+ if (pattern[0] !== "[") {
2509
+ pattern = "[" + pattern;
2510
+ }
2511
+ if (pattern[pattern.length - 1] !== "]") {
2512
+ pattern += "]";
2513
+ }
2514
+ const found = value.match(new $RegExp(pattern, "gm"));
2515
+ value = found ? found.join("") : "";
2516
+ // update
2517
+ this.text = value;
2518
+ element.value = value;
2519
+ });
2520
+ // add click event
2521
+ this._$textarea.addEventListener("click", () => {
2522
+ if (this.willTrigger(Next2DMouseEvent.CLICK)) {
2523
+ this.dispatchEvent(new Next2DMouseEvent(Next2DMouseEvent.CLICK));
2524
+ }
2525
+ });
2526
+ // add mousewheel event
2527
+ this._$textarea.addEventListener($MOUSE_WHEEL, (event) => {
2528
+ this.scrollV += event.deltaY;
2529
+ });
2530
+ // add scroll event
2531
+ this._$textarea.addEventListener($SCROLL, (event) => {
2532
+ const element = event.target;
2533
+ this.scrollV = element.scrollTop
2534
+ / (element.scrollHeight - element.clientHeight)
2535
+ * this.maxScrollV + 1;
2536
+ });
2537
+ // down event
2538
+ this._$textarea.addEventListener($TOUCH_START, () => {
2539
+ const player = $currentPlayer();
2540
+ player._$state = "down";
2541
+ });
2542
+ // up event
2543
+ this._$textarea.addEventListener($TOUCH_END, () => {
2544
+ const player = $currentPlayer();
2545
+ player._$state = "up";
2546
+ });
2547
+ // down event
2548
+ this._$textarea.addEventListener($MOUSE_DOWN, () => {
2549
+ const player = $currentPlayer();
2550
+ player._$state = "down";
2551
+ });
2552
+ // up event
2553
+ this._$textarea.addEventListener($MOUSE_UP, () => {
2554
+ const player = $currentPlayer();
2555
+ player._$state = "up";
2556
+ });
2557
+ }
2558
+ // change style
2559
+ const tf = this._$defaultTextFormat;
2560
+ const fontSize = tf.size
2561
+ ? $Math.ceil(tf.size * scale * this._$transform.concatenatedMatrix.d)
2562
+ : 0;
2563
+ this._$textarea.style.fontSize = `${fontSize}px`;
2564
+ this._$textarea.style.fontFamily = tf.font || "Times New Roman";
2565
+ this._$textarea.style.lineHeight = `${(fontSize + $Math.max(0, tf.leading || 0)) / fontSize}em`;
2566
+ if (this._$autoSize !== "none") {
2567
+ this._$textarea.style.textAlign = "center";
2568
+ }
2569
+ else {
2570
+ this._$textarea.style.textAlign = tf.align || "none";
2571
+ }
2572
+ this._$textarea.addEventListener("keydown", (event) => {
2573
+ const element = event.target;
2574
+ let value = element.value;
2575
+ // SafariではInputEvent.isComposingがundefined
2576
+ if (this._$restrict && !this._$isComposing && value) {
2577
+ let pattern = this._$restrict;
2578
+ if (pattern[0] !== "[") {
2579
+ pattern = "[" + pattern;
2580
+ }
2581
+ if (pattern[pattern.length - 1] !== "]") {
2582
+ pattern += "]";
2583
+ }
2584
+ const found = value.match(new $RegExp(pattern, "gm"));
2585
+ value = found ? found.join("") : "";
2586
+ }
2587
+ // update
2588
+ if (!this._$isComposing) {
2589
+ this.text = value;
2590
+ element.value = value;
2591
+ }
2592
+ // enter off
2593
+ if (event.code === "Enter" && !this._$multiline) {
2594
+ return false;
2595
+ }
2596
+ });
2597
+ //reset
2598
+ this._$textarea.maxLength = this._$maxChars ? this._$maxChars : 0x7fffffff;
2599
+ }
2600
+ /**
2601
+ * @return {void}
2602
+ * @method
2603
+ * @private
2604
+ */
2605
+ _$createWorkerInstance() {
2606
+ if (this._$created || !$rendererWorker) {
2607
+ return;
2608
+ }
2609
+ this._$created = true;
2610
+ const bounds = this._$getBounds();
2611
+ const message = {
2612
+ "command": "createTextField",
2613
+ "instanceId": this._$instanceId,
2614
+ "parentId": this._$parent ? this._$parent._$instanceId : -1,
2615
+ "xMin": bounds.xMin,
2616
+ "yMin": bounds.yMin,
2617
+ "xMax": bounds.xMax,
2618
+ "yMax": bounds.yMax,
2619
+ "textData": this._$getTextData(),
2620
+ "scrollV": this.scrollV,
2621
+ "widthTable": this._$widthTable,
2622
+ "heightTable": this._$heightTable,
2623
+ "textHeightTable": this._$textHeightTable,
2624
+ "objectTable": this._$objectTable,
2625
+ "limitWidth": this.width,
2626
+ "limitHeight": this.height,
2627
+ "textHeight": this.textHeight,
2628
+ "verticalAlign": this._$verticalAlign,
2629
+ "autoSize": this._$autoSize,
2630
+ "wordWrap": this._$wordWrap,
2631
+ "border": this._$border,
2632
+ "background": this._$background,
2633
+ "thickness": this._$thickness
2634
+ };
2635
+ if (this._$border) {
2636
+ message.borderColor = this._$borderColor;
2637
+ }
2638
+ if (this._$background) {
2639
+ message.backgroundColor = this._$backgroundColor;
2640
+ }
2641
+ if (this._$thickness) {
2642
+ message.thicknessColor = this._$backgroundColor;
2643
+ }
2644
+ if (this._$characterId > -1) {
2645
+ message.characterId = this._$characterId;
2646
+ }
2647
+ if (this._$loaderInfo) {
2648
+ message.loaderInfoId = this._$loaderInfo._$id;
2649
+ }
2650
+ if (this._$scale9Grid) {
2651
+ message.grid = {
2652
+ "x": this._$scale9Grid.x,
2653
+ "y": this._$scale9Grid.y,
2654
+ "w": this._$scale9Grid.width,
2655
+ "h": this._$scale9Grid.height
2656
+ };
2657
+ }
2658
+ $rendererWorker.postMessage(message);
2659
+ }
2660
+ /**
2661
+ * @return {void}
2662
+ * @method
2663
+ * @private
2664
+ */
2665
+ _$postProperty() {
2666
+ if (!$rendererWorker) {
2667
+ return;
2668
+ }
2669
+ const message = this._$createMessage();
2670
+ message.textAreaActive = this._$textAreaActive;
2671
+ const bounds = this._$getBounds(null);
2672
+ message.xMin = bounds.xMin;
2673
+ message.yMin = bounds.yMin;
2674
+ message.xMax = bounds.xMax;
2675
+ message.yMax = bounds.yMax;
2676
+ $poolBoundsObject(bounds);
2677
+ if (this._$isUpdated()) {
2678
+ message.textData = this._$getTextData();
2679
+ message.scrollV = this.scrollV;
2680
+ message.widthTable = this._$widthTable;
2681
+ message.heightTable = this._$heightTable;
2682
+ message.textHeightTable = this._$textHeightTable;
2683
+ message.objectTable = this._$objectTable;
2684
+ message.limitWidth = this.width;
2685
+ message.limitHeight = this.height;
2686
+ message.textHeight = this.textHeight;
2687
+ message.verticalAlign = this._$verticalAlign;
2688
+ message.autoSize = this._$autoSize;
2689
+ message.wordWrap = this._$wordWrap;
2690
+ message.border = this._$border;
2691
+ if (this._$border) {
2692
+ message.borderColor = this._$borderColor;
2693
+ }
2694
+ message.background = this._$background;
2695
+ if (this._$background) {
2696
+ message.backgroundColor = this._$backgroundColor;
2697
+ }
2698
+ message.thickness = this._$thickness;
2699
+ if (this._$thickness) {
2700
+ message.thicknessColor = this._$backgroundColor;
2701
+ }
2702
+ }
2703
+ $rendererWorker.postMessage(message);
2704
+ this._$posted = true;
2705
+ this._$updated = false;
2706
+ }
2707
+ }