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.
- package/README.ja.md +10 -9
- package/README.ko.md +10 -9
- package/README.md +10 -9
- package/README.zh-CN.md +10 -9
- 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 +44 -51
- 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 -144
- package/docs/development.ko.md +0 -144
- package/docs/development.md +0 -146
- package/docs/development.zh-CN.md +0 -146
- 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 -107
- 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/docs/system.md
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# System
|
|
2
|
-
|
|
3
|
-
**English** ยท [็ฎไฝไธญๆ](system.zh-CN.md) ยท [ๆฅๆฌ่ช](system.ja.md) ยท [ํ๊ตญ์ด](system.ko.md)
|
|
4
|
-
|
|
5
|
-
> System provides value types, time, input streams, Unicode boundaries and error handling. Ordinary numeric calculations run in JS; resource-related operations enter native code through the relevant APIs.
|
|
6
|
-
|
|
7
|
-
[API guide](api.md) ยท [Core concepts](concepts.md)
|
|
8
|
-
|
|
9
|
-
## Vectors and operations
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { Vector2f, Vector2i, add, multiply, addAssign } from 'sfml.js';
|
|
13
|
-
|
|
14
|
-
const position = new Vector2f(10, 20);
|
|
15
|
-
const velocity = new Vector2f(2, 3);
|
|
16
|
-
const next = add(position, velocity);
|
|
17
|
-
const doubled = multiply(velocity, 2);
|
|
18
|
-
addAssign(position, velocity);
|
|
19
|
-
const pixels = new Vector2i(position);
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Ordinary operations return independent values; `*Assign` modifies and returns the left operand. Assignment does not automatically convert a vector's scalar type; use the corresponding constructor for conversion.
|
|
23
|
-
|
|
24
|
-
| Scalar tag | JS component type | Storage |
|
|
25
|
-
| --- | --- | --- |
|
|
26
|
-
| `i8`/`u8` | number | Int8Array/Uint8Array |
|
|
27
|
-
| `i16`/`u16` | number | Int16Array/Uint16Array |
|
|
28
|
-
| `i32`/`u32` | number | Int32Array/Uint32Array |
|
|
29
|
-
| `i64`/`u64` | bigint | BigInt64Array/BigUint64Array |
|
|
30
|
-
| `f32`/`f64` | number | Float32Array/Float64Array |
|
|
31
|
-
|
|
32
|
-
`Vector2i/u/f` and `Vector3i/u/f` correspond to i32/u32/f32. For other scalars, use forms such as `new Vector2('f64', x, y)`.
|
|
33
|
-
|
|
34
|
-
Both vector types provide `lengthSquared()`, `dot()`, `cross()` and component-wise multiplication and division; 2D vectors also provide `perpendicular()`. Floating-point vectors provide `length()` and `normalized()`, with additional angle, rotation and projection operations for floating-point 2D vectors. Integer vectors do not support floating-point-only methods.
|
|
35
|
-
|
|
36
|
-
Vector `multiply()`/`divide()` use scalars; use `componentWiseMul()`/`componentWiseDiv()` for component-wise operations. Zero divisors, normalizing a zero vector and projecting onto a zero axis throw errors. 64-bit integer calculations retain bigint; f32 calculations round according to SFML precision rules, with limited platform math-library differences allowed for trigonometric operations.
|
|
37
|
-
|
|
38
|
-
## Angles
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { Angle, degrees, radians, divide } from 'sfml.js';
|
|
42
|
-
|
|
43
|
-
const heading = degrees(90);
|
|
44
|
-
const turn = radians(Math.PI);
|
|
45
|
-
const copy = new Angle(heading);
|
|
46
|
-
const ratio = divide(turn, heading);
|
|
47
|
-
console.log(copy.asDegrees(), ratio);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Rotation APIs accept Angle. `wrapSigned()` and `wrapUnsigned()` return wrapped angles; comparisons do not wrap automatically. `Angle.Zero` is a read-only constant; copy it before modifying it. Angle uses float32, and modulo requires a positive divisor.
|
|
51
|
-
|
|
52
|
-
## Time and clocks
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
import { Clock, milliseconds, microseconds, sleep } from 'sfml.js';
|
|
56
|
-
|
|
57
|
-
const clock = new Clock();
|
|
58
|
-
await sleep(milliseconds(16));
|
|
59
|
-
const elapsed = clock.restart();
|
|
60
|
-
console.log(elapsed.asSeconds(), elapsed.asMicroseconds());
|
|
61
|
-
console.log(microseconds(1000n).asMilliseconds());
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
| API | Semantics |
|
|
65
|
-
| --- | --- |
|
|
66
|
-
| `new Time()`/`new Time(source)`/`new Time(bigint)` | Construct zero duration, a copy or a microsecond value |
|
|
67
|
-
| `seconds(number)` | Convert seconds to Time |
|
|
68
|
-
| `milliseconds(number)` | int32 millisecond input, with fractions truncated toward zero |
|
|
69
|
-
| `microseconds(bigint)` | Microsecond input |
|
|
70
|
-
| `asMicroseconds()`/`toDuration()` | Microsecond bigint |
|
|
71
|
-
| `asSeconds()`/`asMilliseconds()` | float32 seconds/int32 milliseconds |
|
|
72
|
-
| `Clock.start()`/`stop()` | Resume/pause timing |
|
|
73
|
-
| `Clock.restart()`/`reset()` | Return previous elapsed time, then zero and run/pause |
|
|
74
|
-
|
|
75
|
-
Time stores signed int64 microseconds, using bigint for integer scaling and number for floating-point scaling. `Time.Zero` is a read-only constant. Out-of-range values and invalid division throw RangeError; failed in-place operations preserve the original value.
|
|
76
|
-
|
|
77
|
-
Clock uses `process.hrtime.bigint()` and returns independent Time snapshots. It has no timer of its own; clock resolution and system-suspend semantics are determined by Node.js and the platform.
|
|
78
|
-
|
|
79
|
-
`sleep(time)` returns a promise and waits using a Node timer without blocking the event loop. Positive durations round up to milliseconds; zero and negative durations complete immediately. Actual resumption time depends on scheduling.
|
|
80
|
-
|
|
81
|
-
### Timeout configuration
|
|
82
|
-
|
|
83
|
-
`TimeoutWithPredicate` stores a polling period and predicate; it does not start a timer itself:
|
|
84
|
-
|
|
85
|
-
- `new TimeoutWithPredicate(time)`: fixed period; the predicate always returns false.
|
|
86
|
-
- `new TimeoutWithPredicate(predicate, period?)`: default period of 1 ms; true means continue waiting.
|
|
87
|
-
- `getPeriod()` returns a read-only Time, and `getPredicate()` returns the original function.
|
|
88
|
-
|
|
89
|
-
The receiving API determines when checks occur. SFTP currently uses it to control waiting without progress; see [Network](network.md#sftp).
|
|
90
|
-
|
|
91
|
-
`SuspendAwareClock.now()` returns a native nanosecond time point that includes system suspend time. Only the Android branch supports it; desktop calls throw SFMLError. The current automatic download flow has no Android build target.
|
|
92
|
-
|
|
93
|
-
## Colors, rectangles and vertices
|
|
94
|
-
|
|
95
|
-
| Type | Construction and main operations |
|
|
96
|
-
| --- | --- |
|
|
97
|
-
| Color | RGB/RGBA, `0xRRGGBBAA`, copying; `r/g/b/a`, `toInteger()` |
|
|
98
|
-
| FloatRect/IntRect | `position` + `size`, copying, explicit conversion; `contains()`, `findIntersection()`, `getCenter()` |
|
|
99
|
-
| Vertex | `position`, `color`, `texCoords`, or copy construction |
|
|
100
|
-
|
|
101
|
-
These values are primarily used by graphics APIs. Color components are stored as uint8, and direct writes narrow to that type. Color addition and subtraction saturate; multiplication computes `floor(a * b / 255)` per channel. Color constants are read-only.
|
|
102
|
-
|
|
103
|
-
Rectangle and vertex members are shared views. Rectangles include the left and top edges and exclude the right and bottom edges. Negative sizes use normalized bounds; an intersection without positive area returns `undefined`. Vertex defaults to zero position and texture coordinates, with white color.
|
|
104
|
-
|
|
105
|
-
<a id="input-streams"></a>
|
|
106
|
-
|
|
107
|
-
## Input streams
|
|
108
|
-
|
|
109
|
-
InputStream is a seekable byte-stream protocol whose methods may return synchronous values or promises:
|
|
110
|
-
|
|
111
|
-
| Method | Return value |
|
|
112
|
-
| --- | --- |
|
|
113
|
-
| `read(data)` | Writes into a Uint8Array and returns the actual byte count as bigint; EOF is `0n` |
|
|
114
|
-
| `seek(position)` | Actual byte position as bigint |
|
|
115
|
-
| `tell()` | Current byte position as bigint |
|
|
116
|
-
| `getSize()` | Total byte count as bigint |
|
|
117
|
-
|
|
118
|
-
`undefined` indicates I/O failure; thrown errors propagate unchanged. Any object implementing these four methods can also be passed as a stream; a Node Readable needs an additional adapter to support seeking.
|
|
119
|
-
|
|
120
|
-
`MemoryInputStream(data)` retains a reference to the input bytes. Keep contents unchanged during loading and give each operation exclusive cursor access. `FileInputStream` uses a Node file handle, serializing asynchronous I/O and seeking per object:
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
import { FileInputStream, Image } from 'sfml.js';
|
|
124
|
-
|
|
125
|
-
async function readImage(filename: string) {
|
|
126
|
-
const stream = new FileInputStream();
|
|
127
|
-
try {
|
|
128
|
-
if (!await stream.open(filename)) throw new Error('Cannot open file');
|
|
129
|
-
const image = new Image();
|
|
130
|
-
if (!await image.loadFromStream(stream)) throw new Error('Cannot decode image');
|
|
131
|
-
return image;
|
|
132
|
-
} finally {
|
|
133
|
-
await stream.close();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Wait for loading to finish before closing the stream. Await multiple loads on the same stream sequentially. FileInputStream supports file offsets from 0 to 2^53 - 1; EOF does not automatically close the file, so seeking again is allowed.
|
|
139
|
-
|
|
140
|
-
## Unicode and version
|
|
141
|
-
|
|
142
|
-
`Unicode.isGraphemeBoundary(text, position)`, `isWordBoundary()` and `isSentenceBoundary()` use SFML's Unicode rules. position is a UTF-16 index into a JS string, ranging from 0 to `text.length`; the middle of a surrogate pair is not a boundary.
|
|
143
|
-
|
|
144
|
-
`version()` returns a cached, read-only SFML runtime version containing `major`, `minor`, `patch`, `isRelease` and `string`. It is not the npm package version.
|
|
145
|
-
|
|
146
|
-
## Errors and logging
|
|
147
|
-
|
|
148
|
-
SFMLError indicates a binding or SFML runtime failure; test it with `instanceof SFMLError`. Argument errors use TypeError/RangeError; errors thrown by user callbacks propagate unchanged. Ordinary SFML failure statuses remain false/undefined rather than all being converted to exceptions.
|
|
149
|
-
|
|
150
|
-
`err()` returns a singleton Node Writable that writes to `sf::err()`. `setErrorOutput(writable)` redirects SFML logs; pass null to silence them, or no arguments to restore the default stderr:
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
import { createWriteStream } from 'node:fs';
|
|
154
|
-
import { finished } from 'node:stream/promises';
|
|
155
|
-
import { err, setErrorOutput } from 'sfml.js';
|
|
156
|
-
|
|
157
|
-
const output = createWriteStream('sfml.log');
|
|
158
|
-
setErrorOutput(output);
|
|
159
|
-
err().write('SFML diagnostic\n');
|
|
160
|
-
setErrorOutput();
|
|
161
|
-
output.end();
|
|
162
|
-
await finished(output);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Log routing is process-wide, and Workers share the latest setting; Node's own stderr is unaffected. Background logs are dispatched in byte chunks without guaranteed UTF-8 character or line boundaries; use StringDecoder when parsing text.
|
|
166
|
-
|
|
167
|
-
<a id="sfml-cpp-reference"></a>
|
|
168
|
-
|
|
169
|
-
## SFML C++ reference
|
|
170
|
-
|
|
171
|
-
The original references for [Vector2](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Vector2.html), [Angle](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Angle.html), [Time](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Time.html), [Clock](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Clock.html) and [InputStream](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1InputStream.html) describe the upstream math, time and stream concepts.
|
|
172
|
-
|
|
173
|
-
For JavaScript, follow this guide's named operators, bigint time representation, promise-based sleep and stream method contracts rather than copying C++ signatures.
|
package/docs/system.zh-CN.md
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
# System
|
|
2
|
-
|
|
3
|
-
[English](system.md) ยท **็ฎไฝไธญๆ** ยท [ๆฅๆฌ่ช](system.ja.md) ยท [ํ๊ตญ์ด](system.ko.md)
|
|
4
|
-
|
|
5
|
-
> System ๆไพๅผ็ฑปๅใๆถ้ดใ่พๅ
ฅๆตใUnicode ่พน็ๅ้่ฏฏๅค็ใๆฎ้ๆฐๅผ่ฎก็ฎๅจ JS ไธญๅฎๆ๏ผ่ตๆบ็ธๅ
ณๆไฝๆๆฅๅฃ่ฟๅ
ฅ Nativeใ
|
|
6
|
-
|
|
7
|
-
[API ๅฏผ่ช](api.zh-CN.md) ยท [ๆ ธๅฟๆฆๅฟต](concepts.zh-CN.md)
|
|
8
|
-
|
|
9
|
-
## ๅ้ไธ่ฟ็ฎ
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { Vector2f, Vector2i, add, multiply, addAssign } from 'sfml.js';
|
|
13
|
-
|
|
14
|
-
const position = new Vector2f(10, 20);
|
|
15
|
-
const velocity = new Vector2f(2, 3);
|
|
16
|
-
const next = add(position, velocity);
|
|
17
|
-
const doubled = multiply(velocity, 2);
|
|
18
|
-
addAssign(position, velocity);
|
|
19
|
-
const pixels = new Vector2i(position);
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
ๆฎ้่ฟ็ฎ่ฟๅ็ฌ็ซๅผ๏ผ`*Assign` ไฟฎๆนๅทฆๆไฝๆฐๅนถ่ฟๅๅฎใ่ตๅผไธ่ชๅจ่ฝฌๆขๅ้็ๆ ้็ฑปๅ๏ผ้่ฆ่ฝฌๆขๆถไฝฟ็จๅฏนๅบๆ้ ๅฝๆฐใ
|
|
23
|
-
|
|
24
|
-
| ๆ ้ๆ ็ญพ | JS ๅ้็ฑปๅ | ๅญๅจ |
|
|
25
|
-
| --- | --- | --- |
|
|
26
|
-
| `i8`๏ผ`u8` | number | Int8Array๏ผUint8Array |
|
|
27
|
-
| `i16`๏ผ`u16` | number | Int16Array๏ผUint16Array |
|
|
28
|
-
| `i32`๏ผ`u32` | number | Int32Array๏ผUint32Array |
|
|
29
|
-
| `i64`๏ผ`u64` | bigint | BigInt64Array๏ผBigUint64Array |
|
|
30
|
-
| `f32`๏ผ`f64` | number | Float32Array๏ผFloat64Array |
|
|
31
|
-
|
|
32
|
-
`Vector2i/u/f` ๅ `Vector3i/u/f` ๅๅซๅฏนๅบ i32๏ผu32๏ผf32ใๅ
ถไปๆ ้ไฝฟ็จ `new Vector2('f64', x, y)` ็ญๅฝขๅผใ
|
|
33
|
-
|
|
34
|
-
ไธค็งๅ้ๆไพ `lengthSquared()`ใ`dot()`ใ`cross()` ๅ้ๅ้ไน้ค๏ผไบ็ปดๅ้ๅฆๆ `perpendicular()`ใๆตฎ็นๅ้ๆไพ `length()` ไธ `normalized()`๏ผๆตฎ็นไบ็ปดๅ้่ฟๆไพ่งๅบฆใๆ่ฝฌๅๆๅฝฑๆไฝใๆดๆฐๅ้ไธๆฏๆๆตฎ็นไธๅฑๆนๆณใ
|
|
35
|
-
|
|
36
|
-
ๅ้็ `multiply()`๏ผ`divide()` ไฝฟ็จๆ ้๏ผ้ๅ้ๆไฝไฝฟ็จ `componentWiseMul()`๏ผ`componentWiseDiv()`ใ้ถ้คๆฐใ้ถๅ้ๅฝไธๅๅๅ้ถ่ฝดๆๅฝฑไผๆ้ใ64 ไฝๆดๆฐ่ฎก็ฎไฟ็ bigint๏ผf32 ่ฎก็ฎๆ SFML ็็ฒพๅบฆ่งๅ่ๅ
ฅ๏ผไธ่ง่ฟ็ฎๅ
่ฎธๅนณๅฐๆฐๅญฆๅบ็ๆ้ๅทฎๅผใ
|
|
37
|
-
|
|
38
|
-
## ่งๅบฆ
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { Angle, degrees, radians, divide } from 'sfml.js';
|
|
42
|
-
|
|
43
|
-
const heading = degrees(90);
|
|
44
|
-
const turn = radians(Math.PI);
|
|
45
|
-
const copy = new Angle(heading);
|
|
46
|
-
const ratio = divide(turn, heading);
|
|
47
|
-
console.log(copy.asDegrees(), ratio);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
ๆ่ฝฌๆฅๅฃๆฅๅ Angleใ`wrapSigned()`ใ`wrapUnsigned()` ่ฟๅๆๅๅ็่งๅบฆ๏ผๆฏ่พไธไผ่ชๅจๆๅใ`Angle.Zero` ไธบๅช่ฏปๅธธ้๏ผๅคๅถๅๅฏไฟฎๆนใAngle ไฝฟ็จ float32๏ผๅๆจก่ฆๆฑๆญฃ้คๆฐใ
|
|
51
|
-
|
|
52
|
-
## ๆถ้ดไธๆถ้
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
import { Clock, milliseconds, microseconds, sleep } from 'sfml.js';
|
|
56
|
-
|
|
57
|
-
const clock = new Clock();
|
|
58
|
-
await sleep(milliseconds(16));
|
|
59
|
-
const elapsed = clock.restart();
|
|
60
|
-
console.log(elapsed.asSeconds(), elapsed.asMicroseconds());
|
|
61
|
-
console.log(microseconds(1000n).asMilliseconds());
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
| ๆฅๅฃ | ่ฏญไน |
|
|
65
|
-
| --- | --- |
|
|
66
|
-
| `new Time()`๏ผ`new Time(source)`๏ผ`new Time(bigint)` | ้ถๆถ้ฟใๅคๅถใๅพฎ็งๆ้ |
|
|
67
|
-
| `seconds(number)` | ็ง่ฝฌๆขไธบ Time |
|
|
68
|
-
| `milliseconds(number)` | int32 ๆฏซ็ง่พๅ
ฅ๏ผๅฐๆฐๅ้ถๆชๆญ |
|
|
69
|
-
| `microseconds(bigint)` | ๅพฎ็ง่พๅ
ฅ |
|
|
70
|
-
| `asMicroseconds()`๏ผ`toDuration()` | ๅพฎ็ง bigint |
|
|
71
|
-
| `asSeconds()`๏ผ`asMilliseconds()` | float32 ็ง๏ผint32 ๆฏซ็ง |
|
|
72
|
-
| `Clock.start()`๏ผ`stop()` | ็ปง็ปญ๏ผๆๅ่ฎกๆถ |
|
|
73
|
-
| `Clock.restart()`๏ผ`reset()` | ่ฟๅๅ่ๆถ๏ผๆธ
้ถๅ่ฟ่ก๏ผๆๅ |
|
|
74
|
-
|
|
75
|
-
Time ไฟๅญๆ็ฌฆๅท int64 ๅพฎ็ง๏ผๆดๆฐๅ่ฟ็ฎไฝฟ็จ bigint๏ผๆตฎ็นๅๆฐไฝฟ็จ numberใ`Time.Zero` ไธบๅช่ฏปๅธธ้ใ่ถ
่ๅดๅ้ๆณ้คๆณๆๅบ RangeError๏ผๅคฑ่ดฅ็ๅไฝ่ฟ็ฎไฟ็ๅๅผใ
|
|
76
|
-
|
|
77
|
-
Clock ไฝฟ็จ `process.hrtime.bigint()`๏ผ่ฟๅ็ฌ็ซ Time ๅฟซ็
งใๅฎๆฒกๆ่ชๅทฑ็ๅฎๆถๅจ๏ผๆถ้ๅ่พจ็ไธ็ณป็ปไผ็ ่ฏญไน็ฑ Node.js ๅๅนณๅฐๅณๅฎใ
|
|
78
|
-
|
|
79
|
-
`sleep(time)` ่ฟๅ Promise๏ผ้่ฟ Node ๅฎๆถๅจ็ญๅพ
๏ผไธ้ปๅกไบไปถๅพช็ฏใๆญฃๆถ้ฟๅไธๅๆดๅฐๆฏซ็ง๏ผ้ถไธ่ดๆถ้ฟ็ดๆฅๅฎๆ๏ผๅฎ้
ๆขๅคๆถ้ดๅ่ฐๅบฆๅฝฑๅใ
|
|
80
|
-
|
|
81
|
-
### ่ถ
ๆถ้
็ฝฎ
|
|
82
|
-
|
|
83
|
-
`TimeoutWithPredicate` ไฟๅญๆฃๆฅๅจๆไธ่ฐ่ฏ๏ผๆฌ่บซไธๅฏๅจ่ฎกๆถๅจ๏ผ
|
|
84
|
-
|
|
85
|
-
- `new TimeoutWithPredicate(time)`๏ผๅบๅฎๅจๆ๏ผ่ฐ่ฏๅง็ป่ฟๅ falseใ
|
|
86
|
-
- `new TimeoutWithPredicate(predicate, period?)`๏ผ้ป่ฎคๅจๆ 1 ms๏ผtrue ่กจ็คบ็ปง็ปญ็ญๅพ
ใ
|
|
87
|
-
- `getPeriod()` ่ฟๅๅช่ฏป Time๏ผ`getPredicate()` ่ฟๅๅๅฝๆฐใ
|
|
88
|
-
|
|
89
|
-
ๆฅๆถๅฎ็ๆฅๅฃๅณๅฎไฝๆถๆฃๆฅ๏ผๅฝๅ SFTP ไฝฟ็จๅฎๆงๅถๆ ่ฟๅฑ็ญๅพ
๏ผ่ฏฆ่ง [Network](network.zh-CN.md#sftp)ใ
|
|
90
|
-
|
|
91
|
-
`SuspendAwareClock.now()` ่ฟๅๅ
ๅซ็ณป็ปไผ็ ๆถ้ด็ๅ็็บณ็งๆถ้ด็น๏ผไป
Android ๅๆฏๆฏๆ๏ผๆก้ข่ฐ็จๆๅบ SFMLErrorใๅฝๅ่ชๅจไธ่ฝฝๆต็จๆฒกๆ Android ๆๅปบ็ฎๆ ใ
|
|
92
|
-
|
|
93
|
-
## ้ข่ฒใ็ฉๅฝขไธ้กถ็น
|
|
94
|
-
|
|
95
|
-
| ็ฑปๅ | ๆ้ ไธไธป่ฆๆไฝ |
|
|
96
|
-
| --- | --- |
|
|
97
|
-
| Color | RGB๏ผRGBAใ`0xRRGGBBAA`ใๅคๅถ๏ผ`r/g/b/a`ใ`toInteger()` |
|
|
98
|
-
| FloatRect๏ผIntRect | `position` + `size`ใๅคๅถใๆพๅผ่ฝฌๆข๏ผ`contains()`ใ`findIntersection()`ใ`getCenter()` |
|
|
99
|
-
| Vertex | `position`ใ`color`ใ`texCoords`๏ผๆๅคๅถๆ้ |
|
|
100
|
-
|
|
101
|
-
่ฟไบๅผไธป่ฆ็จไบๅพๅฝขๆฅๅฃใColor ๅ้ๆ uint8 ๅญๅจ๏ผ็ดๆฅๅๅ
ฅไผ็ชๅ๏ผ้ข่ฒๅ ๅๆฏ้ฅฑๅ่ฟ็ฎ๏ผ้ข่ฒ็ธไนๆ้้่ฎก็ฎ `floor(a * b / 255)`ใColor ๅธธ้ๅช่ฏปใ
|
|
102
|
-
|
|
103
|
-
็ฉๅฝขๆๅๅ้กถ็นๆๅๆฏๅ
ฑไบซ่งๅพใ็ฉๅฝขๅ
ๅซๅทฆใไธ่พน็๏ผๆ้คๅณใไธ่พน็๏ผ่ดๅฐบๅฏธๆๅฝไธๅ่ๅด่ฎก็ฎ๏ผไบค้ๆ ๆญฃ้ข็งฏๆถ่ฟๅ `undefined`ใVertex ้ป่ฎคไฝ็ฝฎใ็บน็ๅๆ ไธบ้ถ๏ผ้ข่ฒไธบ็ฝ่ฒใ
|
|
104
|
-
|
|
105
|
-
<a id="input-streams"></a>
|
|
106
|
-
|
|
107
|
-
## ่พๅ
ฅๆต
|
|
108
|
-
|
|
109
|
-
InputStream ๆฏๅฏๅฏปๅๅญ่ๆตๅ่ฎฎ๏ผๆนๆณๅฏ่ฟๅๅๆญฅๅผๆ Promise๏ผ
|
|
110
|
-
|
|
111
|
-
| ๆนๆณ | ่ฟๅๅผ |
|
|
112
|
-
| --- | --- |
|
|
113
|
-
| `read(data)` | ๅๅ
ฅ Uint8Array๏ผ่ฟๅๅฎ้
ๅญ่ๆฐ bigint๏ผEOF ไธบ `0n` |
|
|
114
|
-
| `seek(position)` | ่ฟๅๅฎ้
ๅญ่ไฝ็ฝฎ bigint |
|
|
115
|
-
| `tell()` | ๅฝๅๅญ่ไฝ็ฝฎ bigint |
|
|
116
|
-
| `getSize()` | ๆปๅญ่ๆฐ bigint |
|
|
117
|
-
|
|
118
|
-
`undefined` ่กจ็คบ I/O ๅคฑ่ดฅ๏ผๆๅบ็้่ฏฏๅๆ ทไผ ๆญใๅฎ็ฐ่ฟๅไธชๆนๆณ็ๅฏน่ฑกไนๅฏไปฅไฝไธบๆตไผ ๅ
ฅ๏ผNode Readable ้้ขๅค้้
ๅฏปๅ่ฝๅใ
|
|
119
|
-
|
|
120
|
-
`MemoryInputStream(data)` ไฟ็่พๅ
ฅๅญ่ๅผ็จใๅ ่ฝฝๆ้ดไฟๆๅ
ๅฎนไธๅ๏ผๅนถ่ฎฉๅๆฌกๆไฝ็ฌๅ ๆธธๆ ใ`FileInputStream` ไฝฟ็จ Node ๆไปถๅฅๆ๏ผๆๅฏน่ฑกไธฒ่กๆง่กๅผๆญฅ่ฏปๅไธๅฏปๅ๏ผ
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
import { FileInputStream, Image } from 'sfml.js';
|
|
124
|
-
|
|
125
|
-
async function readImage(filename: string) {
|
|
126
|
-
const stream = new FileInputStream();
|
|
127
|
-
try {
|
|
128
|
-
if (!await stream.open(filename)) throw new Error('Cannot open file');
|
|
129
|
-
const image = new Image();
|
|
130
|
-
if (!await image.loadFromStream(stream)) throw new Error('Cannot decode image');
|
|
131
|
-
return image;
|
|
132
|
-
} finally {
|
|
133
|
-
await stream.close();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
็ญๅพ
ๅ ่ฝฝๅฎๆๅๅๅ
ณ้ญๆตใๅไธไธชๆต็ๅคๆฌกๅ ่ฝฝๅบ้ๆฌก awaitใFileInputStream ็ๆไปถๅ็งป่ๅดไธบ 0๏ฝ2โตยณโ1๏ผEOF ไธไผ่ชๅจๅ
ณ้ญๆไปถ๏ผๅ
่ฎธๅๆฌก seekใ
|
|
139
|
-
|
|
140
|
-
## Unicode ไธ็ๆฌ
|
|
141
|
-
|
|
142
|
-
`Unicode.isGraphemeBoundary(text, position)`ใ`isWordBoundary()`ใ`isSentenceBoundary()` ไฝฟ็จ SFML ็ Unicode ่งๅใposition ๆฏ JS ๅญ็ฌฆไธฒ็ UTF-16 ไธๆ ๏ผ่ๅดไธบ 0๏ฝ`text.length`๏ผไปฃ็ๅฏนไธญ้ดไธๆฏ่พน็ใ
|
|
143
|
-
|
|
144
|
-
`version()` ่ฟๅ็ผๅญ็ๅช่ฏป SFML ่ฟ่กๆถ็ๆฌ๏ผๅ
ๅซ `major`ใ`minor`ใ`patch`ใ`isRelease` ไธ `string`ใๅฎไธๆฏ npm ๅ
็ๆฌใ
|
|
145
|
-
|
|
146
|
-
## ้่ฏฏไธๆฅๅฟ
|
|
147
|
-
|
|
148
|
-
SFMLError ่กจ็คบ็ปๅฎๅฑๆ SFML ่ฟ่กๅคฑ่ดฅ๏ผๅฏ็จ `instanceof SFMLError` ๅคๆญใๅๆฐ้่ฏฏไฝฟ็จ TypeError๏ผRangeError๏ผ็จๆทๅ่ฐๆๅบ็้่ฏฏๅๆ ทไผ ๆญใSFML ่ฟๅ็ๆฎ้ๅคฑ่ดฅ็ถๆไปๆฏ false๏ผundefined๏ผไธไผๅ
จ้จ่ฝฌๆขๆๅผๅธธใ
|
|
149
|
-
|
|
150
|
-
`err()` ่ฟๅๅไพ Node Writable๏ผๅๅ
ฅ `sf::err()`ใ`setErrorOutput(writable)` ้ๅฎๅ SFML ๆฅๅฟ๏ผไผ ๅ
ฅ null ้้ณ๏ผไธไผ ๅๆฐๆขๅค้ป่ฎค stderr๏ผ
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
import { createWriteStream } from 'node:fs';
|
|
154
|
-
import { finished } from 'node:stream/promises';
|
|
155
|
-
import { err, setErrorOutput } from 'sfml.js';
|
|
156
|
-
|
|
157
|
-
const output = createWriteStream('sfml.log');
|
|
158
|
-
setErrorOutput(output);
|
|
159
|
-
err().write('SFML diagnostic\n');
|
|
160
|
-
setErrorOutput();
|
|
161
|
-
output.end();
|
|
162
|
-
await finished(output);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
ๆฅๅฟ่ทฏ็ฑๆฏ่ฟ็จ็บง้
็ฝฎ๏ผWorker ๅ
ฑ็จๆ่ฟ็่ฎพ็ฝฎ๏ผNode ่ช่บซ็ stderr ไธๅๅฝฑๅใๅๅฐๆฅๅฟๆๅญ่ๅๆดพๅ๏ผไธไฟ่ฏ UTF-8 ๅญ็ฌฆๆ่ก่พน็๏ผ่งฃๆๆๆฌๆถๅฏไฝฟ็จ StringDecoderใ
|
|
166
|
-
|
|
167
|
-
<a id="sfml-cpp-reference"></a>
|
|
168
|
-
|
|
169
|
-
## SFML C++ ๅ่
|
|
170
|
-
|
|
171
|
-
ๆฐๅญฆไธๆถ้ดๅ่ [sf::Vector2](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Vector2.html)ใ[sf::Angle](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Angle.html)ใ[sf::Time](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Time.html) ๅ [sf::Clock](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Clock.html)๏ผๆตๅ่ฎฎๅ่ [sf::InputStream](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1InputStream.html)ใ
|
|
172
|
-
|
|
173
|
-
ไธๆธธ่ฏดๆๅฏ็จไบ็่งฃๆฐๅญฆใๆถ้ดๅๆต็ๆฆๅฟตใJS ไฝฟ็จๅ
ทๅ่ฟ็ฎ็ฌฆใbigint ๅพฎ็งใPromise sleep ๅๅฏๅผๆญฅ็่พๅ
ฅๆตๆนๆณ๏ผ่ฐ็จๆนๅผๅ่พน็ไปฅๆฌๆไธบๅใ
|
package/docs/window.ja.md
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
# Window
|
|
2
|
-
|
|
3
|
-
[English](window.md) / [็ฎไฝไธญๆ](window.zh-CN.md) / **ๆฅๆฌ่ช** / [ํ๊ตญ์ด](window.ko.md)
|
|
4
|
-
|
|
5
|
-
> 2D ๆ็ปใซใฏ RenderWindow ใไฝฟใใOpenGL ใ่ชๅใง็ตใฟ่พผใๅ ดๅใฏ Window ใๅฉ็จใงใใพใใใฆใฃใณใใฆๆไฝใฏใกใคใณในใฌใใใงๅฎ่กใใพใใ
|
|
6
|
-
|
|
7
|
-
[API ใใใฒใผใทใงใณ](api.ja.md) ยท [Graphics](graphics.ja.md) ยท [ใฏใคใใฏในใฟใผใ](getting-started.ja.md)
|
|
8
|
-
|
|
9
|
-
## ไฝๆใจ็ตไบ
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { RenderWindow, VideoMode, Vector2u, State, Style } from 'sfml.js';
|
|
13
|
-
|
|
14
|
-
const window = new RenderWindow(
|
|
15
|
-
new VideoMode(new Vector2u(800, 600)),
|
|
16
|
-
'sfml.js',
|
|
17
|
-
{
|
|
18
|
-
style: Style.Default,
|
|
19
|
-
state: State.Windowed,
|
|
20
|
-
settings: { depthBits: 24, stencilBits: 8 },
|
|
21
|
-
},
|
|
22
|
-
);
|
|
23
|
-
window.close();
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Window ใจ RenderWindow ใฏ็ฉบใฎใณใณในใใฉใฏใฟใผใงไฝๆใใฆใใ `create()` ใๅผใถๆนๆณใซๅฏพๅฟใใฆใใพใใVector2u ใฎใตใคใบใใๆขๅญใฎ OS ใฆใฃใณใใฆใฎ bigint ใใณใใซใๅใๅใใพใใ`close()` ใฏใฆใฃใณใใฆใ้ใใพใใใJS ใชใใธใงใฏใใฏๅใณ create ใงใใพใใ
|
|
27
|
-
|
|
28
|
-
RenderWindow ใฏ `instanceof Window` ใจ `instanceof RenderTarget` ใฎไธกๆนใๆบใใใพใใ็ดๆฅๆ็ปใงใใใใฆในใฎ็ธๅฏพๅบงๆจใ็
งไผใงใใใปใใ`Texture.update(window)` ใฎๅ
ฅๅๅ
ใซใไฝฟใใพใใ
|
|
29
|
-
|
|
30
|
-
| ใคใณใฟใผใใงใผใน | ็จ้ |
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| `get/setPosition()`ใ`get/setSize()` | ใฆใฃใณใใฆใฎไฝ็ฝฎใจใฏใฉใคใขใณใ้ ๅใฎใตใคใบ |
|
|
33
|
-
| `setMinimumSize()`ใ`setMaximumSize()` | ใตใคใบๅถ้ใundefined ใงๅถ้ใ่งฃ้ค |
|
|
34
|
-
| `setTitle()`ใ`setVisible()`ใ`setIcon()` | ใฟใคใใซใ่กจ็คบใจ้่กจ็คบใRGBA ใขใคใณใณ |
|
|
35
|
-
| `requestFocus()`ใ`hasFocus()` | ใใฉใผใซในใฎ่ฆๆฑใจ็
งไผ |
|
|
36
|
-
| `setMouseCursor()`ใ`setMouseCursorVisible()`ใ`setMouseCursorGrabbed()` | ใซใผใฝใซใจใใฆในใฎ็งปๅ็ฏๅฒใฎๅถ้ |
|
|
37
|
-
| `setKeyRepeatEnabled()`ใ`setJoystickThreshold()` | ๅ
ฅๅใฎๆๅ |
|
|
38
|
-
| `setVerticalSyncEnabled()`ใ`setFramerateLimit()` | ่กจ็คบใฎใฟใคใใณใฐ |
|
|
39
|
-
| `getSettings()`ใ`getNativeHandle()` | ๅฎ้ใฎใณใณใใญในใ่จญๅฎใจ OS ใฆใฃใณใใฆใฎใใณใใซ |
|
|
40
|
-
|
|
41
|
-
ไฝ็ฝฎใซใฏ Vector2iใใตใคใบใซใฏ Vector2u ใไฝฟใใพใใ`setIcon(size, pixels)` ใฏ RGBA8 ใฎใใคใๅใๅใๅใใRenderWindow ใงใฏ Image ใๅใๅใใพใใ
|
|
42
|
-
|
|
43
|
-
## ใคใใณใใซใผใ
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
import { RenderWindow, Vector2u, Keyboard } from 'sfml.js';
|
|
47
|
-
|
|
48
|
-
const window = new RenderWindow(new Vector2u(800, 600), 'Events');
|
|
49
|
-
window.setFramerateLimit(60);
|
|
50
|
-
|
|
51
|
-
function frame() {
|
|
52
|
-
window.handleEvents({
|
|
53
|
-
Closed: () => window.close(),
|
|
54
|
-
KeyPressed: event => {
|
|
55
|
-
if (event.code === Keyboard.Key.Escape) window.close();
|
|
56
|
-
},
|
|
57
|
-
Resized: event => console.log(event.size.x, event.size.y),
|
|
58
|
-
});
|
|
59
|
-
if (!window.isOpen()) return;
|
|
60
|
-
window.clear();
|
|
61
|
-
window.display();
|
|
62
|
-
setImmediate(frame);
|
|
63
|
-
}
|
|
64
|
-
frame();
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
`handleEvents(handlers, fallback?)` ใฏใคใใณใใญใฅใผใ็ฉบใซใชใใพใงๅฆ็ใใๅฏพๅฟใใๅใฎใใณใใฉใผใๅชๅ
ใใฆๅผใณๅบใใพใใๅไธใฎ้ขๆฐใๆธกใใฆใใในใฆใฎใคใใณใใๅฆ็ใใใใจใใงใใพใใ
|
|
68
|
-
|
|
69
|
-
ๆๅใงๆฏใๅใใใๅ ดๅใฏ `pollEvent()` ใไฝฟใใพใใ
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
let event;
|
|
73
|
-
while ((event = window.pollEvent())) {
|
|
74
|
-
if (event.is('Closed')) window.close();
|
|
75
|
-
const key = event.getIf('KeyPressed');
|
|
76
|
-
if (key) console.log(key.code, key.scancode);
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
`pollEvent()` ใฏใคใใณใใใชใใใฐ undefined ใ่ฟใใพใใEvent ใฎ data ใฏ kind ใๅคๅฅๅญใจใใใฆใใชใณๅใงใใ`is()`ใ`getIf()`ใ`visit()` ใงๅใ็ตใ่พผใใ ใใใผใฟใซใขใฏใปในใใใใงใใพใใTextEntered ใฏ Unicode ใณใผใใใคใณใใไฝฟใใพใใ
|
|
81
|
-
|
|
82
|
-
`waitEvent(timeout = Time.Zero)` ใฏๅๆ็ใซใใญใใฏใใใคใณใฟใผใใงใผในใงใใฟใคใ ใขใฆใใพใใฏใฆใฃใณใใฆใฎ็ตไบๆใซ undefined ใ่ฟใใพใใNode ใฎ I/O ใๅฆ็ใใใใฌใผใ ใซใผใใงใฏ pollEvent๏ผhandleEvents ใไฝฟใใใใฌใผใ ้ใงใคใใณใใซใผใใซๅถๅพกใ่ฟใใฆใใ ใใใ
|
|
83
|
-
|
|
84
|
-
## ใชใขใซใฟใคใ ๅ
ฅๅใจใทในใใ ๆฉ่ฝ
|
|
85
|
-
|
|
86
|
-
| ใคใณใฟใผใใงใผใน | ่ชฌๆ |
|
|
87
|
-
| --- | --- |
|
|
88
|
-
| `Keyboard.isKeyPressed(key)` | ็พๅจใฎใญใผใณใผใใฎ็ถๆ
|
|
|
89
|
-
| `Keyboard.isKeyPressed(scancode, 'scancode')` | ็พๅจใฎ็ฉ็ในใญใฃใณใณใผใใฎ็ถๆ
|
|
|
90
|
-
| `Keyboard.localize()`๏ผ`delocalize()`๏ผ`getDescription()` | ็พๅจใฎใญใผใใผใ้
ๅใจใฎใใใใณใฐใจ่ชฌๆ |
|
|
91
|
-
| `Mouse.getPosition(window?)`๏ผ`setPosition(position, window?)` | ใฆใฃใณใใฆใ็็ฅใใๅ ดๅใฏในใฏใชใผใณๅบงๆจใไฝฟ็จ |
|
|
92
|
-
| `Mouse.isButtonPressed(button)` | ็พๅจใฎใใฆในใใฟใณใฎ็ถๆ
|
|
|
93
|
-
| Joystick | ๆฅ็ถใใใฟใณใ่ปธใใใใคใน่ญๅฅๆ
ๅ ฑใใฆใฃใณใใฆใซใผใใใชใๅ ดๅใฏ `update()` ใๅผใถ |
|
|
94
|
-
| Sensor | ๆๅใซ `isAvailable()` ใ็ขบ่ชใใใใฎๅพใซๆๅนๅใจ่ชญใฟๅใใ่กใ |
|
|
95
|
-
| Clipboard | `getString()`๏ผ`setString()`ใJS ใฎ Unicode ๆๅญๅใซๅฏพๅฟ |
|
|
96
|
-
| Touch | ใฟใใ็นใฎ็ถๆ
ใจไฝ็ฝฎใSFML 3.1.0 ใงใฏใชใขใซใฟใคใ Touch API ใฏ้ๆจๅฅจ |
|
|
97
|
-
|
|
98
|
-
ๅ
ฅๅๅๅ็ฉบ้ๅ
ใฎๅๆๅใจใใใใฌใใซใฎๅๆๅใฏๅใใชใใธใงใฏใใๅ
ฑๆใใพใใใใจใใฐ `Keyboard.Key` ใจ `KeyboardKey` ใ่ฉฒๅฝใใพใใ
|
|
99
|
-
|
|
100
|
-
`Cursor.createFromSystem()`ใ`createFromPixels()` ใฏๅคฑๆๆใซ undefined ใ่ฟใใใณใณในใใฉใฏใฟใผใฏๅคฑๆๆใซไพๅคใๆใใพใใใฆใฃใณใใฆใฏไฝฟ็จไธญใฎ Cursor ใฎๅฏฟๅฝใ็ถญๆใใพใใmacOS ใงใฏใใทในใใ ใซใผใฝใซใไฝฟใๅใซใฆใฃใณใใฆใไฝๆใใๅฟ
่ฆใใใใพใใ
|
|
101
|
-
|
|
102
|
-
VideoMode ใฏ `size` ใจ `bitsPerPixel` ใไฝฟใใพใใ`getDesktopMode()`ใ`getFullscreenModes()` ใงใใใคในใฎใขใผใใ็
งไผใใ`isValid()` ใงใใซในใฏใชใผใณใขใผใใฎๆๅนๆงใๅคๅฎใใพใใ็นๅฎใฎๆฐใฎใใซในใฏใชใผใณใขใผใใๅฟ
ใๆไพใใใใจใฏๆณๅฎใใชใใงใใ ใใใ
|
|
103
|
-
|
|
104
|
-
## OpenGL ใจ Vulkan
|
|
105
|
-
|
|
106
|
-
Context ใฏ็ฌ็ซใใ OpenGL ใณใณใใญในใใไฝๆใงใใๆๅนๅใๅฎ้ใฎ่จญๅฎใๆกๅผตใฎ็
งไผใ้ขๆฐใขใใฌในใฎ็
งไผใๆไพใใพใใ`Context.getActiveContextId()` ใฏ bigint ใ่ฟใใๆๅนใชใณใณใใญในใใใชใใใฐ `0n` ใงใใ`getFunction()` ใฏใขใใฌในใ bigint ใง่ฟใใพใใใใฎ้ขๆฐใๅผใณๅบใใซใฏใใทใฐใใใฃใไธ่ดใใใใคใใฃใใณใผใใๅฟ
่ฆใงใใ
|
|
107
|
-
|
|
108
|
-
RenderWindow ใฎ `setActive()`ใ`pushGLStates()`ใ`popGLStates()`ใ`resetGLStates()` ใฏใSFML ใจ็ฌ่ชใฎ OpenGL ๅฆ็ใๆททๅจใใใใใใซไฝฟใใพใใGL ใฎ็ถๆ
ใ็ดๆฅๅคๆดใใๅใซ SFML ใฎใณใใณใใ้ไฟกใใฆใใ ใใใpush๏ผpop ใฏๅใใณใณใใญในใๅ
ใงๅฏพใซใใๅฟ
่ฆใใใใพใใ
|
|
109
|
-
|
|
110
|
-
Vulkan ๅๅ็ฉบ้ใฏไปฅไธใๆไพใใพใใ
|
|
111
|
-
|
|
112
|
-
- `isAvailable(requireGraphics = true)`ใ
|
|
113
|
-
- `getFunction(name)`ใ
|
|
114
|
-
- `getGraphicsRequiredInstanceExtensions()`ใ
|
|
115
|
-
|
|
116
|
-
`window.createVulkanSurface(instance, allocator = 0n)` ใฏใตใผใใงในใใณใใซใ bigint ใง่ฟใใๅคฑๆๆใฏ undefined ใงใใใคใณในใฟใณในใใขใญใฑใผใฟใผใใตใผใใงในใฎ็ ดๆฃใฏๅผใณๅบใๅดใ็ฎก็ใใพใใ
|
|
117
|
-
|
|
118
|
-
SFML 3.1.0 ใฎ macOS ใใซใใซใฏ Vulkan ใใใฏใจใณใใใใใพใใใใใใใฎ็
งไผใฏๅฉ็จไธๅฏใ็คบใใMoltenVK ใใคใณในใใผใซใใฆใ SFML ใฎใใฎใใฉใใใใฉใผใ ๅๅฒใฏๅคใใใพใใใWindows๏ผX11 ใฎๆๅ็ต่ทฏใฏใใใใใใฎ็ฐๅขใงๆค่จผใใๅฟ
่ฆใใใใพใใ
|
|
119
|
-
|
|
120
|
-
## ใใขใฎๅฎ่ก
|
|
121
|
-
|
|
122
|
-
ใใซใๅพใซ `node examples/window.cjs --frames=120` ใๅฎ่กใใใจใใคใใณใใใญใผใณใผใใใใคใณใฟใผใฎไฝ็ฝฎใใฆใฃใณใใฆใฎใใญใใใฃใ็ขบ่ชใงใใพใใใใฌใผใ ๆฐใ็็ฅใใใจ็ถ็ถใใฆๅฎ่กใใพใใ
|
|
123
|
-
|
|
124
|
-
| ใญใผ | ๅไฝ |
|
|
125
|
-
| --- | --- |
|
|
126
|
-
| F1๏ผF2 | ใซใผใฝใซใฎ็จฎ้ก๏ผ่กจ็คบใจ้่กจ็คบ |
|
|
127
|
-
| F3๏ผF4 | ใญใผใชใใผใ๏ผๅ็ดๅๆ |
|
|
128
|
-
| F5๏ผF6 | ใฆใฃใณใใฆใตใคใบ๏ผใตใคใบๅถ้ |
|
|
129
|
-
| F7๏ผF8 | ใฟใคใใซใฎๅคๆด๏ผ1 ็ง้้่กจ็คบใซใใฆใใๅพฉๅ
|
|
|
130
|
-
| F9๏ผF10 | ใคใใณใ API๏ผใฆใฃใณใใฆใฎ็งปๅ |
|
|
131
|
-
| Esc | ้ใใ |
|
|
132
|
-
|
|
133
|
-
macOS ใงใฏ Fn ใญใผใๅๆใซๆผใๅฟ
่ฆใใใๅ ดๅใใใใพใใใธใงใคในใใฃใใฏใใปใณใตใผใใฟใใใVulkan ใฎๆฉ่ฝใฏใใใใคในใฎ็
งไผ็ตๆใซๅบใฅใใฆๅคๆญใใฆใใ ใใใCI ใฎใใซใๆๅใฏใใใใใฎใใผใใฆใงใขๅบๆใฎๅฆ็ใใในใฆๆค่จผๆธใฟใงใใใใจใๆๅณใใพใใใ
|
|
134
|
-
|
|
135
|
-
<a id="sfml-cpp-reference"></a>
|
|
136
|
-
## SFML C++ ใชใใกใฌใณใน
|
|
137
|
-
|
|
138
|
-
ไธๆตใฎ [Window](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Window.html)ใ[RenderWindow](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1RenderWindow.html)ใ[Event](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Event.html)ใ[VideoMode](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1VideoMode.html)ใ[Cursor](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Cursor.html) ใงใฏใใฆใฃใณใใฆใใคใใณใๅใๅบงๆจ่ฆๅใ็ขบ่ชใงใใพใใใใใใฎๆฆๅฟตใฏใใฎใฌใคใใง่ชฌๆใใ็ฏๅฒใง้ฉ็จใใใพใใใJS ใงใฏๆๅญๅใจๅไปใใใคใญใผใใงใคใใณใใๆฏใๅใใ`setImmediate()` ใงใคใใณใใซใผใใซๅถๅพกใ่ฟใใพใใ`waitEvent()` ใฏๅๆ็ใซๅพ
ๆฉใใ็นใซๆณจๆใใฆใใ ใใใ
|
package/docs/window.ko.md
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# Window
|
|
2
|
-
|
|
3
|
-
[English](window.md) / [็ฎไฝไธญๆ](window.zh-CN.md) / [ๆฅๆฌ่ช](window.ja.md) / **ํ๊ตญ์ด**
|
|
4
|
-
|
|
5
|
-
> 2D ๊ทธ๋ฆฌ๊ธฐ์๋ RenderWindow๋ฅผ ์ฌ์ฉํ๊ณ , OpenGL์ ์ง์ ์ฐ๊ฒฐํ ๋๋ Window๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ฐฝ ์์
์ ๋ฉ์ธ ์ค๋ ๋์์ ์คํํฉ๋๋ค.
|
|
6
|
-
|
|
7
|
-
[API ์๋ด](api.ko.md) ยท [Graphics](graphics.ko.md) ยท [๋น ๋ฅธ ์์](getting-started.ko.md)
|
|
8
|
-
|
|
9
|
-
## ์์ฑ๊ณผ ๋ซ๊ธฐ
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { RenderWindow, VideoMode, Vector2u, State, Style } from 'sfml.js';
|
|
13
|
-
|
|
14
|
-
const window = new RenderWindow(
|
|
15
|
-
new VideoMode(new Vector2u(800, 600)),
|
|
16
|
-
'sfml.js',
|
|
17
|
-
{
|
|
18
|
-
style: Style.Default,
|
|
19
|
-
state: State.Windowed,
|
|
20
|
-
settings: { depthBits: 24, stencilBits: 8 },
|
|
21
|
-
},
|
|
22
|
-
);
|
|
23
|
-
window.close();
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Window์ RenderWindow๋ ๋น ์์ฑ์๋ก ๋ง๋ ๋ค `create()`๋ฅผ ํธ์ถํ ์ ์์ผ๋ฉฐ, Vector2u ํฌ๊ธฐ๋ ๊ธฐ์กด ์์คํ
์ฐฝ์ bigint ํธ๋ค๋ ๋ฐ์ต๋๋ค. `close()`๋ ์ฐฝ์ ๋ซ์ผ๋ฉฐ, JS ๊ฐ์ฒด์์๋ ๋ค์ create๋ฅผ ํธ์ถํ ์ ์์ต๋๋ค.
|
|
27
|
-
|
|
28
|
-
RenderWindow๋ `instanceof Window`์ `instanceof RenderTarget`์ ๋ชจ๋ ๋ง์กฑํฉ๋๋ค. ์ง์ ๊ทธ๋ฆฌ๊ฑฐ๋ ์ฐฝ ๊ธฐ์ค ๋ง์ฐ์ค ์ขํ๋ฅผ ์กฐํํ ์ ์๊ณ , `Texture.update(window)`์ ์์ค๋ก๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
|
|
29
|
-
|
|
30
|
-
| ์ธํฐํ์ด์ค | ์ฉ๋ |
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| `get/setPosition()`, `get/setSize()` | ์ฐฝ ์์น์ ํด๋ผ์ด์ธํธ ์์ญ ํฌ๊ธฐ |
|
|
33
|
-
| `setMinimumSize()`, `setMaximumSize()` | ํฌ๊ธฐ ์ ํ. undefined๋ก ์ ํ ํด์ |
|
|
34
|
-
| `setTitle()`, `setVisible()`, `setIcon()` | ์ ๋ชฉ, ํ์ ์ฌ๋ถ, RGBA ์์ด์ฝ |
|
|
35
|
-
| `requestFocus()`, `hasFocus()` | ํฌ์ปค์ค ์์ฒญ๊ณผ ์กฐํ |
|
|
36
|
-
| `setMouseCursor()`, `setMouseCursorVisible()`, `setMouseCursorGrabbed()` | ์ปค์ ๋ฐ ๋ง์ฐ์ค ์ด๋ ์ ํ |
|
|
37
|
-
| `setKeyRepeatEnabled()`, `setJoystickThreshold()` | ์
๋ ฅ ๋์ |
|
|
38
|
-
| `setVerticalSyncEnabled()`, `setFramerateLimit()` | ํ๋ ์ ํ์ ๊ฐ๊ฒฉ |
|
|
39
|
-
| `getSettings()`, `getNativeHandle()` | ์ค์ ์ปจํ
์คํธ ์ค์ ๊ณผ ์์คํ
์ฐฝ ํธ๋ค |
|
|
40
|
-
|
|
41
|
-
์์น๋ Vector2i, ํฌ๊ธฐ๋ Vector2u๋ฅผ ์ฌ์ฉํฉ๋๋ค. `setIcon(size, pixels)`๋ RGBA8 ๋ฐ์ดํธ๋ฅผ ๋ฐ์ผ๋ฉฐ, RenderWindow์์๋ Image๋ ๋ฐ์ต๋๋ค.
|
|
42
|
-
|
|
43
|
-
## ์ด๋ฒคํธ ๋ฃจํ
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
import { RenderWindow, Vector2u, Keyboard } from 'sfml.js';
|
|
47
|
-
|
|
48
|
-
const window = new RenderWindow(new Vector2u(800, 600), 'Events');
|
|
49
|
-
window.setFramerateLimit(60);
|
|
50
|
-
|
|
51
|
-
function frame() {
|
|
52
|
-
window.handleEvents({
|
|
53
|
-
Closed: () => window.close(),
|
|
54
|
-
KeyPressed: event => {
|
|
55
|
-
if (event.code === Keyboard.Key.Escape) window.close();
|
|
56
|
-
},
|
|
57
|
-
Resized: event => console.log(event.size.x, event.size.y),
|
|
58
|
-
});
|
|
59
|
-
if (!window.isOpen()) return;
|
|
60
|
-
window.clear();
|
|
61
|
-
window.display();
|
|
62
|
-
setImmediate(frame);
|
|
63
|
-
}
|
|
64
|
-
frame();
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
`handleEvents(handlers, fallback?)`๋ ์ด๋ฒคํธ ํ๋ฅผ ๋น์ฐ๋ฉฐ, ํด๋น ํ์
์ ํธ๋ค๋ฌ๋ฅผ ์ฐ์ ํธ์ถํฉ๋๋ค. ํ๋์ ํจ์๋ก ๋ชจ๋ ์ด๋ฒคํธ๋ฅผ ์ฒ๋ฆฌํ๋๋ก ์ ๋ฌํ ์๋ ์์ต๋๋ค.
|
|
68
|
-
|
|
69
|
-
์ง์ ๋ถ๊ธฐํด์ผ ํ๋ค๋ฉด `pollEvent()`๋ฅผ ์ฌ์ฉํ์ธ์.
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
let event;
|
|
73
|
-
while ((event = window.pollEvent())) {
|
|
74
|
-
if (event.is('Closed')) window.close();
|
|
75
|
-
const key = event.getIf('KeyPressed');
|
|
76
|
-
if (key) console.log(key.code, key.scancode);
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
`pollEvent()`๋ ์ด๋ฒคํธ๊ฐ ์์ผ๋ฉด undefined๋ฅผ ๋ฐํํฉ๋๋ค. Event์ data๋ kind๋ก ๊ตฌ๋ถํ๋ ์ ๋์จ ํ์
์ด๋ฉฐ, `is()`, `getIf()`, `visit()`์ผ๋ก ํ์
์ ์ขํ๊ฑฐ๋ ๋ฐ์ดํฐ์ ์ ๊ทผํ ์ ์์ต๋๋ค. TextEntered๋ Unicode ์ฝ๋ ํฌ์ธํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
|
|
81
|
-
|
|
82
|
-
`waitEvent(timeout = Time.Zero)`๋ ๋๊ธฐ์ ๋ธ๋กํน ์ธํฐํ์ด์ค๋ก, ํ์์์๋๊ฑฐ๋ ์ฐฝ์ด ๋ซํ๋ฉด undefined๋ฅผ ๋ฐํํฉ๋๋ค. Node I/O๋ฅผ ํจ๊ป ์ฒ๋ฆฌํด์ผ ํ๋ ํ๋ ์ ๋ฃจํ์์๋ pollEvent/handleEvents๋ฅผ ์ฌ์ฉํ๊ณ , ํ๋ ์ ์ฌ์ด์ ์ด๋ฒคํธ ๋ฃจํ์ ์ ์ด๊ถ์ ๋๊ธฐ์ธ์.
|
|
83
|
-
|
|
84
|
-
## ์ค์๊ฐ ์
๋ ฅ๊ณผ ์์คํ
๊ธฐ๋ฅ
|
|
85
|
-
|
|
86
|
-
| ์ธํฐํ์ด์ค | ์ค๋ช
|
|
|
87
|
-
| --- | --- |
|
|
88
|
-
| `Keyboard.isKeyPressed(key)` | ํ์ฌ ํค ์ฝ๋ ์ํ |
|
|
89
|
-
| `Keyboard.isKeyPressed(scancode, 'scancode')` | ํ์ฌ ๋ฌผ๋ฆฌ ์ค์บ ์ฝ๋ ์ํ |
|
|
90
|
-
| `Keyboard.localize()`/`delocalize()`/`getDescription()` | ํ์ฌ ํค๋ณด๋ ๋ ์ด์์ ๋งคํ๊ณผ ์ค๋ช
|
|
|
91
|
-
| `Mouse.getPosition(window?)`/`setPosition(position, window?)` | ์ฐฝ์ ์๋ตํ๋ฉด ํ๋ฉด ์ขํ ์ฌ์ฉ |
|
|
92
|
-
| `Mouse.isButtonPressed(button)` | ํ์ฌ ๋ง์ฐ์ค ๋ฒํผ ์ํ |
|
|
93
|
-
| Joystick | ์ฐ๊ฒฐ, ๋ฒํผ, ์ถ, ์ฅ์น ์๋ณ ์ ๋ณด. ์ฐฝ ๋ฃจํ๊ฐ ์์ผ๋ฉด `update()` ํธ์ถ |
|
|
94
|
-
| Sensor | ๋จผ์ `isAvailable()`๋ก ํ์ธํ ๋ค ํ์ฑํํ๊ณ ์ฝ๊ธฐ |
|
|
95
|
-
| Clipboard | `getString()`/`setString()`, JS Unicode ๋ฌธ์์ด ์ง์ |
|
|
96
|
-
| Touch | ํฐ์น ์ ์ ์ํ์ ์์น. SFML 3.1.0์์ ์ค์๊ฐ Touch API๋ ์ฌ์ฉ ์ค๋จ ์์ ์ผ๋ก ์ง์ ๋จ |
|
|
97
|
-
|
|
98
|
-
์
๋ ฅ ๋ค์์คํ์ด์ค์ ์ด๊ฑฐํ๊ณผ ์ต์์ ์ด๊ฑฐํ์ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๊ณต์ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด `Keyboard.Key`์ `KeyboardKey`๊ฐ ๊ทธ๋ ์ต๋๋ค.
|
|
99
|
-
|
|
100
|
-
`Cursor.createFromSystem()`, `createFromPixels()`๋ ์คํจ ์ undefined๋ฅผ ๋ฐํํ์ง๋ง, ์์ฑ์ ์คํจ๋ ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ์ฐฝ์ ์ฌ์ฉ ์ค์ธ Cursor์ ์๋ช
์ ์ ์งํฉ๋๋ค. macOS์์๋ ์์คํ
์ปค์๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ์ฐฝ์ ๋จผ์ ์์ฑํด์ผ ํฉ๋๋ค.
|
|
101
|
-
|
|
102
|
-
VideoMode๋ `size`์ `bitsPerPixel`์ ์ฌ์ฉํฉ๋๋ค. `getDesktopMode()`, `getFullscreenModes()`๋ ์ฅ์น ๋ชจ๋๋ฅผ ์กฐํํ๊ณ , `isValid()`๋ ์ ์ฒด ํ๋ฉด ๋ชจ๋์ ์ ํจ์ฑ์ ํ๋จํฉ๋๋ค. ๋ชจ๋ ์ปดํจํฐ๊ฐ ํน์ ๊ฐ์์ ์ ์ฒด ํ๋ฉด ๋ชจ๋๋ฅผ ์ ๊ณตํ๋ค๊ณ ๊ฐ์ ํ์ง ๋ง์ธ์.
|
|
103
|
-
|
|
104
|
-
## OpenGL๊ณผ Vulkan
|
|
105
|
-
|
|
106
|
-
Context๋ ๋
๋ฆฝ์ ์ธ OpenGL ์ปจํ
์คํธ๋ฅผ ์์ฑํ๋ฉฐ, ํ์ฑํ, ์ค์ ์ค์ , ํ์ฅ ์กฐํ, ํจ์ ์ฃผ์ ์กฐํ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. `Context.getActiveContextId()`๋ bigint๋ฅผ ๋ฐํํ๊ณ , ํ์ฑ ์ปจํ
์คํธ๊ฐ ์์ผ๋ฉด `0n`์
๋๋ค. `getFunction()`์ ์ฃผ์๋ฅผ bigint๋ก ๋ฐํํ๋ฉฐ, ์ด๋ฅผ ํธ์ถํ๋ ค๋ฉด ์ผ์นํ๋ ์๊ทธ๋์ฒ์ ๋ค์ดํฐ๋ธ ์ฝ๋๊ฐ ํ์ํฉ๋๋ค.
|
|
107
|
-
|
|
108
|
-
RenderWindow์ `setActive()`, `pushGLStates()`, `popGLStates()`, `resetGLStates()`๋ SFML๊ณผ ์ฌ์ฉ์ ์ ์ OpenGL์ ํจ๊ป ์ฌ์ฉํ ๋ ์ฐ์
๋๋ค. GL ์ํ๋ฅผ ์ง์ ์์ ํ๊ธฐ ์ ์ SFML ๋ช
๋ น์ ์ ์ถํ์ธ์. push/pop์ ๊ฐ์ ์ปจํ
์คํธ์์ ์์ ์ด๋ฃจ์ด์ผ ํฉ๋๋ค.
|
|
109
|
-
|
|
110
|
-
Vulkan ๋ค์์คํ์ด์ค๋ ๋ค์์ ์ ๊ณตํฉ๋๋ค.
|
|
111
|
-
|
|
112
|
-
- `isAvailable(requireGraphics = true)`.
|
|
113
|
-
- `getFunction(name)`.
|
|
114
|
-
- `getGraphicsRequiredInstanceExtensions()`.
|
|
115
|
-
|
|
116
|
-
`window.createVulkanSurface(instance, allocator = 0n)`๋ bigint ์ํผ์ค ํธ๋ค์ ๋ฐํํ๊ณ , ์คํจํ๋ฉด undefined๋ฅผ ๋ฐํํฉ๋๋ค. ์ธ์คํด์ค, ํ ๋น์, ์ํผ์ค์ ํด์ ๋ ํธ์ถ์๊ฐ ์ฑ
์์ง๋๋ค.
|
|
117
|
-
|
|
118
|
-
SFML 3.1.0์ macOS ๋น๋๋ Vulkan ๋ฐฑ์๋๋ฅผ ์ ๊ณตํ์ง ์์ต๋๋ค. ์ด ์กฐํ ํจ์๋ค์ ์ฌ์ฉ ๋ถ๊ฐ ์ํ๋ฅผ ๋ฐํํ๋ฉฐ, MoltenVK๋ฅผ ์ค์นํด๋ SFML์ ํด๋น ํ๋ซํผ ๋ถ๊ธฐ๋ ๋ฐ๋์ง ์์ต๋๋ค. Windows/X11์์์ ์ฑ๊ณต ๊ฒฝ๋ก๋ ํด๋น ํ๊ฒฝ์์ ๊ฒ์ฆํด์ผ ํฉ๋๋ค.
|
|
119
|
-
|
|
120
|
-
## ๋ฐ๋ชจ ์คํ
|
|
121
|
-
|
|
122
|
-
๋น๋ ํ `node examples/window.cjs --frames=120`์ ์คํํ๋ฉด ์ด๋ฒคํธ, ํค ์ฝ๋, ํฌ์ธํฐ ์์น, ์ฐฝ ์์ฑ์ ํ์ธํ ์ ์์ต๋๋ค. ํ๋ ์ ์๋ฅผ ์๋ตํ๋ฉด ๊ณ์ ์คํ๋ฉ๋๋ค.
|
|
123
|
-
|
|
124
|
-
| ํค | ๋์ |
|
|
125
|
-
| --- | --- |
|
|
126
|
-
| F1/F2 | ์ปค์ ์ข
๋ฅ/ํ์ ์ฌ๋ถ |
|
|
127
|
-
| F3/F4 | ํค ๋ฐ๋ณต/์์ง ๋๊ธฐํ |
|
|
128
|
-
| F5/F6 | ์ฐฝ ํฌ๊ธฐ/ํฌ๊ธฐ ์ ํ |
|
|
129
|
-
| F7/F8 | ์ ๋ชฉ ๋ณ๊ฒฝ/1์ด ๋์ ์จ๊ธด ๋ค ๋ณต์ |
|
|
130
|
-
| F9/F10 | ์ด๋ฒคํธ API/์ฐฝ ์ด๋ |
|
|
131
|
-
| Esc | ๋ซ๊ธฐ |
|
|
132
|
-
|
|
133
|
-
macOS์์๋ Fn ํค๋ฅผ ํจ๊ป ๋๋ฌ์ผ ํ ์ ์์ต๋๋ค. ์กฐ์ด์คํฑ, ์ผ์, ํฐ์น, Vulkan ๊ธฐ๋ฅ์ ์ฅ์น ์กฐํ ๊ฒฐ๊ณผ๋ก ํ๋จํ์ธ์. CI ๋น๋ ํต๊ณผ๊ฐ ์ด๋ฌํ ํ๋์จ์ด ๊ฒฝ๋ก๋ฅผ ๋ชจ๋ ๊ฒ์ฆํ๋ค๋ ๋ป์ ์๋๋๋ค.
|
|
134
|
-
|
|
135
|
-
<a id="sfml-cpp-reference"></a>
|
|
136
|
-
## SFML C++ ๋ ํผ๋ฐ์ค
|
|
137
|
-
|
|
138
|
-
์๋ณธ ํด๋์ค ๋ฌธ์: [Window](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Window.html), [RenderWindow](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1RenderWindow.html), [Event](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Event.html), [VideoMode](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1VideoMode.html), [Cursor](https://www.sfml-dev.org/documentation/3.1.0/classsf_1_1Cursor.html).
|
|
139
|
-
|
|
140
|
-
C++ ๋ฌธ์์ ์ด๋ฒคํธ ํ์
๊ณผ ์ขํ ๊ท์น์ ์ฐธ๊ณ ํ๋, JS์์๋ ๋ฌธ์์ด๊ณผ ํ์
์ด ์ง์ ๋ ํ์ด๋ก๋๋ก ์ด๋ฒคํธ๋ฅผ ๋ถ๊ธฐํฉ๋๋ค. ํ๋ ์ ์ฌ์ด์๋ `setImmediate()`๋ก ์ ์ด๊ถ์ ๋๊ธฐ๋ฉฐ, `waitEvent()`๋ ๋๊ธฐ์์ด๋ผ๋ ์ ์ ์ ์งํด์ผ ํฉ๋๋ค.
|