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,5 +1,7 @@
1
1
  import {
2
- GlslValue, BooleanComponents, glslStorage,
2
+ GlslValue,
3
+ BooleanComponents,
4
+ glslStorage,
3
5
  } from '../internal/glsl-value';
4
6
  import { native } from '../internal/native';
5
7
  import type { ReadonlyValue as R } from '../internal/value-storage';
@@ -13,8 +15,8 @@ export { Mat3, Mat4 } from './glsl-matrix';
13
15
  type Source4 = R<Vec4> | R<Ivec4> | R<Bvec4>;
14
16
  type NumericArguments =
15
17
  | []
16
- | [ x: number, y: number, z: number, w: number ]
17
- | [ source: Source4 | R<Color> ];
18
+ | [x: number, y: number, z: number, w: number]
19
+ | [source: Source4 | R<Color>];
18
20
 
19
21
  /**
20
22
  * SFML's four-dimensional GLSL vectors expose data, not vector arithmetic.
@@ -22,8 +24,10 @@ type NumericArguments =
22
24
  * @ja SFML の四次元 GLSL ベクトルはデータを公開し、ベクトル演算は提供しません。
23
25
  * @ko SFML의 4차원 GLSL 벡터는 데이터만 노출하며 벡터 산술 연산은 제공하지 않습니다.
24
26
  */
25
- class Vector4<T extends 'i32' | 'f32'>
26
- extends GlslValue<'vector4', Int32Array | Float32Array> {
27
+ class Vector4<T extends 'i32' | 'f32'> extends GlslValue<
28
+ 'vector4',
29
+ Int32Array | Float32Array
30
+ > {
27
31
  /**
28
32
  * Component storage type, i32 or f32.
29
33
  * @zh 分量存储类型,i32 或 f32。
@@ -33,8 +37,10 @@ class Vector4<T extends 'i32' | 'f32'>
33
37
  private readonly type: T;
34
38
 
35
39
  constructor(type: T, ...args: NumericArguments) {
36
- super(type === 'f32' ? new Float32Array(4) : new Int32Array(4),
37
- buffer => native.wrapVector4(type, buffer));
40
+ super(
41
+ type === 'f32' ? new Float32Array(4) : new Int32Array(4),
42
+ buffer => native.wrapVector4(type, buffer),
43
+ );
38
44
  this.type = type;
39
45
  const source = args[0];
40
46
  if (source instanceof Vector4 && source.scalarType === type) {
@@ -48,8 +54,8 @@ class Vector4<T extends 'i32' | 'f32'>
48
54
  this.y = source.g / divisor;
49
55
  this.z = source.b / divisor;
50
56
  this.w = source.a / divisor;
51
- // Both vector classes are initialized before a public constructor runs.
52
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
57
+ // Both vector classes are initialized before a public constructor runs.
58
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
53
59
  } else if (source instanceof Vector4 || source instanceof Bvec4) {
54
60
  this.x = Number(source.x);
55
61
  this.y = Number(source.y);
@@ -61,7 +67,9 @@ class Vector4<T extends 'i32' | 'f32'>
61
67
  this.z = args[2];
62
68
  this.w = args[3];
63
69
  } else if (args.length !== 0) {
64
- throw new TypeError('Expected four numbers, a Glsl vector or a Color');
70
+ throw new TypeError(
71
+ 'Expected four numbers, a Glsl vector or a Color',
72
+ );
65
73
  }
66
74
  }
67
75
 
@@ -71,63 +79,81 @@ class Vector4<T extends 'i32' | 'f32'>
71
79
  * @ja 成分の格納型。i32 または f32。
72
80
  * @ko 성분의 저장 형식은 i32 또는 f32입니다.
73
81
  */
74
- get scalarType(): T { return this.type; }
82
+ get scalarType(): T {
83
+ return this.type;
84
+ }
75
85
  /**
76
86
  * X component.
77
87
  * @zh X 分量。
78
88
  * @ja X 成分。
79
89
  * @ko X 성분입니다.
80
90
  */
81
- get x(): number { return this[glslStorage][0]; }
91
+ get x(): number {
92
+ return this[glslStorage][0];
93
+ }
82
94
  /**
83
95
  * Sets the X component, converting to the storage type.
84
96
  * @zh 设置 X 分量,按存储类型转换。
85
97
  * @ja X 成分を格納型に変換して設定します。
86
98
  * @ko X 성분을 저장 형식으로 변환하여 설정합니다.
87
99
  */
88
- set x(value: number) { this[glslStorage][0] = value; }
100
+ set x(value: number) {
101
+ this[glslStorage][0] = value;
102
+ }
89
103
  /**
90
104
  * Y component.
91
105
  * @zh Y 分量。
92
106
  * @ja Y 成分。
93
107
  * @ko Y 성분입니다.
94
108
  */
95
- get y(): number { return this[glslStorage][1]; }
109
+ get y(): number {
110
+ return this[glslStorage][1];
111
+ }
96
112
  /**
97
113
  * Sets the Y component, converting to the storage type.
98
114
  * @zh 设置 Y 分量,按存储类型转换。
99
115
  * @ja Y 成分を格納型に変換して設定します。
100
116
  * @ko Y 성분을 저장 형식으로 변환하여 설정합니다.
101
117
  */
102
- set y(value: number) { this[glslStorage][1] = value; }
118
+ set y(value: number) {
119
+ this[glslStorage][1] = value;
120
+ }
103
121
  /**
104
122
  * Z component.
105
123
  * @zh Z 分量。
106
124
  * @ja Z 成分。
107
125
  * @ko Z 성분입니다.
108
126
  */
109
- get z(): number { return this[glslStorage][2]; }
127
+ get z(): number {
128
+ return this[glslStorage][2];
129
+ }
110
130
  /**
111
131
  * Sets the Z component, converting to the storage type.
112
132
  * @zh 设置 Z 分量,按存储类型转换。
113
133
  * @ja Z 成分を格納型に変換して設定します。
114
134
  * @ko Z 성분을 저장 형식으로 변환하여 설정합니다.
115
135
  */
116
- set z(value: number) { this[glslStorage][2] = value; }
136
+ set z(value: number) {
137
+ this[glslStorage][2] = value;
138
+ }
117
139
  /**
118
140
  * W component.
119
141
  * @zh W 分量。
120
142
  * @ja W 成分。
121
143
  * @ko W 성분입니다.
122
144
  */
123
- get w(): number { return this[glslStorage][3]; }
145
+ get w(): number {
146
+ return this[glslStorage][3];
147
+ }
124
148
  /**
125
149
  * Sets the W component, converting to the storage type.
126
150
  * @zh 设置 W 分量,按存储类型转换。
127
151
  * @ja W 成分を格納型に変換して設定します。
128
152
  * @ko W 성분을 저장 형식으로 변환하여 설정합니다.
129
153
  */
130
- set w(value: number) { this[glslStorage][3] = value; }
154
+ set w(value: number) {
155
+ this[glslStorage][3] = value;
156
+ }
131
157
  }
132
158
 
133
159
  /**
@@ -144,7 +170,9 @@ export class Vec4 extends Vector4<'f32'> {
144
170
  * @ja ゼロベクトルを作成するか、四成分を指定するか、ベクトルをコピーします。Color からの作成では RGBA を [0, 1] に正規化します。
145
171
  * @ko 영벡터를 만들거나 네 성분을 지정하거나 벡터를 복사합니다. Color로 만들면 RGBA를 [0, 1]로 정규화합니다.
146
172
  */
147
- constructor(...args: NumericArguments) { super('f32', ...args); }
173
+ constructor(...args: NumericArguments) {
174
+ super('f32', ...args);
175
+ }
148
176
  }
149
177
 
150
178
  /**
@@ -161,13 +189,15 @@ export class Ivec4 extends Vector4<'i32'> {
161
189
  * @ja ゼロベクトルを作成するか、四成分を指定するか、ベクトルをコピーします。Color からの作成では 0~255 の RGBA を保持します。
162
190
  * @ko 영벡터를 만들거나 네 성분을 지정하거나 벡터를 복사합니다. Color로 만들면 0~255의 RGBA 값을 유지합니다.
163
191
  */
164
- constructor(...args: NumericArguments) { super('i32', ...args); }
192
+ constructor(...args: NumericArguments) {
193
+ super('i32', ...args);
194
+ }
165
195
  }
166
196
 
167
197
  type BooleanArguments =
168
198
  | []
169
- | [ x: boolean, y: boolean, z: boolean, w: boolean ]
170
- | [ source: Source4 ];
199
+ | [x: boolean, y: boolean, z: boolean, w: boolean]
200
+ | [source: Source4];
171
201
 
172
202
  /**
173
203
  * GLSL bvec4 with four boolean components.
@@ -186,15 +216,23 @@ export class Bvec4 extends BooleanComponents<'vector4'> {
186
216
  constructor(...args: BooleanArguments) {
187
217
  const source = args[0];
188
218
  if (source instanceof Vector4 || source instanceof Bvec4) {
189
- super([ source.x, source.y, source.z, source.w ],
190
- buffer => native.wrapVector4('bool', buffer));
191
- } else if (args.length === 0 ||
192
- (args.length === 4 && args.every(value => typeof value === 'boolean'))) {
193
- super(args.length === 0 ? [ false, false, false, false ]
194
- : args as [ boolean, boolean, boolean, boolean ],
195
- buffer => native.wrapVector4('bool', buffer));
219
+ super([ source.x, source.y, source.z, source.w ], buffer =>
220
+ native.wrapVector4('bool', buffer),
221
+ );
222
+ } else if (
223
+ args.length === 0 ||
224
+ (args.length === 4 && args.every(value => typeof value === 'boolean'))
225
+ ) {
226
+ super(
227
+ args.length === 0
228
+ ? [ false, false, false, false ]
229
+ : (args as [boolean, boolean, boolean, boolean]),
230
+ buffer => native.wrapVector4('bool', buffer),
231
+ );
196
232
  } else {
197
- throw new TypeError('Expected four booleans or a four-dimensional vector');
233
+ throw new TypeError(
234
+ 'Expected four booleans or a four-dimensional vector',
235
+ );
198
236
  }
199
237
  }
200
238
 
@@ -204,26 +242,34 @@ export class Bvec4 extends BooleanComponents<'vector4'> {
204
242
  * @ja Z ブール成分。
205
243
  * @ko Z 불리언 성분입니다.
206
244
  */
207
- get z(): boolean { return this[glslStorage][2] !== 0; }
245
+ get z(): boolean {
246
+ return this[glslStorage][2] !== 0;
247
+ }
208
248
  /**
209
249
  * Sets the Z component.
210
250
  * @zh 设置 Z 分量。
211
251
  * @ja Z 成分を設定します。
212
252
  * @ko Z 성분을 설정합니다.
213
253
  */
214
- set z(value: boolean) { this[glslStorage][2] = value ? 1 : 0; }
254
+ set z(value: boolean) {
255
+ this[glslStorage][2] = value ? 1 : 0;
256
+ }
215
257
  /**
216
258
  * W boolean component.
217
259
  * @zh W 布尔分量。
218
260
  * @ja W ブール成分。
219
261
  * @ko W 불리언 성분입니다.
220
262
  */
221
- get w(): boolean { return this[glslStorage][3] !== 0; }
263
+ get w(): boolean {
264
+ return this[glslStorage][3] !== 0;
265
+ }
222
266
  /**
223
267
  * Sets the W component.
224
268
  * @zh 设置 W 分量。
225
269
  * @ja W 成分を設定します。
226
270
  * @ko W 성분을 설정합니다.
227
271
  */
228
- set w(value: boolean) { this[glslStorage][3] = value ? 1 : 0; }
272
+ set w(value: boolean) {
273
+ this[glslStorage][3] = value ? 1 : 0;
274
+ }
229
275
  }
@@ -1,15 +1,30 @@
1
1
  import {
2
- native, type NativeValueHandle, type NativeValueMapping,
2
+ native,
3
+ type NativeValueHandle,
4
+ type NativeValueMapping,
3
5
  } from '../internal/native';
4
- import { LazyValue, memberValue, nativeValue } from '../internal/lazy-value';
5
6
  import {
6
- glyphStorage, glyphNative, mutableValue, rectStorage, type ReadonlyValue as R,
7
+ LazyValue,
8
+ memberValue,
9
+ nativeValue,
10
+ } from '../internal/lazy-value';
11
+ import {
12
+ glyphStorage,
13
+ glyphNative,
14
+ mutableValue,
15
+ rectStorage,
16
+ type ReadonlyValue as R,
7
17
  } from '../internal/value-storage';
8
18
  import {
9
- FloatRect, IntRect, floatRectFromState, intRectFromState,
19
+ FloatRect,
20
+ IntRect,
21
+ floatRectFromState,
22
+ intRectFromState,
10
23
  } from './rect';
11
24
 
12
- export let glyphFromMapping: (mapping: NativeValueMapping<'glyph'>) => Glyph;
25
+ export let glyphFromMapping: (
26
+ mapping: NativeValueMapping<'glyph'>,
27
+ ) => Glyph;
13
28
  export let glyphFromState: (state: LazyValue<'glyph', Uint8Array>) => Glyph;
14
29
 
15
30
  /**
@@ -64,16 +79,22 @@ export class Glyph {
64
79
  * @ko 모든 숫자 값이 0인 글리프를 만들거나 source의 모든 글리프 메트릭을 복사합니다.
65
80
  */
66
81
  constructor(source?: R<Glyph>) {
67
- this.state = new LazyValue(new Uint8Array(44), buffer => native.wrapGlyph(buffer));
82
+ this.state = new LazyValue(new Uint8Array(44), buffer =>
83
+ native.wrapGlyph(buffer),
84
+ );
68
85
  this.floats = new Float32Array(this.state.values.buffer);
69
86
  this.integers = new Int32Array(this.state.values.buffer);
70
87
  if (source !== undefined) {
71
- if (!(source instanceof Glyph)) throw new TypeError('Expected a Glyph');
88
+ if (!(source instanceof Glyph)) {
89
+ throw new TypeError('Expected a Glyph');
90
+ }
72
91
  this.state.values.set(source[glyphStorage]);
73
92
  }
74
93
  }
75
94
 
76
- get [glyphStorage](): Uint8Array { return this.state.values; }
95
+ get [glyphStorage](): Uint8Array {
96
+ return this.state.values;
97
+ }
77
98
  get [glyphNative](): NativeValueHandle<'glyph'> {
78
99
  return nativeValue(this, glyphNative, this.state);
79
100
  }
@@ -83,14 +104,18 @@ export class Glyph {
83
104
  * @ja 描画後のペン位置の水平移動量。ピクセル単位。
84
105
  * @ko 그린 후 펜 위치의 수평 이동량이며 픽셀 단위입니다.
85
106
  */
86
- get advance(): number { return this.floats[0]; }
107
+ get advance(): number {
108
+ return this.floats[0];
109
+ }
87
110
  /**
88
111
  * Sets the horizontal advance in pixels.
89
112
  * @zh 设置水平前进量,单位为像素。
90
113
  * @ja 水平移動量をピクセル単位で設定します。
91
114
  * @ko 수평 이동량을 픽셀 단위로 설정합니다.
92
115
  */
93
- set advance(value: number) { this.floats[0] = value; }
116
+ set advance(value: number) {
117
+ this.floats[0] = value;
118
+ }
94
119
  /**
95
120
  * Difference in left side bearing before and after auto-hinting, in 1/64
96
121
  * pixels.
@@ -98,14 +123,18 @@ export class Glyph {
98
123
  * @ja 自動ヒンティング前後の左サイドベアリングの差。1/64 ピクセル単位。
99
124
  * @ko 자동 힌팅 전후 왼쪽 사이드 베어링의 차이이며 1/64 픽셀 단위입니다.
100
125
  */
101
- get lsbDelta(): number { return this.integers[1]; }
126
+ get lsbDelta(): number {
127
+ return this.integers[1];
128
+ }
102
129
  /**
103
130
  * Sets the left side bearing hinting delta.
104
131
  * @zh 设置左侧边距微调差。
105
132
  * @ja 左サイドベアリングのヒンティング差を設定します。
106
133
  * @ko 왼쪽 사이드 베어링의 힌팅 차이를 설정합니다.
107
134
  */
108
- set lsbDelta(value: number) { this.integers[1] = value; }
135
+ set lsbDelta(value: number) {
136
+ this.integers[1] = value;
137
+ }
109
138
  /**
110
139
  * Difference in right side bearing before and after auto-hinting, in 1/64
111
140
  * pixels.
@@ -113,14 +142,18 @@ export class Glyph {
113
142
  * @ja 自動ヒンティング前後の右サイドベアリングの差。1/64 ピクセル単位。
114
143
  * @ko 자동 힌팅 전후 오른쪽 사이드 베어링의 차이이며 1/64 픽셀 단위입니다.
115
144
  */
116
- get rsbDelta(): number { return this.integers[2]; }
145
+ get rsbDelta(): number {
146
+ return this.integers[2];
147
+ }
117
148
  /**
118
149
  * Sets the right side bearing hinting delta.
119
150
  * @zh 设置右侧边距微调差。
120
151
  * @ja 右サイドベアリングのヒンティング差を設定します。
121
152
  * @ko 오른쪽 사이드 베어링의 힌팅 차이를 설정합니다.
122
153
  */
123
- set rsbDelta(value: number) { this.integers[2] = value; }
154
+ set rsbDelta(value: number) {
155
+ this.integers[2] = value;
156
+ }
124
157
 
125
158
  /**
126
159
  * Pixel bounds relative to the baseline and pen position; a mutable shared
@@ -130,10 +163,11 @@ export class Glyph {
130
163
  * @ko 기준선과 펜 위치에 상대적인 픽셀 경계 상자이며 수정 가능한 공유 뷰입니다.
131
164
  */
132
165
  get bounds(): FloatRect {
133
- this.boundsView ??= floatRectFromState(memberValue(
134
- this.state, this.floats.subarray(3, 7),
135
- handle => native.glyphMember(handle, 0),
136
- ));
166
+ this.boundsView ??= floatRectFromState(
167
+ memberValue(this.state, this.floats.subarray(3, 7), handle =>
168
+ native.glyphMember(handle, 0),
169
+ ),
170
+ );
137
171
  return this.boundsView;
138
172
  }
139
173
  /**
@@ -143,7 +177,9 @@ export class Glyph {
143
177
  * @ko 글리프 경계 상자를 복사합니다.
144
178
  */
145
179
  set bounds(value: R<FloatRect>) {
146
- if (!(value instanceof FloatRect)) throw new TypeError('Expected a FloatRect');
180
+ if (!(value instanceof FloatRect)) {
181
+ throw new TypeError('Expected a FloatRect');
182
+ }
147
183
  this.floats.set(value[rectStorage], 3);
148
184
  }
149
185
  /**
@@ -153,10 +189,11 @@ export class Glyph {
153
189
  * @ko 글꼴 텍스처 안의 글리프 픽셀 사각형이며 수정 가능한 공유 뷰입니다.
154
190
  */
155
191
  get textureRect(): IntRect {
156
- this.textureView ??= intRectFromState(memberValue(
157
- this.state, this.integers.subarray(7, 11),
158
- handle => native.glyphMember(handle, 1),
159
- ));
192
+ this.textureView ??= intRectFromState(
193
+ memberValue(this.state, this.integers.subarray(7, 11), handle =>
194
+ native.glyphMember(handle, 1),
195
+ ),
196
+ );
160
197
  return this.textureView;
161
198
  }
162
199
  /**
@@ -166,7 +203,9 @@ export class Glyph {
166
203
  * @ko 글꼴 텍스처 안의 글리프 사각형을 복사합니다.
167
204
  */
168
205
  set textureRect(value: R<IntRect>) {
169
- if (!(value instanceof IntRect)) throw new TypeError('Expected an IntRect');
206
+ if (!(value instanceof IntRect)) {
207
+ throw new TypeError('Expected an IntRect');
208
+ }
170
209
  this.integers.set(value[rectStorage], 7);
171
210
  }
172
211
 
@@ -180,7 +219,9 @@ export class Glyph {
180
219
  integers: new Int32Array(buffer, byteOffset, 11),
181
220
  });
182
221
  };
183
- glyphFromMapping = mapping => glyphFromState(
184
- new LazyValue(new Uint8Array(mapping.buffer), () => mapping));
222
+ glyphFromMapping = mapping =>
223
+ glyphFromState(
224
+ new LazyValue(new Uint8Array(mapping.buffer), () => mapping),
225
+ );
185
226
  }
186
227
  }