sfml.js 1.0.0-rc.2 → 1.1.0

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 (314) hide show
  1. package/README.ja.md +16 -11
  2. package/README.ko.md +16 -11
  3. package/README.md +16 -11
  4. package/README.zh-CN.md +16 -11
  5. package/assets/breakout.png +0 -0
  6. package/binding.gyp +23 -16
  7. package/dist/audio/effect-processor.js +9 -3
  8. package/dist/audio/input-sound-file.js +41 -15
  9. package/dist/audio/listener.js +33 -11
  10. package/dist/audio/music.js +41 -18
  11. package/dist/audio/output-sound-file.js +4 -2
  12. package/dist/audio/playback-device.js +11 -3
  13. package/dist/audio/sound-buffer-recorder.js +8 -5
  14. package/dist/audio/sound-buffer.js +40 -17
  15. package/dist/audio/sound-file-factory.js +21 -9
  16. package/dist/audio/sound-file-reader.js +21 -7
  17. package/dist/audio/sound-recorder.js +36 -15
  18. package/dist/audio/sound-source.js +117 -40
  19. package/dist/audio/sound-stream.js +14 -5
  20. package/dist/audio/sound.js +9 -4
  21. package/dist/audio/value.js +42 -16
  22. package/dist/graphics/blend-mode.js +2 -1
  23. package/dist/graphics/boolean-vector.d.ts +1 -2
  24. package/dist/graphics/boolean-vector.js +19 -9
  25. package/dist/graphics/color.js +2 -1
  26. package/dist/graphics/convex-shape.js +7 -3
  27. package/dist/graphics/font.js +52 -23
  28. package/dist/graphics/glsl-matrix.js +8 -3
  29. package/dist/graphics/glsl.js +47 -16
  30. package/dist/graphics/glyph.js +27 -10
  31. package/dist/graphics/image.js +30 -14
  32. package/dist/graphics/rect.js +15 -8
  33. package/dist/graphics/render-states.js +18 -9
  34. package/dist/graphics/render-target.js +49 -23
  35. package/dist/graphics/render-texture.js +24 -12
  36. package/dist/graphics/render-window.js +6 -3
  37. package/dist/graphics/shader.js +67 -32
  38. package/dist/graphics/shape.js +25 -13
  39. package/dist/graphics/sprite.js +19 -9
  40. package/dist/graphics/stencil-mode.js +10 -6
  41. package/dist/graphics/swap.js +2 -1
  42. package/dist/graphics/text.js +123 -48
  43. package/dist/graphics/texture.js +48 -24
  44. package/dist/graphics/transform.js +29 -13
  45. package/dist/graphics/transformable.js +2 -1
  46. package/dist/graphics/vertex-array.js +40 -18
  47. package/dist/graphics/vertex-buffer.js +39 -19
  48. package/dist/graphics/vertex.js +6 -3
  49. package/dist/graphics/view.js +30 -14
  50. package/dist/index.d.ts +4 -4
  51. package/dist/internal/audio-codec-registry.js +12 -6
  52. package/dist/internal/audio-input-stream.js +2 -1
  53. package/dist/internal/audio-music-pump.js +58 -24
  54. package/dist/internal/audio-recorder-session.js +17 -7
  55. package/dist/internal/audio-worker-session.js +28 -10
  56. package/dist/internal/audio-worker.js +40 -21
  57. package/dist/internal/glsl-value.d.ts +3 -1
  58. package/dist/internal/glsl-value.js +18 -8
  59. package/dist/internal/graphics-state.js +29 -15
  60. package/dist/internal/input-stream.d.ts +3 -1
  61. package/dist/internal/input-stream.js +16 -7
  62. package/dist/internal/numeric-properties.js +2 -1
  63. package/dist/internal/render-states.js +2 -1
  64. package/dist/internal/scalar.js +22 -13
  65. package/dist/internal/shaped-glyph.d.ts +3 -1
  66. package/dist/internal/shaped-glyph.js +12 -4
  67. package/dist/internal/struct-view.d.ts +3 -1
  68. package/dist/internal/struct-view.js +3 -1
  69. package/dist/internal/transformable.js +2 -1
  70. package/dist/network/common.js +23 -11
  71. package/dist/network/dns.js +25 -17
  72. package/dist/network/ftp.js +43 -18
  73. package/dist/network/http.js +126 -56
  74. package/dist/network/ip-address.js +50 -25
  75. package/dist/network/packet.js +63 -25
  76. package/dist/network/sftp.js +175 -74
  77. package/dist/network/socket-selector.js +28 -14
  78. package/dist/network/socket.js +71 -30
  79. package/dist/network/tcp-listener.js +42 -19
  80. package/dist/network/tcp-socket.js +111 -53
  81. package/dist/network/tls-material.js +2 -1
  82. package/dist/network/udp-socket.js +68 -33
  83. package/dist/system/angle.js +2 -1
  84. package/dist/system/clock.js +4 -2
  85. package/dist/system/err.js +5 -2
  86. package/dist/system/file-input-stream.js +8 -4
  87. package/dist/system/input-stream.js +6 -3
  88. package/dist/system/operators.d.ts +1 -1
  89. package/dist/system/operators.js +90 -50
  90. package/dist/system/sleep.js +4 -2
  91. package/dist/system/time.js +12 -6
  92. package/dist/system/vector2.js +6 -7
  93. package/dist/system/vector3.js +11 -6
  94. package/dist/window/clipboard.js +2 -1
  95. package/dist/window/context.js +10 -5
  96. package/dist/window/cursor.js +2 -1
  97. package/dist/window/event.js +9 -5
  98. package/dist/window/mouse.js +4 -2
  99. package/dist/window/video-mode.js +2 -1
  100. package/dist/window/window.js +19 -12
  101. package/native/addon.cc +25 -12
  102. package/native/audio-binding.cc +266 -126
  103. package/native/audio-codec-binding.cc +147 -77
  104. package/native/audio-device-binding.cc +76 -49
  105. package/native/audio-file-binding.cc +116 -67
  106. package/native/audio-recorder-binding.cc +147 -98
  107. package/native/audio-recorder.h +1 -1
  108. package/native/audio-state.h +53 -30
  109. package/native/audio-stream-binding.cc +148 -94
  110. package/native/audio-stream.h +5 -4
  111. package/native/audio-worker-binding.cc +163 -81
  112. package/native/audio-worker.h +35 -19
  113. package/native/batch-drawable.cc +29 -16
  114. package/native/batch-drawable.h +11 -8
  115. package/native/context-binding.cc +40 -27
  116. package/native/context-settings.h +15 -8
  117. package/native/deferred-delete.cc +9 -6
  118. package/native/deferred-delete.h +7 -8
  119. package/native/error-stream-binding.cc +42 -28
  120. package/native/font-binding.cc +89 -48
  121. package/native/graphics-binding.cc +122 -72
  122. package/native/graphics-state.h +50 -36
  123. package/native/image-binding.cc +38 -24
  124. package/native/image-state.h +26 -18
  125. package/native/input-binding.cc +42 -27
  126. package/native/render-window-binding.cc +38 -23
  127. package/native/shader-binding.cc +115 -50
  128. package/native/shape-binding.cc +94 -49
  129. package/native/shape-state.h +18 -9
  130. package/native/shaped-glyph-storage.h +9 -5
  131. package/native/stream-binding.cc +143 -117
  132. package/native/system-binding.cc +17 -12
  133. package/native/text-binding.cc +68 -35
  134. package/native/text-state.h +25 -18
  135. package/native/texture-binding.cc +42 -33
  136. package/native/texture-resource.h +20 -12
  137. package/native/time-value.h +3 -1
  138. package/native/transformable-binding.cc +12 -6
  139. package/native/transformable-state.h +6 -6
  140. package/native/value-binding.h +46 -28
  141. package/native/value-layout.h +10 -10
  142. package/native/values-binding.cc +29 -23
  143. package/native/vertex-binding.cc +18 -12
  144. package/native/vertex-buffer-binding.cc +38 -24
  145. package/native/vertex-storage.h +2 -2
  146. package/native/view-data.h +4 -3
  147. package/native/window-binding.cc +75 -45
  148. package/native/window-event.h +20 -11
  149. package/native/window-owner.h +15 -12
  150. package/package.json +43 -50
  151. package/src/audio/effect-processor.ts +9 -3
  152. package/src/audio/input-sound-file.ts +108 -36
  153. package/src/audio/listener.ts +39 -13
  154. package/src/audio/music.ts +112 -47
  155. package/src/audio/output-sound-file.ts +40 -11
  156. package/src/audio/playback-device.ts +23 -8
  157. package/src/audio/sound-buffer-recorder.ts +35 -13
  158. package/src/audio/sound-buffer.ts +166 -58
  159. package/src/audio/sound-file-factory.ts +127 -49
  160. package/src/audio/sound-file-reader.ts +49 -15
  161. package/src/audio/sound-recorder.ts +100 -34
  162. package/src/audio/sound-source.ts +142 -45
  163. package/src/audio/sound-stream.ts +15 -5
  164. package/src/audio/sound.ts +12 -4
  165. package/src/audio/value.ts +89 -26
  166. package/src/graphics/blend-mode.ts +3 -1
  167. package/src/graphics/boolean-vector.ts +56 -26
  168. package/src/graphics/color.ts +3 -1
  169. package/src/graphics/convex-shape.ts +10 -3
  170. package/src/graphics/font.ts +171 -50
  171. package/src/graphics/glsl-matrix.ts +9 -3
  172. package/src/graphics/glsl.ts +81 -35
  173. package/src/graphics/glyph.ts +67 -26
  174. package/src/graphics/image.ts +119 -45
  175. package/src/graphics/rect.ts +56 -24
  176. package/src/graphics/render-states.ts +31 -14
  177. package/src/graphics/render-target.ts +197 -81
  178. package/src/graphics/render-texture.ts +36 -12
  179. package/src/graphics/render-window.ts +9 -3
  180. package/src/graphics/shader.ts +186 -61
  181. package/src/graphics/shape.ts +93 -35
  182. package/src/graphics/sprite.ts +64 -25
  183. package/src/graphics/stencil-mode.ts +12 -6
  184. package/src/graphics/swap.ts +3 -2
  185. package/src/graphics/text.ts +229 -74
  186. package/src/graphics/texture.ts +180 -61
  187. package/src/graphics/transform.ts +132 -47
  188. package/src/graphics/transformable.ts +3 -1
  189. package/src/graphics/vertex-array.ts +87 -35
  190. package/src/graphics/vertex-buffer.ts +97 -33
  191. package/src/graphics/vertex.ts +9 -3
  192. package/src/graphics/view.ts +59 -21
  193. package/src/index.ts +101 -23
  194. package/src/internal/audio-codec-registry.ts +18 -6
  195. package/src/internal/audio-input-stream.ts +6 -2
  196. package/src/internal/audio-music-pump.ts +116 -41
  197. package/src/internal/audio-native.ts +249 -96
  198. package/src/internal/audio-recorder-session.ts +68 -24
  199. package/src/internal/audio-worker-session.ts +65 -21
  200. package/src/internal/audio-worker.ts +85 -41
  201. package/src/internal/glsl-value.ts +26 -11
  202. package/src/internal/graphics-state.ts +57 -20
  203. package/src/internal/input-stream.ts +23 -10
  204. package/src/internal/native.ts +252 -99
  205. package/src/internal/numeric-properties.ts +2 -1
  206. package/src/internal/render-states.ts +3 -1
  207. package/src/internal/scalar.ts +33 -14
  208. package/src/internal/shaped-glyph.ts +25 -12
  209. package/src/internal/struct-view.ts +40 -13
  210. package/src/internal/transformable.ts +3 -1
  211. package/src/network/common.ts +35 -11
  212. package/src/network/dns.ts +95 -38
  213. package/src/network/ftp.ts +129 -47
  214. package/src/network/http.ts +232 -77
  215. package/src/network/ip-address.ts +118 -48
  216. package/src/network/packet.ts +161 -54
  217. package/src/network/sftp.ts +498 -168
  218. package/src/network/socket-selector.ts +66 -26
  219. package/src/network/socket.ts +133 -46
  220. package/src/network/tcp-listener.ts +78 -29
  221. package/src/network/tcp-socket.ts +240 -95
  222. package/src/network/tls-material.ts +6 -2
  223. package/src/network/udp-socket.ts +147 -53
  224. package/src/system/angle.ts +3 -1
  225. package/src/system/clock.ts +12 -4
  226. package/src/system/err.ts +5 -2
  227. package/src/system/file-input-stream.ts +12 -4
  228. package/src/system/input-stream.ts +9 -3
  229. package/src/system/operators.ts +290 -115
  230. package/src/system/sleep.ts +6 -2
  231. package/src/system/time.ts +18 -6
  232. package/src/system/timeout-with-predicate.ts +19 -8
  233. package/src/system/vector2.ts +101 -49
  234. package/src/system/vector3.ts +85 -36
  235. package/src/window/clipboard.ts +3 -1
  236. package/src/window/context.ts +15 -5
  237. package/src/window/cursor.ts +3 -1
  238. package/src/window/event.ts +26 -12
  239. package/src/window/mouse.ts +6 -2
  240. package/src/window/video-mode.ts +3 -1
  241. package/src/window/window.ts +119 -37
  242. package/test/native/audio-probes.cc +74 -36
  243. package/test/native/deferred-delete-probes.cc +17 -11
  244. package/test/native/drawable-probes.cc +70 -36
  245. package/test/native/exception-probes.cc +14 -9
  246. package/test/native/image-probes.cc +20 -10
  247. package/test/native/matrix-probes.cc +8 -4
  248. package/test/native/network-oracle.cc +17 -11
  249. package/test/native/render-texture-probes.cc +33 -24
  250. package/test/native/shader-probes.cc +9 -9
  251. package/test/native/shape-probes.cc +37 -23
  252. package/test/native/sprite-probes.cc +41 -25
  253. package/test/native/system-probes.cc +58 -35
  254. package/test/native/text-probes.cc +77 -44
  255. package/test/native/texture-probes.cc +43 -26
  256. package/test/native/time-probes.cc +18 -12
  257. package/test/native/transform-probes.cc +15 -10
  258. package/test/native/transformable-probes.cc +23 -17
  259. package/test/native/value-oracle.h +9 -4
  260. package/test/native/value-probes.cc +31 -23
  261. package/test/native/vertex-array-probes.cc +22 -14
  262. package/test/native/vertex-buffer-probes.cc +28 -17
  263. package/test/native/view-probes.cc +29 -17
  264. package/test/native/window-probes.cc +66 -33
  265. package/tools/ensure-sfml.cjs +9 -0
  266. package/tools/generate-network-constants.cjs +11 -6
  267. package/tools/generate-window-constants.cjs +31 -12
  268. package/docs/README.ja.md +0 -30
  269. package/docs/README.ko.md +0 -30
  270. package/docs/README.md +0 -30
  271. package/docs/README.zh-CN.md +0 -30
  272. package/docs/api.ja.md +0 -84
  273. package/docs/api.ko.md +0 -84
  274. package/docs/api.md +0 -81
  275. package/docs/api.zh-CN.md +0 -81
  276. package/docs/audio.ja.md +0 -249
  277. package/docs/audio.ko.md +0 -251
  278. package/docs/audio.md +0 -252
  279. package/docs/audio.zh-CN.md +0 -252
  280. package/docs/concepts.ja.md +0 -130
  281. package/docs/concepts.ko.md +0 -130
  282. package/docs/concepts.md +0 -131
  283. package/docs/concepts.zh-CN.md +0 -131
  284. package/docs/development.ja.md +0 -148
  285. package/docs/development.ko.md +0 -148
  286. package/docs/development.md +0 -150
  287. package/docs/development.zh-CN.md +0 -150
  288. package/docs/getting-started.ja.md +0 -154
  289. package/docs/getting-started.ko.md +0 -154
  290. package/docs/getting-started.md +0 -156
  291. package/docs/getting-started.zh-CN.md +0 -156
  292. package/docs/graphics.ja.md +0 -256
  293. package/docs/graphics.ko.md +0 -254
  294. package/docs/graphics.md +0 -255
  295. package/docs/graphics.zh-CN.md +0 -257
  296. package/docs/network.ja.md +0 -214
  297. package/docs/network.ko.md +0 -216
  298. package/docs/network.md +0 -218
  299. package/docs/network.zh-CN.md +0 -218
  300. package/docs/system.ja.md +0 -169
  301. package/docs/system.ko.md +0 -171
  302. package/docs/system.md +0 -173
  303. package/docs/system.zh-CN.md +0 -173
  304. package/docs/window.ja.md +0 -138
  305. package/docs/window.ko.md +0 -140
  306. package/docs/window.md +0 -141
  307. package/docs/window.zh-CN.md +0 -141
  308. package/native/exception-boundary.h +0 -97
  309. package/native/numeric-fields.h +0 -96
  310. package/native/shared-handle.h +0 -69
  311. package/test/tsconfig.json +0 -8
  312. package/tools/configure-lsp.cjs +0 -23
  313. package/tools/lib_downloader.cjs +0 -92
  314. package/tools/lib_downloader_urls.cjs +0 -23
@@ -1,9 +1,15 @@
1
1
  import { resolve } from 'node:path';
2
2
  import {
3
- native, type NativeGraphicsHandle, type NativeFontMapping,
3
+ native,
4
+ type NativeGraphicsHandle,
5
+ type NativeFontMapping,
4
6
  } from '../internal/native';
5
7
  import { nativeStruct } from '../internal/struct-view';
6
- import { graphicsContext, graphicsNative, flushGraphics } from '../internal/graphics-state';
8
+ import {
9
+ graphicsContext,
10
+ graphicsNative,
11
+ flushGraphics,
12
+ } from '../internal/graphics-state';
7
13
  import { type ReadonlyValue as R } from '../internal/value-storage';
8
14
  import { InputStream } from '../system/input-stream';
9
15
  import { Glyph, glyphFromMapping } from './glyph';
@@ -54,11 +60,25 @@ export const fontRevision: unique symbol = Symbol('Font.revision');
54
60
  * @ja 同一フォントリソースへの読み取り専用インターフェース。フォントとグリフテクスチャの寿命を保持します。
55
61
  * @ko 동일한 글꼴 리소스의 읽기 전용 인터페이스입니다. 글꼴과 글리프 텍스처의 수명을 유지합니다.
56
62
  */
57
- export type ReadonlyFont = Readonly<Pick<Font,
58
- typeof graphicsNative | typeof fontRevision | 'getInfo' | 'getGlyph' |
59
- 'getGlyphById' | 'hasGlyph' | 'getKerning' | 'getAscent' | 'getDescent' |
60
- 'getLineSpacing' | 'getUnderlinePosition' | 'getUnderlineThickness' |
61
- 'getTexture' | 'isSmooth'>>;
63
+ export type ReadonlyFont = Readonly<
64
+ Pick<
65
+ Font,
66
+ | typeof graphicsNative
67
+ | typeof fontRevision
68
+ | 'getInfo'
69
+ | 'getGlyph'
70
+ | 'getGlyphById'
71
+ | 'hasGlyph'
72
+ | 'getKerning'
73
+ | 'getAscent'
74
+ | 'getDescent'
75
+ | 'getLineSpacing'
76
+ | 'getUnderlinePosition'
77
+ | 'getUnderlineThickness'
78
+ | 'getTexture'
79
+ | 'isSmooth'
80
+ >
81
+ >;
62
82
 
63
83
  export function fontUnsigned(value: number, maximum = 0xffffffff): number {
64
84
  if (!Number.isInteger(value) || value < 0 || value > maximum) {
@@ -68,23 +88,32 @@ export function fontUnsigned(value: number, maximum = 0xffffffff): number {
68
88
  }
69
89
 
70
90
  export function textFloat(value: number): number {
71
- if (typeof value !== 'number') throw new TypeError('Expected a number');
91
+ if (typeof value !== 'number') {
92
+ throw new TypeError('Expected a number');
93
+ }
72
94
  const result = Math.fround(value);
73
- if (!Number.isFinite(result)) throw new RangeError('Expected a finite float32 value');
95
+ if (!Number.isFinite(result)) {
96
+ throw new RangeError('Expected a finite float32 value');
97
+ }
74
98
  return result;
75
99
  }
76
100
 
77
101
  function flag(value: boolean): void {
78
- if (typeof value !== 'boolean') throw new TypeError('Expected a boolean');
102
+ if (typeof value !== 'boolean') {
103
+ throw new TypeError('Expected a boolean');
104
+ }
79
105
  }
80
106
 
81
107
  function fontViews(mapping: NativeFontMapping) {
82
108
  const { smooth, ...fields } = mapping.fields;
83
109
  return {
84
- info: nativeStruct<FontInfo>({ buffers: mapping.buffers, fields },
85
- { family: mapping.family }),
110
+ info: nativeStruct<FontInfo>(
111
+ { buffers: mapping.buffers, fields },
112
+ { family: mapping.family },
113
+ ),
86
114
  sampling: nativeStruct<{ smooth: boolean }>({
87
- buffers: mapping.buffers, fields: { smooth },
115
+ buffers: mapping.buffers,
116
+ fields: { smooth },
88
117
  }),
89
118
  };
90
119
  }
@@ -115,7 +144,10 @@ export class Font {
115
144
  if (source !== undefined && !(source instanceof Font)) {
116
145
  throw new TypeError('Expected a Font');
117
146
  }
118
- const mapping = native.createFont(graphicsContext(), source?.[graphicsNative]);
147
+ const mapping = native.createFont(
148
+ graphicsContext(),
149
+ source?.[graphicsNative],
150
+ );
119
151
  this[graphicsNative] = mapping.handle;
120
152
  this.state = fontViews(mapping);
121
153
  }
@@ -141,7 +173,9 @@ export class Font {
141
173
  * @ko 인코딩된 글꼴 바이트를 비동기로 열고 성공 여부를 반환합니다.
142
174
  */
143
175
  async openFromMemory(data: Uint8Array): Promise<boolean> {
144
- if (!(data instanceof Uint8Array)) throw new TypeError('Expected a Uint8Array');
176
+ if (!(data instanceof Uint8Array)) {
177
+ throw new TypeError('Expected a Uint8Array');
178
+ }
145
179
  return this.open(data);
146
180
  }
147
181
 
@@ -153,22 +187,35 @@ export class Font {
153
187
  * @ko 스트림 시작부터 모든 글꼴 바이트를 읽고 비동기로 엽니다. 성공 여부를 반환하며 스트림 예외는 Promise를 거부합니다.
154
188
  */
155
189
  async openFromStream(stream: InputStream): Promise<boolean> {
156
- if (!(stream instanceof InputStream)) throw new TypeError('Expected an InputStream');
190
+ if (!(stream instanceof InputStream)) {
191
+ throw new TypeError('Expected an InputStream');
192
+ }
157
193
  const size = await stream.getSize();
158
- if (size === undefined || size === 0n) return false;
194
+ if (size === undefined || size === 0n) {
195
+ return false;
196
+ }
159
197
  if (typeof size !== 'bigint' || size < 0n || size > 0x7fffffffn) {
160
198
  throw new RangeError('Font stream size exceeds the buffer limit');
161
199
  }
162
200
  const position = await stream.seek(0n);
163
- if (position === undefined) return false;
164
- if (position !== 0n) throw new RangeError('Font stream must seek to its beginning');
201
+ if (position === undefined) {
202
+ return false;
203
+ }
204
+ if (position !== 0n) {
205
+ throw new RangeError('Font stream must seek to its beginning');
206
+ }
165
207
  const bytes = new Uint8Array(Number(size));
166
208
  let offset = 0;
167
209
  while (offset < bytes.length) {
168
210
  const count = await stream.read(bytes.subarray(offset));
169
- if (count === undefined || count === 0n) return false;
170
- if (typeof count !== 'bigint' || count < 0n ||
171
- count > BigInt(bytes.length - offset)) {
211
+ if (count === undefined || count === 0n) {
212
+ return false;
213
+ }
214
+ if (
215
+ typeof count !== 'bigint' ||
216
+ count < 0n ||
217
+ count > BigInt(bytes.length - offset)
218
+ ) {
172
219
  throw new RangeError('Invalid font stream read count');
173
220
  }
174
221
  offset += Number(count);
@@ -182,7 +229,9 @@ export class Font {
182
229
  * @ja 現在のフォント情報の読み取り専用ビューを返します。
183
230
  * @ko 현재 글꼴 정보의 읽기 전용 뷰를 반환합니다.
184
231
  */
185
- getInfo(): FontInfo { return this.state.info; }
232
+ getInfo(): FontInfo {
233
+ return this.state.info;
234
+ }
186
235
 
187
236
  /**
188
237
  * Gets the cached glyph for a Unicode code point; size and outline thickness
@@ -192,10 +241,20 @@ export class Font {
192
241
  * @ko Unicode 코드 포인트의 캐시된 글리프를 가져옵니다. 글자 크기와 윤곽선 두께는 픽셀 단위이며 bold는 굵게 표시할지
193
242
  * 제어합니다.
194
243
  */
195
- getGlyph(codePoint: number, characterSize: number, bold: boolean,
196
- outlineThickness = 0): R<Glyph> {
244
+ getGlyph(
245
+ codePoint: number,
246
+ characterSize: number,
247
+ bold: boolean,
248
+ outlineThickness = 0,
249
+ ): R<Glyph> {
197
250
  fontUnsigned(codePoint, 0x10ffff);
198
- return this.glyph(codePoint, characterSize, bold, outlineThickness, false);
251
+ return this.glyph(
252
+ codePoint,
253
+ characterSize,
254
+ bold,
255
+ outlineThickness,
256
+ false,
257
+ );
199
258
  }
200
259
 
201
260
  /**
@@ -205,8 +264,12 @@ export class Font {
205
264
  * @ja フォント内部のグリフ番号でグリフを取得します。サイズと輪郭の太さはピクセル単位です。
206
265
  * @ko 글꼴 내부 글리프 번호로 글리프를 가져옵니다. 글자 크기와 윤곽선 두께는 픽셀 단위입니다.
207
266
  */
208
- getGlyphById(id: number, characterSize: number, bold: boolean,
209
- outlineThickness = 0): R<Glyph> {
267
+ getGlyphById(
268
+ id: number,
269
+ characterSize: number,
270
+ bold: boolean,
271
+ outlineThickness = 0,
272
+ ): R<Glyph> {
210
273
  fontUnsigned(id);
211
274
  return this.glyph(id, characterSize, bold, outlineThickness, true);
212
275
  }
@@ -221,7 +284,11 @@ export class Font {
221
284
  fontUnsigned(codePoint, 0x10ffff);
222
285
  let exists = this.coverage.get(codePoint);
223
286
  if (exists === undefined) {
224
- exists = native.fontMetric(this[graphicsNative], 5, codePoint) as boolean;
287
+ exists = native.fontMetric(
288
+ this[graphicsNative],
289
+ 5,
290
+ codePoint,
291
+ ) as boolean;
225
292
  this.coverage.set(codePoint, exists);
226
293
  }
227
294
  return exists;
@@ -233,7 +300,12 @@ export class Font {
233
300
  * @ja 二つの Unicode コードポイント間のカーニング量をピクセル単位で返します。
234
301
  * @ko 두 Unicode 코드 포인트 간의 커닝 양을 픽셀 단위로 반환합니다.
235
302
  */
236
- getKerning(first: number, second: number, characterSize: number, bold = false): number {
303
+ getKerning(
304
+ first: number,
305
+ second: number,
306
+ characterSize: number,
307
+ bold = false,
308
+ ): number {
237
309
  fontUnsigned(first, 0x10ffff);
238
310
  fontUnsigned(second, 0x10ffff);
239
311
  fontUnsigned(characterSize);
@@ -242,8 +314,14 @@ export class Font {
242
314
  let value = this.kernings.get(key);
243
315
  if (value === undefined) {
244
316
  flushGraphics();
245
- value = native.fontMetric(this[graphicsNative], 6,
246
- first, second, characterSize, bold) as number;
317
+ value = native.fontMetric(
318
+ this[graphicsNative],
319
+ 6,
320
+ first,
321
+ second,
322
+ characterSize,
323
+ bold,
324
+ ) as number;
247
325
  this.kernings.set(key, value);
248
326
  }
249
327
  return value;
@@ -255,14 +333,18 @@ export class Font {
255
333
  * @ja 指定ピクセル文字サイズでのアセントをピクセル単位で返します。
256
334
  * @ko 지정한 픽셀 글자 크기의 어센트를 픽셀 단위로 반환합니다.
257
335
  */
258
- getAscent(size: number): number { return this.metric(0, size); }
336
+ getAscent(size: number): number {
337
+ return this.metric(0, size);
338
+ }
259
339
  /**
260
340
  * Returns the descent in pixels for the specified pixel character size.
261
341
  * @zh 返回指定像素字号的下降度量,单位为像素。
262
342
  * @ja 指定ピクセル文字サイズでのディセントをピクセル単位で返します。
263
343
  * @ko 지정한 픽셀 글자 크기의 디센트를 픽셀 단위로 반환합니다.
264
344
  */
265
- getDescent(size: number): number { return this.metric(1, size); }
345
+ getDescent(size: number): number {
346
+ return this.metric(1, size);
347
+ }
266
348
  /**
267
349
  * Returns recommended baseline spacing for the specified pixel character
268
350
  * size.
@@ -270,21 +352,27 @@ export class Font {
270
352
  * @ja 指定ピクセル文字サイズでの推奨ベースライン間隔を返します。
271
353
  * @ko 지정한 픽셀 글자 크기의 권장 기준선 간격을 반환합니다.
272
354
  */
273
- getLineSpacing(size: number): number { return this.metric(2, size); }
355
+ getLineSpacing(size: number): number {
356
+ return this.metric(2, size);
357
+ }
274
358
  /**
275
359
  * Returns the underline position relative to the baseline in pixels.
276
360
  * @zh 返回下划线相对基线的位置,单位为像素。
277
361
  * @ja ベースラインに対する下線位置をピクセル単位で返します。
278
362
  * @ko 기준선에 대한 밑줄 위치를 픽셀 단위로 반환합니다.
279
363
  */
280
- getUnderlinePosition(size: number): number { return this.metric(3, size); }
364
+ getUnderlinePosition(size: number): number {
365
+ return this.metric(3, size);
366
+ }
281
367
  /**
282
368
  * Returns the underline thickness in pixels.
283
369
  * @zh 返回下划线厚度,单位为像素。
284
370
  * @ja 下線の太さをピクセル単位で返します。
285
371
  * @ko 밑줄 두께를 픽셀 단위로 반환합니다.
286
372
  */
287
- getUnderlineThickness(size: number): number { return this.metric(4, size); }
373
+ getUnderlineThickness(size: number): number {
374
+ return this.metric(4, size);
375
+ }
288
376
 
289
377
  /**
290
378
  * Returns a read-only glyph atlas texture reference for the specified pixel
@@ -300,7 +388,9 @@ export class Font {
300
388
  if (!texture) {
301
389
  flushGraphics();
302
390
  texture = fontTextureFromMapping(
303
- native.getFontTexture(this[graphicsNative], characterSize), this);
391
+ native.getFontTexture(this[graphicsNative], characterSize),
392
+ this,
393
+ );
304
394
  this.textures.set(characterSize, texture);
305
395
  }
306
396
  return texture;
@@ -314,7 +404,9 @@ export class Font {
314
404
  */
315
405
  setSmooth(smooth: boolean): void {
316
406
  flag(smooth);
317
- if (smooth === this.state.sampling.smooth) return;
407
+ if (smooth === this.state.sampling.smooth) {
408
+ return;
409
+ }
318
410
  flushGraphics();
319
411
  native.setFontSmooth(this[graphicsNative], smooth);
320
412
  }
@@ -324,22 +416,35 @@ export class Font {
324
416
  * @ja フォントテクスチャで平滑化フィルタリングが有効かを返します。
325
417
  * @ko 글꼴 텍스처의 부드러운 필터링 사용 여부를 반환합니다.
326
418
  */
327
- isSmooth(): boolean { return this.state.sampling.smooth; }
419
+ isSmooth(): boolean {
420
+ return this.state.sampling.smooth;
421
+ }
328
422
 
329
423
  private metric(metric: number, size: number): number {
330
424
  fontUnsigned(size);
331
425
  let values = this.metrics.get(size);
332
- if (!values) this.metrics.set(size, values = []);
426
+ if (!values) {
427
+ this.metrics.set(size, (values = []));
428
+ }
333
429
  let value = values[metric];
334
430
  if (value === undefined) {
335
- value = native.fontMetric(this[graphicsNative], metric, size) as number;
431
+ value = native.fontMetric(
432
+ this[graphicsNative],
433
+ metric,
434
+ size,
435
+ ) as number;
336
436
  values[metric] = value;
337
437
  }
338
438
  return value;
339
439
  }
340
440
 
341
- private glyph(id: number, size: number, bold: boolean, outline: number,
342
- byId: boolean): R<Glyph> {
441
+ private glyph(
442
+ id: number,
443
+ size: number,
444
+ bold: boolean,
445
+ outline: number,
446
+ byId: boolean,
447
+ ): R<Glyph> {
343
448
  fontUnsigned(size);
344
449
  flag(bold);
345
450
  outline = textFloat(outline);
@@ -347,8 +452,16 @@ export class Font {
347
452
  let glyph = this.glyphs.get(key);
348
453
  if (!glyph) {
349
454
  flushGraphics();
350
- const value = glyphFromMapping(native.getFontGlyph(
351
- this[graphicsNative], id, size, bold, outline, byId));
455
+ const value = glyphFromMapping(
456
+ native.getFontGlyph(
457
+ this[graphicsNative],
458
+ id,
459
+ size,
460
+ bold,
461
+ outline,
462
+ byId,
463
+ ),
464
+ );
352
465
  glyph = value;
353
466
  this.glyphs.set(key, glyph);
354
467
  }
@@ -358,11 +471,17 @@ export class Font {
358
471
  private open(input: string | Uint8Array): Promise<boolean> {
359
472
  return new Promise((resolve, reject) => {
360
473
  native.openFont(input, (error, data) => {
361
- if (error) return reject(error);
362
- if (!data) return resolve(false);
474
+ if (error) {
475
+ return reject(error);
476
+ }
477
+ if (!data) {
478
+ return resolve(false);
479
+ }
363
480
  try {
364
481
  flushGraphics();
365
- this.state = fontViews(native.commitFont(this[graphicsNative], data));
482
+ this.state = fontViews(
483
+ native.commitFont(this[graphicsNative], data),
484
+ );
366
485
  this[fontRevision]++;
367
486
  this.glyphs.clear();
368
487
  this.metrics.clear();
@@ -370,7 +489,9 @@ export class Font {
370
489
  this.coverage.clear();
371
490
  this.textures.clear();
372
491
  resolve(true);
373
- } catch (error) { reject(error); }
492
+ } catch (error) {
493
+ reject(error);
494
+ }
374
495
  });
375
496
  });
376
497
  }
@@ -46,7 +46,9 @@ abstract class Matrix<K extends Kind> extends GlslValue<K, Float32Array> {
46
46
  // Copy the nine SFML entries as bits, including signed zero and NaN.
47
47
  const input = new Uint32Array(data.buffer, data.byteOffset, 16);
48
48
  const output = new Uint32Array(values.buffer);
49
- for (let i = 0; i < 9; i++) output[i] = input[transform3Indices[i]];
49
+ for (let i = 0; i < 9; i++) {
50
+ output[i] = input[transform3Indices[i]];
51
+ }
50
52
  }
51
53
  } else if (source instanceof Matrix) {
52
54
  copyArray(values, source[glslStorage]);
@@ -61,14 +63,18 @@ abstract class Matrix<K extends Kind> extends GlslValue<K, Float32Array> {
61
63
  * @ja 列優先の行列データの変更可能な共有ビュー。
62
64
  * @ko 열 우선 행렬 데이터의 수정 가능한 공유 뷰입니다.
63
65
  */
64
- get array(): Float32Array { return this[glslStorage]; }
66
+ get array(): Float32Array {
67
+ return this[glslStorage];
68
+ }
65
69
  /**
66
70
  * Copies an array of the same length into existing matrix storage.
67
71
  * @zh 复制同长度数组到矩阵的现有存储。
68
72
  * @ja 同じ長さの配列を行列の既存ストレージにコピーします。
69
73
  * @ko 길이가 같은 배열을 기존 행렬 저장 공간에 복사합니다.
70
74
  */
71
- set array(source: ArrayLike<number>) { copyArray(this[glslStorage], source); }
75
+ set array(source: ArrayLike<number>) {
76
+ copyArray(this[glslStorage], source);
77
+ }
72
78
  }
73
79
 
74
80
  /**