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.
- package/README.ja.md +16 -11
- package/README.ko.md +16 -11
- package/README.md +16 -11
- package/README.zh-CN.md +16 -11
- package/assets/breakout.png +0 -0
- package/binding.gyp +23 -16
- package/dist/audio/effect-processor.js +9 -3
- package/dist/audio/input-sound-file.js +41 -15
- package/dist/audio/listener.js +33 -11
- package/dist/audio/music.js +41 -18
- package/dist/audio/output-sound-file.js +4 -2
- package/dist/audio/playback-device.js +11 -3
- package/dist/audio/sound-buffer-recorder.js +8 -5
- package/dist/audio/sound-buffer.js +40 -17
- package/dist/audio/sound-file-factory.js +21 -9
- package/dist/audio/sound-file-reader.js +21 -7
- package/dist/audio/sound-recorder.js +36 -15
- package/dist/audio/sound-source.js +117 -40
- package/dist/audio/sound-stream.js +14 -5
- package/dist/audio/sound.js +9 -4
- package/dist/audio/value.js +42 -16
- package/dist/graphics/blend-mode.js +2 -1
- package/dist/graphics/boolean-vector.d.ts +1 -2
- package/dist/graphics/boolean-vector.js +19 -9
- package/dist/graphics/color.js +2 -1
- package/dist/graphics/convex-shape.js +7 -3
- package/dist/graphics/font.js +52 -23
- package/dist/graphics/glsl-matrix.js +8 -3
- package/dist/graphics/glsl.js +47 -16
- package/dist/graphics/glyph.js +27 -10
- package/dist/graphics/image.js +30 -14
- package/dist/graphics/rect.js +15 -8
- package/dist/graphics/render-states.js +18 -9
- package/dist/graphics/render-target.js +49 -23
- package/dist/graphics/render-texture.js +24 -12
- package/dist/graphics/render-window.js +6 -3
- package/dist/graphics/shader.js +67 -32
- package/dist/graphics/shape.js +25 -13
- package/dist/graphics/sprite.js +19 -9
- package/dist/graphics/stencil-mode.js +10 -6
- package/dist/graphics/swap.js +2 -1
- package/dist/graphics/text.js +123 -48
- package/dist/graphics/texture.js +48 -24
- package/dist/graphics/transform.js +29 -13
- package/dist/graphics/transformable.js +2 -1
- package/dist/graphics/vertex-array.js +40 -18
- package/dist/graphics/vertex-buffer.js +39 -19
- package/dist/graphics/vertex.js +6 -3
- package/dist/graphics/view.js +30 -14
- package/dist/index.d.ts +4 -4
- package/dist/internal/audio-codec-registry.js +12 -6
- package/dist/internal/audio-input-stream.js +2 -1
- package/dist/internal/audio-music-pump.js +58 -24
- package/dist/internal/audio-recorder-session.js +17 -7
- package/dist/internal/audio-worker-session.js +28 -10
- package/dist/internal/audio-worker.js +40 -21
- package/dist/internal/glsl-value.d.ts +3 -1
- package/dist/internal/glsl-value.js +18 -8
- package/dist/internal/graphics-state.js +29 -15
- package/dist/internal/input-stream.d.ts +3 -1
- package/dist/internal/input-stream.js +16 -7
- package/dist/internal/numeric-properties.js +2 -1
- package/dist/internal/render-states.js +2 -1
- package/dist/internal/scalar.js +22 -13
- package/dist/internal/shaped-glyph.d.ts +3 -1
- package/dist/internal/shaped-glyph.js +12 -4
- package/dist/internal/struct-view.d.ts +3 -1
- package/dist/internal/struct-view.js +3 -1
- package/dist/internal/transformable.js +2 -1
- package/dist/network/common.js +23 -11
- package/dist/network/dns.js +25 -17
- package/dist/network/ftp.js +43 -18
- package/dist/network/http.js +126 -56
- package/dist/network/ip-address.js +50 -25
- package/dist/network/packet.js +63 -25
- package/dist/network/sftp.js +175 -74
- package/dist/network/socket-selector.js +28 -14
- package/dist/network/socket.js +71 -30
- package/dist/network/tcp-listener.js +42 -19
- package/dist/network/tcp-socket.js +111 -53
- package/dist/network/tls-material.js +2 -1
- package/dist/network/udp-socket.js +68 -33
- package/dist/system/angle.js +2 -1
- package/dist/system/clock.js +4 -2
- package/dist/system/err.js +5 -2
- package/dist/system/file-input-stream.js +8 -4
- package/dist/system/input-stream.js +6 -3
- package/dist/system/operators.d.ts +1 -1
- package/dist/system/operators.js +90 -50
- package/dist/system/sleep.js +4 -2
- package/dist/system/time.js +12 -6
- package/dist/system/vector2.js +6 -7
- package/dist/system/vector3.js +11 -6
- package/dist/window/clipboard.js +2 -1
- package/dist/window/context.js +10 -5
- package/dist/window/cursor.js +2 -1
- package/dist/window/event.js +9 -5
- package/dist/window/mouse.js +4 -2
- package/dist/window/video-mode.js +2 -1
- package/dist/window/window.js +19 -12
- package/native/addon.cc +25 -12
- package/native/audio-binding.cc +266 -126
- package/native/audio-codec-binding.cc +147 -77
- package/native/audio-device-binding.cc +76 -49
- package/native/audio-file-binding.cc +116 -67
- package/native/audio-recorder-binding.cc +147 -98
- package/native/audio-recorder.h +1 -1
- package/native/audio-state.h +53 -30
- package/native/audio-stream-binding.cc +148 -94
- package/native/audio-stream.h +5 -4
- package/native/audio-worker-binding.cc +163 -81
- package/native/audio-worker.h +35 -19
- package/native/batch-drawable.cc +29 -16
- package/native/batch-drawable.h +11 -8
- package/native/context-binding.cc +40 -27
- package/native/context-settings.h +15 -8
- package/native/deferred-delete.cc +9 -6
- package/native/deferred-delete.h +7 -8
- package/native/error-stream-binding.cc +42 -28
- package/native/font-binding.cc +89 -48
- package/native/graphics-binding.cc +122 -72
- package/native/graphics-state.h +50 -36
- package/native/image-binding.cc +38 -24
- package/native/image-state.h +26 -18
- package/native/input-binding.cc +42 -27
- package/native/render-window-binding.cc +38 -23
- package/native/shader-binding.cc +115 -50
- package/native/shape-binding.cc +94 -49
- package/native/shape-state.h +18 -9
- package/native/shaped-glyph-storage.h +9 -5
- package/native/stream-binding.cc +143 -117
- package/native/system-binding.cc +17 -12
- package/native/text-binding.cc +68 -35
- package/native/text-state.h +25 -18
- package/native/texture-binding.cc +42 -33
- package/native/texture-resource.h +20 -12
- package/native/time-value.h +3 -1
- package/native/transformable-binding.cc +12 -6
- package/native/transformable-state.h +6 -6
- package/native/value-binding.h +46 -28
- package/native/value-layout.h +10 -10
- package/native/values-binding.cc +29 -23
- package/native/vertex-binding.cc +18 -12
- package/native/vertex-buffer-binding.cc +38 -24
- package/native/vertex-storage.h +2 -2
- package/native/view-data.h +4 -3
- package/native/window-binding.cc +75 -45
- package/native/window-event.h +20 -11
- package/native/window-owner.h +15 -12
- package/package.json +43 -50
- package/src/audio/effect-processor.ts +9 -3
- package/src/audio/input-sound-file.ts +108 -36
- package/src/audio/listener.ts +39 -13
- package/src/audio/music.ts +112 -47
- package/src/audio/output-sound-file.ts +40 -11
- package/src/audio/playback-device.ts +23 -8
- package/src/audio/sound-buffer-recorder.ts +35 -13
- package/src/audio/sound-buffer.ts +166 -58
- package/src/audio/sound-file-factory.ts +127 -49
- package/src/audio/sound-file-reader.ts +49 -15
- package/src/audio/sound-recorder.ts +100 -34
- package/src/audio/sound-source.ts +142 -45
- package/src/audio/sound-stream.ts +15 -5
- package/src/audio/sound.ts +12 -4
- package/src/audio/value.ts +89 -26
- package/src/graphics/blend-mode.ts +3 -1
- package/src/graphics/boolean-vector.ts +56 -26
- package/src/graphics/color.ts +3 -1
- package/src/graphics/convex-shape.ts +10 -3
- package/src/graphics/font.ts +171 -50
- package/src/graphics/glsl-matrix.ts +9 -3
- package/src/graphics/glsl.ts +81 -35
- package/src/graphics/glyph.ts +67 -26
- package/src/graphics/image.ts +119 -45
- package/src/graphics/rect.ts +56 -24
- package/src/graphics/render-states.ts +31 -14
- package/src/graphics/render-target.ts +197 -81
- package/src/graphics/render-texture.ts +36 -12
- package/src/graphics/render-window.ts +9 -3
- package/src/graphics/shader.ts +186 -61
- package/src/graphics/shape.ts +93 -35
- package/src/graphics/sprite.ts +64 -25
- package/src/graphics/stencil-mode.ts +12 -6
- package/src/graphics/swap.ts +3 -2
- package/src/graphics/text.ts +229 -74
- package/src/graphics/texture.ts +180 -61
- package/src/graphics/transform.ts +132 -47
- package/src/graphics/transformable.ts +3 -1
- package/src/graphics/vertex-array.ts +87 -35
- package/src/graphics/vertex-buffer.ts +97 -33
- package/src/graphics/vertex.ts +9 -3
- package/src/graphics/view.ts +59 -21
- package/src/index.ts +101 -23
- package/src/internal/audio-codec-registry.ts +18 -6
- package/src/internal/audio-input-stream.ts +6 -2
- package/src/internal/audio-music-pump.ts +116 -41
- package/src/internal/audio-native.ts +249 -96
- package/src/internal/audio-recorder-session.ts +68 -24
- package/src/internal/audio-worker-session.ts +65 -21
- package/src/internal/audio-worker.ts +85 -41
- package/src/internal/glsl-value.ts +26 -11
- package/src/internal/graphics-state.ts +57 -20
- package/src/internal/input-stream.ts +23 -10
- package/src/internal/native.ts +252 -99
- package/src/internal/numeric-properties.ts +2 -1
- package/src/internal/render-states.ts +3 -1
- package/src/internal/scalar.ts +33 -14
- package/src/internal/shaped-glyph.ts +25 -12
- package/src/internal/struct-view.ts +40 -13
- package/src/internal/transformable.ts +3 -1
- package/src/network/common.ts +35 -11
- package/src/network/dns.ts +95 -38
- package/src/network/ftp.ts +129 -47
- package/src/network/http.ts +232 -77
- package/src/network/ip-address.ts +118 -48
- package/src/network/packet.ts +161 -54
- package/src/network/sftp.ts +498 -168
- package/src/network/socket-selector.ts +66 -26
- package/src/network/socket.ts +133 -46
- package/src/network/tcp-listener.ts +78 -29
- package/src/network/tcp-socket.ts +240 -95
- package/src/network/tls-material.ts +6 -2
- package/src/network/udp-socket.ts +147 -53
- package/src/system/angle.ts +3 -1
- package/src/system/clock.ts +12 -4
- package/src/system/err.ts +5 -2
- package/src/system/file-input-stream.ts +12 -4
- package/src/system/input-stream.ts +9 -3
- package/src/system/operators.ts +290 -115
- package/src/system/sleep.ts +6 -2
- package/src/system/time.ts +18 -6
- package/src/system/timeout-with-predicate.ts +19 -8
- package/src/system/vector2.ts +101 -49
- package/src/system/vector3.ts +85 -36
- package/src/window/clipboard.ts +3 -1
- package/src/window/context.ts +15 -5
- package/src/window/cursor.ts +3 -1
- package/src/window/event.ts +26 -12
- package/src/window/mouse.ts +6 -2
- package/src/window/video-mode.ts +3 -1
- package/src/window/window.ts +119 -37
- package/test/native/audio-probes.cc +74 -36
- package/test/native/deferred-delete-probes.cc +17 -11
- package/test/native/drawable-probes.cc +70 -36
- package/test/native/exception-probes.cc +14 -9
- package/test/native/image-probes.cc +20 -10
- package/test/native/matrix-probes.cc +8 -4
- package/test/native/network-oracle.cc +17 -11
- package/test/native/render-texture-probes.cc +33 -24
- package/test/native/shader-probes.cc +9 -9
- package/test/native/shape-probes.cc +37 -23
- package/test/native/sprite-probes.cc +41 -25
- package/test/native/system-probes.cc +58 -35
- package/test/native/text-probes.cc +77 -44
- package/test/native/texture-probes.cc +43 -26
- package/test/native/time-probes.cc +18 -12
- package/test/native/transform-probes.cc +15 -10
- package/test/native/transformable-probes.cc +23 -17
- package/test/native/value-oracle.h +9 -4
- package/test/native/value-probes.cc +31 -23
- package/test/native/vertex-array-probes.cc +22 -14
- package/test/native/vertex-buffer-probes.cc +28 -17
- package/test/native/view-probes.cc +29 -17
- package/test/native/window-probes.cc +66 -33
- package/tools/ensure-sfml.cjs +9 -0
- package/tools/generate-network-constants.cjs +11 -6
- package/tools/generate-window-constants.cjs +31 -12
- package/docs/README.ja.md +0 -30
- package/docs/README.ko.md +0 -30
- package/docs/README.md +0 -30
- package/docs/README.zh-CN.md +0 -30
- package/docs/api.ja.md +0 -84
- package/docs/api.ko.md +0 -84
- package/docs/api.md +0 -81
- package/docs/api.zh-CN.md +0 -81
- package/docs/audio.ja.md +0 -249
- package/docs/audio.ko.md +0 -251
- package/docs/audio.md +0 -252
- package/docs/audio.zh-CN.md +0 -252
- package/docs/concepts.ja.md +0 -130
- package/docs/concepts.ko.md +0 -130
- package/docs/concepts.md +0 -131
- package/docs/concepts.zh-CN.md +0 -131
- package/docs/development.ja.md +0 -148
- package/docs/development.ko.md +0 -148
- package/docs/development.md +0 -150
- package/docs/development.zh-CN.md +0 -150
- package/docs/getting-started.ja.md +0 -154
- package/docs/getting-started.ko.md +0 -154
- package/docs/getting-started.md +0 -156
- package/docs/getting-started.zh-CN.md +0 -156
- package/docs/graphics.ja.md +0 -256
- package/docs/graphics.ko.md +0 -254
- package/docs/graphics.md +0 -255
- package/docs/graphics.zh-CN.md +0 -257
- package/docs/network.ja.md +0 -214
- package/docs/network.ko.md +0 -216
- package/docs/network.md +0 -218
- package/docs/network.zh-CN.md +0 -218
- package/docs/system.ja.md +0 -169
- package/docs/system.ko.md +0 -171
- package/docs/system.md +0 -173
- package/docs/system.zh-CN.md +0 -173
- package/docs/window.ja.md +0 -138
- package/docs/window.ko.md +0 -140
- package/docs/window.md +0 -141
- package/docs/window.zh-CN.md +0 -141
- package/native/exception-boundary.h +0 -97
- package/native/numeric-fields.h +0 -96
- package/native/shared-handle.h +0 -69
- package/test/tsconfig.json +0 -8
- package/tools/configure-lsp.cjs +0 -23
- package/tools/lib_downloader.cjs +0 -92
- package/tools/lib_downloader_urls.cjs +0 -23
package/src/graphics/glsl.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
GlslValue,
|
|
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
|
-
| [
|
|
17
|
-
| [
|
|
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
|
-
|
|
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(
|
|
37
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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(
|
|
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 {
|
|
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 {
|
|
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) {
|
|
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 {
|
|
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) {
|
|
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 {
|
|
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) {
|
|
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 {
|
|
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) {
|
|
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) {
|
|
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) {
|
|
192
|
+
constructor(...args: NumericArguments) {
|
|
193
|
+
super('i32', ...args);
|
|
194
|
+
}
|
|
165
195
|
}
|
|
166
196
|
|
|
167
197
|
type BooleanArguments =
|
|
168
198
|
| []
|
|
169
|
-
| [
|
|
170
|
-
| [
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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(
|
|
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 {
|
|
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) {
|
|
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 {
|
|
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) {
|
|
272
|
+
set w(value: boolean) {
|
|
273
|
+
this[glslStorage][3] = value ? 1 : 0;
|
|
274
|
+
}
|
|
229
275
|
}
|
package/src/graphics/glyph.ts
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
|
-
native,
|
|
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
|
-
|
|
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,
|
|
19
|
+
FloatRect,
|
|
20
|
+
IntRect,
|
|
21
|
+
floatRectFromState,
|
|
22
|
+
intRectFromState,
|
|
10
23
|
} from './rect';
|
|
11
24
|
|
|
12
|
-
export let glyphFromMapping: (
|
|
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 =>
|
|
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))
|
|
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 {
|
|
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 {
|
|
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) {
|
|
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 {
|
|
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) {
|
|
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 {
|
|
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) {
|
|
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(
|
|
134
|
-
this.state, this.floats.subarray(3, 7),
|
|
135
|
-
|
|
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))
|
|
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(
|
|
157
|
-
this.state, this.integers.subarray(7, 11),
|
|
158
|
-
|
|
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))
|
|
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 =>
|
|
184
|
-
|
|
222
|
+
glyphFromMapping = mapping =>
|
|
223
|
+
glyphFromState(
|
|
224
|
+
new LazyValue(new Uint8Array(mapping.buffer), () => mapping),
|
|
225
|
+
);
|
|
185
226
|
}
|
|
186
227
|
}
|