sfml.js 1.0.0 → 1.2.1

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 (313) hide show
  1. package/README.ja.md +10 -9
  2. package/README.ko.md +10 -9
  3. package/README.md +10 -9
  4. package/README.zh-CN.md +10 -9
  5. package/binding.gyp +23 -16
  6. package/dist/audio/effect-processor.js +9 -3
  7. package/dist/audio/input-sound-file.js +41 -15
  8. package/dist/audio/listener.js +33 -11
  9. package/dist/audio/music.js +41 -18
  10. package/dist/audio/output-sound-file.js +4 -2
  11. package/dist/audio/playback-device.js +11 -3
  12. package/dist/audio/sound-buffer-recorder.js +8 -5
  13. package/dist/audio/sound-buffer.js +40 -17
  14. package/dist/audio/sound-file-factory.js +21 -9
  15. package/dist/audio/sound-file-reader.js +21 -7
  16. package/dist/audio/sound-recorder.js +36 -15
  17. package/dist/audio/sound-source.js +117 -40
  18. package/dist/audio/sound-stream.js +14 -5
  19. package/dist/audio/sound.js +9 -4
  20. package/dist/audio/value.js +42 -16
  21. package/dist/graphics/blend-mode.js +2 -1
  22. package/dist/graphics/boolean-vector.d.ts +1 -2
  23. package/dist/graphics/boolean-vector.js +19 -9
  24. package/dist/graphics/color.js +2 -1
  25. package/dist/graphics/convex-shape.js +7 -3
  26. package/dist/graphics/font.js +52 -23
  27. package/dist/graphics/glsl-matrix.js +8 -3
  28. package/dist/graphics/glsl.js +47 -16
  29. package/dist/graphics/glyph.js +27 -10
  30. package/dist/graphics/image.js +30 -14
  31. package/dist/graphics/rect.js +15 -8
  32. package/dist/graphics/render-states.js +18 -9
  33. package/dist/graphics/render-target.js +49 -23
  34. package/dist/graphics/render-texture.js +24 -12
  35. package/dist/graphics/render-window.js +6 -3
  36. package/dist/graphics/shader.js +67 -32
  37. package/dist/graphics/shape.js +25 -13
  38. package/dist/graphics/sprite.js +19 -9
  39. package/dist/graphics/stencil-mode.js +10 -6
  40. package/dist/graphics/swap.js +2 -1
  41. package/dist/graphics/text.js +123 -48
  42. package/dist/graphics/texture.js +48 -24
  43. package/dist/graphics/transform.js +29 -13
  44. package/dist/graphics/transformable.js +2 -1
  45. package/dist/graphics/vertex-array.js +40 -18
  46. package/dist/graphics/vertex-buffer.js +39 -19
  47. package/dist/graphics/vertex.js +6 -3
  48. package/dist/graphics/view.js +30 -14
  49. package/dist/index.d.ts +4 -4
  50. package/dist/internal/audio-codec-registry.js +12 -6
  51. package/dist/internal/audio-input-stream.js +2 -1
  52. package/dist/internal/audio-music-pump.js +58 -24
  53. package/dist/internal/audio-recorder-session.js +17 -7
  54. package/dist/internal/audio-worker-session.js +28 -10
  55. package/dist/internal/audio-worker.js +40 -21
  56. package/dist/internal/glsl-value.d.ts +3 -1
  57. package/dist/internal/glsl-value.js +18 -8
  58. package/dist/internal/graphics-state.js +29 -15
  59. package/dist/internal/input-stream.d.ts +3 -1
  60. package/dist/internal/input-stream.js +16 -7
  61. package/dist/internal/numeric-properties.js +2 -1
  62. package/dist/internal/render-states.js +2 -1
  63. package/dist/internal/scalar.js +22 -13
  64. package/dist/internal/shaped-glyph.d.ts +3 -1
  65. package/dist/internal/shaped-glyph.js +12 -4
  66. package/dist/internal/struct-view.d.ts +3 -1
  67. package/dist/internal/struct-view.js +3 -1
  68. package/dist/internal/transformable.js +2 -1
  69. package/dist/network/common.js +23 -11
  70. package/dist/network/dns.js +25 -17
  71. package/dist/network/ftp.js +43 -18
  72. package/dist/network/http.js +126 -56
  73. package/dist/network/ip-address.js +50 -25
  74. package/dist/network/packet.js +63 -25
  75. package/dist/network/sftp.js +175 -74
  76. package/dist/network/socket-selector.js +28 -14
  77. package/dist/network/socket.js +71 -30
  78. package/dist/network/tcp-listener.js +42 -19
  79. package/dist/network/tcp-socket.js +111 -53
  80. package/dist/network/tls-material.js +2 -1
  81. package/dist/network/udp-socket.js +68 -33
  82. package/dist/system/angle.js +2 -1
  83. package/dist/system/clock.js +4 -2
  84. package/dist/system/err.js +5 -2
  85. package/dist/system/file-input-stream.js +8 -4
  86. package/dist/system/input-stream.js +6 -3
  87. package/dist/system/operators.d.ts +1 -1
  88. package/dist/system/operators.js +90 -50
  89. package/dist/system/sleep.js +4 -2
  90. package/dist/system/time.js +12 -6
  91. package/dist/system/vector2.js +6 -7
  92. package/dist/system/vector3.js +11 -6
  93. package/dist/window/clipboard.js +2 -1
  94. package/dist/window/context.js +10 -5
  95. package/dist/window/cursor.js +2 -1
  96. package/dist/window/event.js +9 -5
  97. package/dist/window/mouse.js +4 -2
  98. package/dist/window/video-mode.js +2 -1
  99. package/dist/window/window.js +19 -12
  100. package/native/addon.cc +25 -12
  101. package/native/audio-binding.cc +266 -126
  102. package/native/audio-codec-binding.cc +147 -77
  103. package/native/audio-device-binding.cc +76 -49
  104. package/native/audio-file-binding.cc +116 -67
  105. package/native/audio-recorder-binding.cc +147 -98
  106. package/native/audio-recorder.h +1 -1
  107. package/native/audio-state.h +53 -30
  108. package/native/audio-stream-binding.cc +148 -94
  109. package/native/audio-stream.h +5 -4
  110. package/native/audio-worker-binding.cc +163 -81
  111. package/native/audio-worker.h +35 -19
  112. package/native/batch-drawable.cc +29 -16
  113. package/native/batch-drawable.h +11 -8
  114. package/native/context-binding.cc +40 -27
  115. package/native/context-settings.h +15 -8
  116. package/native/deferred-delete.cc +9 -6
  117. package/native/deferred-delete.h +7 -8
  118. package/native/error-stream-binding.cc +42 -28
  119. package/native/font-binding.cc +89 -48
  120. package/native/graphics-binding.cc +122 -72
  121. package/native/graphics-state.h +50 -36
  122. package/native/image-binding.cc +38 -24
  123. package/native/image-state.h +26 -18
  124. package/native/input-binding.cc +42 -27
  125. package/native/render-window-binding.cc +38 -23
  126. package/native/shader-binding.cc +115 -50
  127. package/native/shape-binding.cc +94 -49
  128. package/native/shape-state.h +18 -9
  129. package/native/shaped-glyph-storage.h +9 -5
  130. package/native/stream-binding.cc +143 -117
  131. package/native/system-binding.cc +17 -12
  132. package/native/text-binding.cc +68 -35
  133. package/native/text-state.h +25 -18
  134. package/native/texture-binding.cc +42 -33
  135. package/native/texture-resource.h +20 -12
  136. package/native/time-value.h +3 -1
  137. package/native/transformable-binding.cc +12 -6
  138. package/native/transformable-state.h +6 -6
  139. package/native/value-binding.h +46 -28
  140. package/native/value-layout.h +10 -10
  141. package/native/values-binding.cc +29 -23
  142. package/native/vertex-binding.cc +18 -12
  143. package/native/vertex-buffer-binding.cc +38 -24
  144. package/native/vertex-storage.h +2 -2
  145. package/native/view-data.h +4 -3
  146. package/native/window-binding.cc +75 -45
  147. package/native/window-event.h +20 -11
  148. package/native/window-owner.h +15 -12
  149. package/package.json +44 -51
  150. package/src/audio/effect-processor.ts +9 -3
  151. package/src/audio/input-sound-file.ts +108 -36
  152. package/src/audio/listener.ts +39 -13
  153. package/src/audio/music.ts +112 -47
  154. package/src/audio/output-sound-file.ts +40 -11
  155. package/src/audio/playback-device.ts +23 -8
  156. package/src/audio/sound-buffer-recorder.ts +35 -13
  157. package/src/audio/sound-buffer.ts +166 -58
  158. package/src/audio/sound-file-factory.ts +127 -49
  159. package/src/audio/sound-file-reader.ts +49 -15
  160. package/src/audio/sound-recorder.ts +100 -34
  161. package/src/audio/sound-source.ts +142 -45
  162. package/src/audio/sound-stream.ts +15 -5
  163. package/src/audio/sound.ts +12 -4
  164. package/src/audio/value.ts +89 -26
  165. package/src/graphics/blend-mode.ts +3 -1
  166. package/src/graphics/boolean-vector.ts +56 -26
  167. package/src/graphics/color.ts +3 -1
  168. package/src/graphics/convex-shape.ts +10 -3
  169. package/src/graphics/font.ts +171 -50
  170. package/src/graphics/glsl-matrix.ts +9 -3
  171. package/src/graphics/glsl.ts +81 -35
  172. package/src/graphics/glyph.ts +67 -26
  173. package/src/graphics/image.ts +119 -45
  174. package/src/graphics/rect.ts +56 -24
  175. package/src/graphics/render-states.ts +31 -14
  176. package/src/graphics/render-target.ts +197 -81
  177. package/src/graphics/render-texture.ts +36 -12
  178. package/src/graphics/render-window.ts +9 -3
  179. package/src/graphics/shader.ts +186 -61
  180. package/src/graphics/shape.ts +93 -35
  181. package/src/graphics/sprite.ts +64 -25
  182. package/src/graphics/stencil-mode.ts +12 -6
  183. package/src/graphics/swap.ts +3 -2
  184. package/src/graphics/text.ts +229 -74
  185. package/src/graphics/texture.ts +180 -61
  186. package/src/graphics/transform.ts +132 -47
  187. package/src/graphics/transformable.ts +3 -1
  188. package/src/graphics/vertex-array.ts +87 -35
  189. package/src/graphics/vertex-buffer.ts +97 -33
  190. package/src/graphics/vertex.ts +9 -3
  191. package/src/graphics/view.ts +59 -21
  192. package/src/index.ts +101 -23
  193. package/src/internal/audio-codec-registry.ts +18 -6
  194. package/src/internal/audio-input-stream.ts +6 -2
  195. package/src/internal/audio-music-pump.ts +116 -41
  196. package/src/internal/audio-native.ts +249 -96
  197. package/src/internal/audio-recorder-session.ts +68 -24
  198. package/src/internal/audio-worker-session.ts +65 -21
  199. package/src/internal/audio-worker.ts +85 -41
  200. package/src/internal/glsl-value.ts +26 -11
  201. package/src/internal/graphics-state.ts +57 -20
  202. package/src/internal/input-stream.ts +23 -10
  203. package/src/internal/native.ts +252 -99
  204. package/src/internal/numeric-properties.ts +2 -1
  205. package/src/internal/render-states.ts +3 -1
  206. package/src/internal/scalar.ts +33 -14
  207. package/src/internal/shaped-glyph.ts +25 -12
  208. package/src/internal/struct-view.ts +40 -13
  209. package/src/internal/transformable.ts +3 -1
  210. package/src/network/common.ts +35 -11
  211. package/src/network/dns.ts +95 -38
  212. package/src/network/ftp.ts +129 -47
  213. package/src/network/http.ts +232 -77
  214. package/src/network/ip-address.ts +118 -48
  215. package/src/network/packet.ts +161 -54
  216. package/src/network/sftp.ts +498 -168
  217. package/src/network/socket-selector.ts +66 -26
  218. package/src/network/socket.ts +133 -46
  219. package/src/network/tcp-listener.ts +78 -29
  220. package/src/network/tcp-socket.ts +240 -95
  221. package/src/network/tls-material.ts +6 -2
  222. package/src/network/udp-socket.ts +147 -53
  223. package/src/system/angle.ts +3 -1
  224. package/src/system/clock.ts +12 -4
  225. package/src/system/err.ts +5 -2
  226. package/src/system/file-input-stream.ts +12 -4
  227. package/src/system/input-stream.ts +9 -3
  228. package/src/system/operators.ts +290 -115
  229. package/src/system/sleep.ts +6 -2
  230. package/src/system/time.ts +18 -6
  231. package/src/system/timeout-with-predicate.ts +19 -8
  232. package/src/system/vector2.ts +101 -49
  233. package/src/system/vector3.ts +85 -36
  234. package/src/window/clipboard.ts +3 -1
  235. package/src/window/context.ts +15 -5
  236. package/src/window/cursor.ts +3 -1
  237. package/src/window/event.ts +26 -12
  238. package/src/window/mouse.ts +6 -2
  239. package/src/window/video-mode.ts +3 -1
  240. package/src/window/window.ts +119 -37
  241. package/test/native/audio-probes.cc +74 -36
  242. package/test/native/deferred-delete-probes.cc +17 -11
  243. package/test/native/drawable-probes.cc +70 -36
  244. package/test/native/exception-probes.cc +14 -9
  245. package/test/native/image-probes.cc +20 -10
  246. package/test/native/matrix-probes.cc +8 -4
  247. package/test/native/network-oracle.cc +17 -11
  248. package/test/native/render-texture-probes.cc +33 -24
  249. package/test/native/shader-probes.cc +9 -9
  250. package/test/native/shape-probes.cc +37 -23
  251. package/test/native/sprite-probes.cc +41 -25
  252. package/test/native/system-probes.cc +58 -35
  253. package/test/native/text-probes.cc +77 -44
  254. package/test/native/texture-probes.cc +43 -26
  255. package/test/native/time-probes.cc +18 -12
  256. package/test/native/transform-probes.cc +15 -10
  257. package/test/native/transformable-probes.cc +23 -17
  258. package/test/native/value-oracle.h +9 -4
  259. package/test/native/value-probes.cc +31 -23
  260. package/test/native/vertex-array-probes.cc +22 -14
  261. package/test/native/vertex-buffer-probes.cc +28 -17
  262. package/test/native/view-probes.cc +29 -17
  263. package/test/native/window-probes.cc +66 -33
  264. package/tools/ensure-sfml.cjs +9 -0
  265. package/tools/generate-network-constants.cjs +11 -6
  266. package/tools/generate-window-constants.cjs +31 -12
  267. package/docs/README.ja.md +0 -30
  268. package/docs/README.ko.md +0 -30
  269. package/docs/README.md +0 -30
  270. package/docs/README.zh-CN.md +0 -30
  271. package/docs/api.ja.md +0 -84
  272. package/docs/api.ko.md +0 -84
  273. package/docs/api.md +0 -81
  274. package/docs/api.zh-CN.md +0 -81
  275. package/docs/audio.ja.md +0 -249
  276. package/docs/audio.ko.md +0 -251
  277. package/docs/audio.md +0 -252
  278. package/docs/audio.zh-CN.md +0 -252
  279. package/docs/concepts.ja.md +0 -130
  280. package/docs/concepts.ko.md +0 -130
  281. package/docs/concepts.md +0 -131
  282. package/docs/concepts.zh-CN.md +0 -131
  283. package/docs/development.ja.md +0 -144
  284. package/docs/development.ko.md +0 -144
  285. package/docs/development.md +0 -146
  286. package/docs/development.zh-CN.md +0 -146
  287. package/docs/getting-started.ja.md +0 -154
  288. package/docs/getting-started.ko.md +0 -154
  289. package/docs/getting-started.md +0 -156
  290. package/docs/getting-started.zh-CN.md +0 -156
  291. package/docs/graphics.ja.md +0 -256
  292. package/docs/graphics.ko.md +0 -254
  293. package/docs/graphics.md +0 -255
  294. package/docs/graphics.zh-CN.md +0 -257
  295. package/docs/network.ja.md +0 -214
  296. package/docs/network.ko.md +0 -216
  297. package/docs/network.md +0 -218
  298. package/docs/network.zh-CN.md +0 -218
  299. package/docs/system.ja.md +0 -169
  300. package/docs/system.ko.md +0 -171
  301. package/docs/system.md +0 -173
  302. package/docs/system.zh-CN.md +0 -173
  303. package/docs/window.ja.md +0 -138
  304. package/docs/window.ko.md +0 -140
  305. package/docs/window.md +0 -141
  306. package/docs/window.zh-CN.md +0 -141
  307. package/native/exception-boundary.h +0 -97
  308. package/native/numeric-fields.h +0 -96
  309. package/native/shared-handle.h +0 -107
  310. package/test/tsconfig.json +0 -8
  311. package/tools/configure-lsp.cjs +0 -23
  312. package/tools/lib_downloader.cjs +0 -92
  313. package/tools/lib_downloader_urls.cjs +0 -23
@@ -1,24 +1,40 @@
1
1
  import {
2
- dispatchDrawable, graphicsFlush, recordSprite, registerTarget, spriteState,
3
- recordVertices, textureId, graphicsReads, validateTextureRead, type SpriteData,
4
- recordVertexBuffer, vertexBufferId, shaderId, shaderTextures,
5
- recordShape, shapeState, graphicsShapeReads, type ShapeData,
2
+ dispatchDrawable,
3
+ graphicsFlush,
4
+ recordSprite,
5
+ registerTarget,
6
+ spriteState,
7
+ recordVertices,
8
+ textureId,
9
+ graphicsReads,
10
+ validateTextureRead,
11
+ type SpriteData,
12
+ recordVertexBuffer,
13
+ vertexBufferId,
14
+ shaderId,
15
+ shaderTextures,
16
+ recordShape,
17
+ shapeState,
18
+ graphicsShapeReads,
19
+ type ShapeData,
6
20
  } from '../internal/graphics-state';
7
21
  import {
8
- transformableState, type TransformableState,
22
+ transformableState,
23
+ type TransformableState,
9
24
  } from '../internal/transformable';
10
25
  import {
11
- defaultRenderStates, validateRenderStates,
26
+ defaultRenderStates,
27
+ validateRenderStates,
12
28
  } from '../internal/render-states';
13
29
  import {
14
- transformStorage, vertexStorage, type ReadonlyValue,
30
+ transformStorage,
31
+ vertexStorage,
32
+ type ReadonlyValue,
15
33
  } from '../internal/value-storage';
16
34
  import { Vector2, Vector2u, Vector2i, Vector2f } from '../system/vector2';
17
35
  import { Color } from './color';
18
36
  import { Drawable } from './drawable';
19
- import {
20
- RenderStates, type RenderStatesInput,
21
- } from './render-states';
37
+ import { RenderStates, type RenderStatesInput } from './render-states';
22
38
  import { StencilValue } from './stencil-mode';
23
39
  import { PrimitiveType, validatePrimitiveType } from './primitive-type';
24
40
  import { Vertex } from './vertex';
@@ -96,7 +112,9 @@ export abstract class RenderTarget {
96
112
  * @ko 대기 중인 그리기를 제출하고 OpenGL 컨텍스트를 활성화하거나 비활성화합니다. 성공 여부를 반환합니다.
97
113
  */
98
114
  setActive(active = true): boolean {
99
- if (typeof active !== 'boolean') throw new TypeError('Expected a boolean');
115
+ if (typeof active !== 'boolean') {
116
+ throw new TypeError('Expected a boolean');
117
+ }
100
118
  this.flush();
101
119
  return this.activate(active);
102
120
  }
@@ -109,7 +127,9 @@ export abstract class RenderTarget {
109
127
  * @ko 이후 그리기에 사용할 뷰를 복사하여 설정합니다. 이미 기록된 그리기는 원래 뷰를 유지합니다.
110
128
  */
111
129
  setView(view: ReadonlyValue<View>): void {
112
- if (!(view instanceof View)) throw new TypeError('Expected a View');
130
+ if (!(view instanceof View)) {
131
+ throw new TypeError('Expected a View');
132
+ }
113
133
  const offset = this.nextCommand();
114
134
  this.words[offset] = 5;
115
135
  writeView(view, this.floats, offset + 9);
@@ -144,7 +164,9 @@ export abstract class RenderTarget {
144
164
  * @ko view의 정규화된 뷰포트를 대상의 픽셀 사각형으로 변환합니다.
145
165
  */
146
166
  getViewport(view: ReadonlyValue<View>): IntRect {
147
- if (!(view instanceof View)) throw new TypeError('Expected a View');
167
+ if (!(view instanceof View)) {
168
+ throw new TypeError('Expected a View');
169
+ }
148
170
  return this.pixelRectangle(view.getViewport());
149
171
  }
150
172
 
@@ -155,7 +177,9 @@ export abstract class RenderTarget {
155
177
  * @ko view의 정규화된 시저 영역을 픽셀 사각형으로 변환합니다.
156
178
  */
157
179
  getScissor(view: ReadonlyValue<View>): IntRect {
158
- if (!(view instanceof View)) throw new TypeError('Expected a View');
180
+ if (!(view instanceof View)) {
181
+ throw new TypeError('Expected a View');
182
+ }
159
183
  return this.pixelRectangle(view.getScissor());
160
184
  }
161
185
 
@@ -167,7 +191,8 @@ export abstract class RenderTarget {
167
191
  * @ko 대상의 픽셀 좌표를 월드 좌표로 변환합니다. view를 생략하면 현재 뷰를 사용합니다.
168
192
  */
169
193
  mapPixelToCoords(
170
- point: ReadonlyValue<Vector2i>, view: ReadonlyValue<View> = this.currentView,
194
+ point: ReadonlyValue<Vector2i>,
195
+ view: ReadonlyValue<View> = this.currentView,
171
196
  ): Vector2f {
172
197
  if (!(point instanceof Vector2) || point.scalarType !== 'i32') {
173
198
  throw new TypeError('Expected a Vector2i');
@@ -175,10 +200,14 @@ export abstract class RenderTarget {
175
200
  const viewport = this.getViewport(view);
176
201
  const x = f(f(point.x) - f(viewport.position.x));
177
202
  const y = f(f(point.y) - f(viewport.position.y));
178
- return view.getInverseTransform().transformPoint(new Vector2f(
179
- f(-1 + f(f(2 * x) / f(viewport.size.x))),
180
- f(1 + f(f(-2 * y) / f(viewport.size.y))),
181
- ));
203
+ return view
204
+ .getInverseTransform()
205
+ .transformPoint(
206
+ new Vector2f(
207
+ f(-1 + f(f(2 * x) / f(viewport.size.x))),
208
+ f(1 + f(f(-2 * y) / f(viewport.size.y))),
209
+ ),
210
+ );
182
211
  }
183
212
 
184
213
  /**
@@ -189,7 +218,8 @@ export abstract class RenderTarget {
189
218
  * @ko 월드 좌표를 대상의 정수 픽셀 좌표로 변환합니다. view를 생략하면 현재 뷰를 사용합니다.
190
219
  */
191
220
  mapCoordsToPixel(
192
- point: ReadonlyValue<Vector2f>, view: ReadonlyValue<View> = this.currentView,
221
+ point: ReadonlyValue<Vector2f>,
222
+ view: ReadonlyValue<View> = this.currentView,
193
223
  ): Vector2i {
194
224
  if (!(point instanceof Vector2) || point.scalarType !== 'f32') {
195
225
  throw new TypeError('Expected a Vector2f');
@@ -197,10 +227,14 @@ export abstract class RenderTarget {
197
227
  const viewport = this.getViewport(view);
198
228
  const normalized = view.getTransform().transformPoint(point);
199
229
  return new Vector2i(
200
- f(f(f(f(normalized.x + 1) / 2) * f(viewport.size.x)) +
201
- f(viewport.position.x)),
202
- f(f(f(f(-normalized.y + 1) / 2) * f(viewport.size.y)) +
203
- f(viewport.position.y)),
230
+ f(
231
+ f(f(f(normalized.x + 1) / 2) * f(viewport.size.x)) +
232
+ f(viewport.position.x),
233
+ ),
234
+ f(
235
+ f(f(f(-normalized.y + 1) / 2) * f(viewport.size.y)) +
236
+ f(viewport.position.y),
237
+ ),
204
238
  );
205
239
  }
206
240
 
@@ -245,21 +279,25 @@ export abstract class RenderTarget {
245
279
  * @ko 네이티브 생성 또는 크기 변경이 성공한 후에만 호출됩니다.
246
280
  */
247
281
  protected initializeViews(size: Readonly<Vector2u>): void {
248
- const view = new View(new FloatRect(
249
- new Vector2f(), new Vector2f(size.x, size.y)));
282
+ const view = new View(
283
+ new FloatRect(new Vector2f(), new Vector2f(size.x, size.y)),
284
+ );
250
285
  copyView(this.defaultView, view);
251
286
  copyView(this.currentView, view);
252
287
  }
253
288
 
254
289
  private pixelRectangle(rectangle: ReadonlyValue<FloatRect>): IntRect {
255
290
  const size = this.getSize();
256
- return new IntRect(new Vector2i(
257
- roundAway(f(f(size.x) * rectangle.position.x)),
258
- roundAway(f(f(size.y) * rectangle.position.y)),
259
- ), new Vector2i(
260
- roundAway(f(f(size.x) * rectangle.size.x)),
261
- roundAway(f(f(size.y) * rectangle.size.y)),
262
- ));
291
+ return new IntRect(
292
+ new Vector2i(
293
+ roundAway(f(f(size.x) * rectangle.position.x)),
294
+ roundAway(f(f(size.y) * rectangle.position.y)),
295
+ ),
296
+ new Vector2i(
297
+ roundAway(f(f(size.x) * rectangle.size.x)),
298
+ roundAway(f(f(size.y) * rectangle.size.y)),
299
+ ),
300
+ );
263
301
  }
264
302
 
265
303
  /**
@@ -273,9 +311,12 @@ export abstract class RenderTarget {
273
311
  color: ReadonlyValue<Color> = Color.Black,
274
312
  stencil?: number | Readonly<StencilValue>,
275
313
  ): void {
276
- if (!(color instanceof Color)) throw new TypeError('Expected a Color');
314
+ if (!(color instanceof Color)) {
315
+ throw new TypeError('Expected a Color');
316
+ }
277
317
  const rgba = color.toInteger();
278
- const value = stencil === undefined ? 0 : new StencilValue(stencil).value;
318
+ const value =
319
+ stencil === undefined ? 0 : new StencilValue(stencil).value;
279
320
  const offset = this.nextCommand();
280
321
  this.words[offset] = stencil === undefined ? 0 : 2;
281
322
  this.words[offset + 1] = rgba;
@@ -319,8 +360,12 @@ export abstract class RenderTarget {
319
360
  * @ja firstVertex から vertexCount 個の頂点を描画し、末尾を超える数は自動的に切り詰めます。
320
361
  * @ko firstVertex부터 vertexCount개의 꼭짓점을 그리며 끝을 초과하는 수는 자동으로 잘립니다.
321
362
  */
322
- draw(buffer: VertexBuffer, firstVertex: number, vertexCount: number,
323
- states?: RenderStatesInput): void;
363
+ draw(
364
+ buffer: VertexBuffer,
365
+ firstVertex: number,
366
+ vertexCount: number,
367
+ states?: RenderStatesInput,
368
+ ): void;
324
369
  /**
325
370
  * Copies a vertex snapshot and records a draw using type; states defaults to
326
371
  * RenderStates.Default.
@@ -329,33 +374,55 @@ export abstract class RenderTarget {
329
374
  * @ko 꼭짓점 스냅샷을 복사하고 type에 따라 그리기를 기록합니다. states의 기본값은
330
375
  * RenderStates.Default입니다.
331
376
  */
332
- draw(vertices: readonly ReadonlyValue<Vertex>[], type: PrimitiveType,
333
- states?: RenderStatesInput): void;
334
- draw(drawable: Drawable | readonly ReadonlyValue<Vertex>[],
377
+ draw(
378
+ vertices: readonly ReadonlyValue<Vertex>[],
379
+ type: PrimitiveType,
380
+ states?: RenderStatesInput,
381
+ ): void;
382
+ draw(
383
+ drawable: Drawable | readonly ReadonlyValue<Vertex>[],
335
384
  statesOrType: RenderStatesInput | number = defaultRenderStates,
336
385
  statesOrCount: RenderStatesInput | number = defaultRenderStates,
337
- rangeStates: RenderStatesInput = defaultRenderStates): void {
338
- if (drawable instanceof VertexBuffer && typeof statesOrType === 'number') {
339
- const value = rangeStates instanceof RenderStates
340
- ? rangeStates : new RenderStates(rangeStates);
341
- this[recordVertexBuffer](drawable, statesOrType,
342
- statesOrCount as number, value);
386
+ rangeStates: RenderStatesInput = defaultRenderStates,
387
+ ): void {
388
+ if (
389
+ drawable instanceof VertexBuffer &&
390
+ typeof statesOrType === 'number'
391
+ ) {
392
+ const value =
393
+ rangeStates instanceof RenderStates
394
+ ? rangeStates
395
+ : new RenderStates(rangeStates);
396
+ this[recordVertexBuffer](
397
+ drawable,
398
+ statesOrType,
399
+ statesOrCount as number,
400
+ value,
401
+ );
343
402
  return;
344
403
  }
345
404
  if (drawable instanceof Drawable) {
346
- const value = statesOrType instanceof RenderStates
347
- ? statesOrType : new RenderStates(statesOrType as RenderStatesInput);
405
+ const value =
406
+ statesOrType instanceof RenderStates
407
+ ? statesOrType
408
+ : new RenderStates(statesOrType as RenderStatesInput);
348
409
  drawable[dispatchDrawable](this, value);
349
410
  return;
350
411
  }
351
- if (!Array.isArray(drawable)) throw new TypeError('Expected a Drawable');
412
+ if (!Array.isArray(drawable)) {
413
+ throw new TypeError('Expected a Drawable');
414
+ }
352
415
  validatePrimitiveType(statesOrType as PrimitiveType);
353
- const value = statesOrCount instanceof RenderStates
354
- ? statesOrCount : new RenderStates(statesOrCount as RenderStatesInput);
416
+ const value =
417
+ statesOrCount instanceof RenderStates
418
+ ? statesOrCount
419
+ : new RenderStates(statesOrCount as RenderStatesInput);
355
420
  validateRenderStates(value);
356
421
  // Validate and capture every view before touching the command queue.
357
422
  const vertices = drawable.map(vertex => {
358
- if (!(vertex instanceof Vertex)) throw new TypeError('Expected a Vertex');
423
+ if (!(vertex instanceof Vertex)) {
424
+ throw new TypeError('Expected a Vertex');
425
+ }
359
426
  return vertex[vertexStorage];
360
427
  });
361
428
  // Array holes must not turn into partially initialized draw commands.
@@ -364,13 +431,17 @@ export abstract class RenderTarget {
364
431
  throw new TypeError('Expected attached Vertex values');
365
432
  }
366
433
  }
367
- this.writeVertices(vertices.length, statesOrType as PrimitiveType, value,
434
+ this.writeVertices(
435
+ vertices.length,
436
+ statesOrType as PrimitiveType,
437
+ value,
368
438
  offset => {
369
439
  for (const vertex of vertices) {
370
440
  this.vertexBytes.set(vertex, offset);
371
441
  offset += 20;
372
442
  }
373
- });
443
+ },
444
+ );
374
445
  }
375
446
 
376
447
  /**
@@ -380,7 +451,9 @@ export abstract class RenderTarget {
380
451
  * @ko 외부 그래픽 작업 전에 대기 중인 그리기를 제출합니다.
381
452
  */
382
453
  flush(): void {
383
- if (this.count !== 0) this.submit(false);
454
+ if (this.count !== 0) {
455
+ this.submit(false);
456
+ }
384
457
  }
385
458
 
386
459
  [graphicsFlush](): void {
@@ -400,7 +473,9 @@ export abstract class RenderTarget {
400
473
  const appearance = shape[shapeState];
401
474
  validateTextureRead(this, appearance.texture);
402
475
  this.validateShaderReads(states);
403
- const matrix = new Transform(states.transform).combine(shape.getTransform());
476
+ const matrix = new Transform(states.transform).combine(
477
+ shape.getTransform(),
478
+ );
404
479
  const offset = this.nextCommand();
405
480
  this.words[offset] = 7;
406
481
  this.words[offset + 1] = appearance.id;
@@ -408,7 +483,9 @@ export abstract class RenderTarget {
408
483
  this.floats.set(matrix[transformStorage], offset + 9);
409
484
  this.writeModes(offset, states);
410
485
  this.pendingShapes.add(shape);
411
- if (appearance.texture) this.pendingTextures.add(appearance.texture);
486
+ if (appearance.texture) {
487
+ this.pendingTextures.add(appearance.texture);
488
+ }
412
489
  }
413
490
 
414
491
  [recordSprite](sprite: SpriteCommandSource, states: RenderStates): void {
@@ -432,23 +509,39 @@ export abstract class RenderTarget {
432
509
  this.pendingTextures.add(appearance.texture);
433
510
  }
434
511
 
435
- [recordVertices](bytes: Uint8Array, type: PrimitiveType,
436
- states: RenderStates): void {
512
+ [recordVertices](
513
+ bytes: Uint8Array,
514
+ type: PrimitiveType,
515
+ states: RenderStates,
516
+ ): void {
437
517
  validateRenderStates(states);
438
518
  validatePrimitiveType(type);
439
- this.writeVertices(bytes.byteLength / 20, type, states,
440
- offset => this.vertexBytes.set(bytes, offset));
519
+ this.writeVertices(bytes.byteLength / 20, type, states, offset =>
520
+ this.vertexBytes.set(bytes, offset),
521
+ );
441
522
  }
442
523
 
443
- [recordVertexBuffer](buffer: VertexBuffer, first: number, count: number,
444
- states: RenderStates): void {
524
+ [recordVertexBuffer](
525
+ buffer: VertexBuffer,
526
+ first: number,
527
+ count: number,
528
+ states: RenderStates,
529
+ ): void {
445
530
  validateRenderStates(states);
446
- if (!Number.isInteger(first) || first < 0 || first > 0xffffffff ||
447
- !Number.isInteger(count) || count < 0 || count > 0xffffffff) {
531
+ if (
532
+ !Number.isInteger(first) ||
533
+ first < 0 ||
534
+ first > 0xffffffff ||
535
+ !Number.isInteger(count) ||
536
+ count < 0 ||
537
+ count > 0xffffffff
538
+ ) {
448
539
  throw new RangeError('Vertex range is out of bounds');
449
540
  }
450
541
  const available = buffer.getVertexCount();
451
- if (first >= available || count === 0) return;
542
+ if (first >= available || count === 0) {
543
+ return;
544
+ }
452
545
  count = Math.min(count, available - first);
453
546
  validateTextureRead(this, states.texture);
454
547
  this.validateShaderReads(states);
@@ -463,7 +556,9 @@ export abstract class RenderTarget {
463
556
  this.floats.set(states.transform[transformStorage], offset + 9);
464
557
  this.writeModes(offset, states);
465
558
  this.pendingBuffers.add(buffer);
466
- if (states.texture) this.pendingTextures.add(states.texture);
559
+ if (states.texture) {
560
+ this.pendingTextures.add(states.texture);
561
+ }
467
562
  }
468
563
 
469
564
  private writeModes(offset: number, states: RenderStates): void {
@@ -490,31 +585,48 @@ export abstract class RenderTarget {
490
585
  }
491
586
 
492
587
  private validateShaderReads(states: RenderStates): void {
493
- if (!states.shader) return;
588
+ if (!states.shader) {
589
+ return;
590
+ }
494
591
  for (const texture of states.shader[shaderTextures].values()) {
495
592
  validateTextureRead(this, texture);
496
593
  }
497
594
  }
498
595
 
499
- private writeVertices(count: number, type: PrimitiveType,
500
- states: RenderStates, copy: (offset: number) => void): void {
501
- if (!Number.isInteger(count) || count < 0 ||
502
- count > Math.floor(0x7fffffff / 20)) {
596
+ private writeVertices(
597
+ count: number,
598
+ type: PrimitiveType,
599
+ states: RenderStates,
600
+ copy: (offset: number) => void,
601
+ ): void {
602
+ if (
603
+ !Number.isInteger(count) ||
604
+ count < 0 ||
605
+ count > Math.floor(0x7fffffff / 20)
606
+ ) {
503
607
  throw new RangeError('Vertex count exceeds the buffer limit');
504
608
  }
505
- if (count === 0) return;
609
+ if (count === 0) {
610
+ return;
611
+ }
506
612
  validateTextureRead(this, states.texture);
507
613
  this.validateShaderReads(states);
508
614
  const matrix = states.transform[transformStorage];
509
- if (this.count === this.words.length / commandWords ||
510
- (this.vertexCount !== 0 &&
511
- (this.vertexCount + count) * 20 > this.vertexBytes.byteLength)) {
615
+ if (
616
+ this.count === this.words.length / commandWords ||
617
+ (this.vertexCount !== 0 &&
618
+ (this.vertexCount + count) * 20 > this.vertexBytes.byteLength)
619
+ ) {
512
620
  this.flush();
513
621
  }
514
622
  if (count * 20 > this.vertexBytes.byteLength) {
515
- const capacity = Math.min(Math.floor(0x7fffffff / 20),
516
- Math.max(4096, count, this.vertexBytes.byteLength / 10));
517
- this.vertexBytes = new Uint8Array(this.allocateVertexBuffer(capacity));
623
+ const capacity = Math.min(
624
+ Math.floor(0x7fffffff / 20),
625
+ Math.max(4096, count, this.vertexBytes.byteLength / 10),
626
+ );
627
+ this.vertexBytes = new Uint8Array(
628
+ this.allocateVertexBuffer(capacity),
629
+ );
518
630
  }
519
631
  // Copy before reserving: a failed copy cannot leave a partial command.
520
632
  copy(this.vertexCount * 20);
@@ -528,7 +640,9 @@ export abstract class RenderTarget {
528
640
  this.floats.set(matrix, offset + 9);
529
641
  this.writeModes(offset, states);
530
642
  this.vertexCount += count;
531
- if (states.texture) this.pendingTextures.add(states.texture);
643
+ if (states.texture) {
644
+ this.pendingTextures.add(states.texture);
645
+ }
532
646
  }
533
647
 
534
648
  protected abstract submitCommands(count: number, display: boolean): void;
@@ -548,7 +662,9 @@ export abstract class RenderTarget {
548
662
  }
549
663
 
550
664
  private nextCommand(): number {
551
- if (this.count === this.words.length / commandWords) this.submit(false);
665
+ if (this.count === this.words.length / commandWords) {
666
+ this.submit(false);
667
+ }
552
668
  return this.count++ * commandWords;
553
669
  }
554
670
  }
@@ -28,7 +28,9 @@ function coordinates(size: Readonly<Vector2u>): void {
28
28
  }
29
29
 
30
30
  function flag(value: boolean): void {
31
- if (typeof value !== 'boolean') throw new TypeError('Expected a boolean');
31
+ if (typeof value !== 'boolean') {
32
+ throw new TypeError('Expected a boolean');
33
+ }
32
34
  }
33
35
 
34
36
  /**
@@ -61,7 +63,9 @@ export class RenderTexture extends RenderTarget {
61
63
  constructor(
62
64
  size?: Readonly<Vector2u>, settings: Readonly<ContextSettings> = {},
63
65
  ) {
64
- if (size !== undefined) coordinates(size);
66
+ if (size !== undefined) {
67
+ coordinates(size);
68
+ }
65
69
  const requested = contextSettings(settings);
66
70
  const { handle, buffer, info, targetInfo } = native.createRenderTexture(
67
71
  graphicsContext(), size?.x, size?.y, requested,
@@ -70,7 +74,9 @@ export class RenderTexture extends RenderTarget {
70
74
  this[graphicsNative] = handle;
71
75
  this.state = nativeStruct<NativeTextureInfo>(info);
72
76
  this.targetInfo = nativeStruct<{ sRgb: boolean }>(targetInfo);
73
- if (size) this.initializeViews(size);
77
+ if (size) {
78
+ this.initializeViews(size);
79
+ }
74
80
  }
75
81
 
76
82
  /**
@@ -94,7 +100,9 @@ export class RenderTexture extends RenderTarget {
94
100
  ): boolean {
95
101
  coordinates(size);
96
102
  const requested = contextSettings(settings);
97
- if (this.texture) flushTextureReaders(this);
103
+ if (this.texture) {
104
+ flushTextureReaders(this);
105
+ }
98
106
  this.flush();
99
107
  const info = native.resizeRenderTexture(
100
108
  this[graphicsNative], size.x, size.y, requested,
@@ -124,8 +132,12 @@ export class RenderTexture extends RenderTarget {
124
132
  */
125
133
  setSmooth(smooth: boolean): void {
126
134
  flag(smooth);
127
- if (smooth === this.state.smooth) return;
128
- if (this.texture) flushTextureReaders(this);
135
+ if (smooth === this.state.smooth) {
136
+ return;
137
+ }
138
+ if (this.texture) {
139
+ flushTextureReaders(this);
140
+ }
129
141
  native.setRenderTextureSmooth(this[graphicsNative], smooth);
130
142
  }
131
143
 
@@ -147,8 +159,12 @@ export class RenderTexture extends RenderTarget {
147
159
  */
148
160
  setRepeated(repeated: boolean): void {
149
161
  flag(repeated);
150
- if (repeated === this.state.repeated) return;
151
- if (this.texture) flushTextureReaders(this);
162
+ if (repeated === this.state.repeated) {
163
+ return;
164
+ }
165
+ if (this.texture) {
166
+ flushTextureReaders(this);
167
+ }
152
168
  native.setRenderTextureRepeated(this[graphicsNative], repeated);
153
169
  }
154
170
 
@@ -179,7 +195,9 @@ export class RenderTexture extends RenderTarget {
179
195
  * @ko 그린 후 display()를 호출한 다음 해당 이미지의 mipmap을 생성합니다.
180
196
  */
181
197
  generateMipmap(): boolean {
182
- if (this.texture) flushTextureReaders(this);
198
+ if (this.texture) {
199
+ flushTextureReaders(this);
200
+ }
183
201
  return native.generateRenderTextureMipmap(this[graphicsNative]);
184
202
  }
185
203
 
@@ -190,12 +208,16 @@ export class RenderTexture extends RenderTarget {
190
208
  * @ko OpenGL에 직접 접근하거나 비활성화하기 전에 기록된 작업을 완료합니다.
191
209
  */
192
210
  protected activate(active: boolean): boolean {
193
- if (active && this.texture) flushTextureReaders(this);
211
+ if (active && this.texture) {
212
+ flushTextureReaders(this);
213
+ }
194
214
  return native.setRenderTextureActive(this[graphicsNative], active);
195
215
  }
196
216
 
197
217
  protected changeGLStates(operation: 0 | 1 | 2): void {
198
- if (this.texture) flushTextureReaders(this);
218
+ if (this.texture) {
219
+ flushTextureReaders(this);
220
+ }
199
221
  native.changeRenderTextureGLStates(this[graphicsNative], operation);
200
222
  }
201
223
 
@@ -224,7 +246,9 @@ export class RenderTexture extends RenderTarget {
224
246
  }
225
247
 
226
248
  protected submitCommands(count: number, display: boolean): void {
227
- if (this.texture) flushTextureReaders(this);
249
+ if (this.texture) {
250
+ flushTextureReaders(this);
251
+ }
228
252
  native.submitRenderTexture(this[graphicsNative], count, display);
229
253
  }
230
254
 
@@ -89,7 +89,9 @@ export class RenderWindow extends RenderTarget {
89
89
  const initializeViews = () => {
90
90
  super.initializeViews(Window.prototype.getSize.call(this));
91
91
  };
92
- if (native.isWindowOpen(this[graphicsNative])) initializeViews();
92
+ if (native.isWindowOpen(this[graphicsNative])) {
93
+ initializeViews();
94
+ }
93
95
  registerWindowHooks(this, () => {
94
96
  initializeViews();
95
97
  this.onCreate();
@@ -169,7 +171,9 @@ export class RenderWindow extends RenderTarget {
169
171
  * @ko 클라이언트 영역의 최소 픽셀 크기를 설정합니다. undefined는 제한을 해제합니다.
170
172
  */
171
173
  setMinimumSize(size: Readonly<Vector2u> | undefined): void {
172
- if (size !== undefined) windowSize(size);
174
+ if (size !== undefined) {
175
+ windowSize(size);
176
+ }
173
177
  this.flush();
174
178
  Window.prototype.setMinimumSize.call(this, size);
175
179
  }
@@ -181,7 +185,9 @@ export class RenderWindow extends RenderTarget {
181
185
  * @ko 클라이언트 영역의 최대 픽셀 크기를 설정합니다. undefined는 제한을 해제합니다.
182
186
  */
183
187
  setMaximumSize(size: Readonly<Vector2u> | undefined): void {
184
- if (size !== undefined) windowSize(size);
188
+ if (size !== undefined) {
189
+ windowSize(size);
190
+ }
185
191
  this.flush();
186
192
  Window.prototype.setMaximumSize.call(this, size);
187
193
  }