sfml.js 0.0.1 → 1.0.0-rc.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/LICENSE +1 -1
- package/README.md +24 -16
- package/binding.gyp +95 -183
- package/dist/audio/effect-processor.d.ts +22 -0
- package/dist/audio/effect-processor.js +28 -0
- package/dist/audio/input-sound-file.d.ts +52 -0
- package/dist/audio/input-sound-file.js +167 -0
- package/dist/audio/listener.d.ts +28 -0
- package/dist/audio/listener.js +86 -0
- package/dist/audio/music.d.ts +60 -0
- package/dist/audio/music.js +192 -0
- package/dist/audio/output-sound-file.d.ts +15 -0
- package/dist/audio/output-sound-file.js +70 -0
- package/dist/audio/playback-device.d.ts +35 -0
- package/dist/audio/playback-device.js +71 -0
- package/dist/audio/sound-buffer-recorder.d.ts +34 -0
- package/dist/audio/sound-buffer-recorder.js +62 -0
- package/dist/audio/sound-buffer.d.ts +45 -0
- package/dist/audio/sound-buffer.js +152 -0
- package/dist/audio/sound-file-factory.d.ts +27 -0
- package/dist/audio/sound-file-factory.js +152 -0
- package/dist/audio/sound-file-reader.d.ts +60 -0
- package/dist/audio/sound-file-reader.js +61 -0
- package/dist/audio/sound-file-writer.d.ts +17 -0
- package/dist/audio/sound-file-writer.js +9 -0
- package/dist/audio/sound-recorder.d.ts +60 -0
- package/dist/audio/sound-recorder.js +162 -0
- package/dist/audio/sound-source.d.ts +108 -0
- package/dist/audio/sound-source.js +161 -0
- package/dist/audio/sound-stream.d.ts +28 -0
- package/dist/audio/sound-stream.js +47 -0
- package/dist/audio/sound.d.ts +14 -0
- package/dist/audio/sound.js +39 -0
- package/dist/audio/value.d.ts +116 -0
- package/dist/audio/value.js +157 -0
- package/dist/audio/worker.d.ts +88 -0
- package/dist/audio/worker.js +2 -0
- package/dist/graphics/blend-mode.d.ts +82 -0
- package/dist/graphics/blend-mode.js +98 -0
- package/dist/graphics/boolean-vector.d.ts +48 -0
- package/dist/graphics/boolean-vector.js +116 -0
- package/dist/graphics/circle-shape.d.ts +27 -0
- package/dist/graphics/circle-shape.js +41 -0
- package/dist/graphics/color.d.ts +93 -0
- package/dist/graphics/color.js +146 -0
- package/dist/graphics/convex-shape.d.ts +18 -0
- package/dist/graphics/convex-shape.js +33 -0
- package/dist/graphics/drawable.d.ts +9 -0
- package/dist/graphics/drawable.js +15 -0
- package/dist/graphics/font.d.ts +70 -0
- package/dist/graphics/font.js +221 -0
- package/dist/graphics/glsl-matrix.d.ts +25 -0
- package/dist/graphics/glsl-matrix.js +69 -0
- package/dist/graphics/glsl.d.ts +57 -0
- package/dist/graphics/glsl.js +112 -0
- package/dist/graphics/glyph.d.ts +44 -0
- package/dist/graphics/glyph.js +74 -0
- package/dist/graphics/image.d.ts +57 -0
- package/dist/graphics/image.js +181 -0
- package/dist/graphics/primitive-type.d.ts +16 -0
- package/dist/graphics/primitive-type.js +25 -0
- package/dist/graphics/rect.d.ts +67 -0
- package/dist/graphics/rect.js +164 -0
- package/dist/graphics/rectangle-shape.d.ts +18 -0
- package/dist/graphics/rectangle-shape.js +34 -0
- package/dist/graphics/render-states.d.ts +60 -0
- package/dist/graphics/render-states.js +74 -0
- package/dist/graphics/render-target.d.ts +99 -0
- package/dist/graphics/render-target.js +341 -0
- package/dist/graphics/render-texture.d.ts +46 -0
- package/dist/graphics/render-texture.js +120 -0
- package/dist/graphics/render-window.d.ts +49 -0
- package/dist/graphics/render-window.js +106 -0
- package/dist/graphics/shader.d.ts +63 -0
- package/dist/graphics/shader.js +215 -0
- package/dist/graphics/shape.d.ts +77 -0
- package/dist/graphics/shape.js +180 -0
- package/dist/graphics/sprite.d.ts +44 -0
- package/dist/graphics/sprite.js +116 -0
- package/dist/graphics/stencil-mode.d.ts +69 -0
- package/dist/graphics/stencil-mode.js +72 -0
- package/dist/graphics/swap.d.ts +6 -0
- package/dist/graphics/swap.js +16 -0
- package/dist/graphics/text.d.ts +238 -0
- package/dist/graphics/text.js +354 -0
- package/dist/graphics/texture.d.ts +78 -0
- package/dist/graphics/texture.js +274 -0
- package/dist/graphics/transform.d.ts +50 -0
- package/dist/graphics/transform.js +195 -0
- package/dist/graphics/transformable.d.ts +13 -0
- package/dist/graphics/transformable.js +27 -0
- package/dist/graphics/vertex-array.d.ts +54 -0
- package/dist/graphics/vertex-array.js +176 -0
- package/dist/graphics/vertex-buffer.d.ts +69 -0
- package/dist/graphics/vertex-buffer.js +167 -0
- package/dist/graphics/vertex.d.ts +42 -0
- package/dist/graphics/vertex.js +98 -0
- package/dist/graphics/view.d.ts +54 -0
- package/dist/graphics/view.js +209 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +251 -0
- package/dist/internal/audio-codec-registry.d.ts +13 -0
- package/dist/internal/audio-codec-registry.js +64 -0
- package/dist/internal/audio-input-stream.d.ts +13 -0
- package/dist/internal/audio-input-stream.js +44 -0
- package/dist/internal/audio-music-pump.d.ts +63 -0
- package/dist/internal/audio-music-pump.js +193 -0
- package/dist/internal/audio-native.d.ts +145 -0
- package/dist/internal/audio-native.js +24 -0
- package/dist/internal/audio-recorder-session.d.ts +77 -0
- package/dist/internal/audio-recorder-session.js +182 -0
- package/dist/internal/audio-worker-session.d.ts +18 -0
- package/dist/internal/audio-worker-session.js +82 -0
- package/dist/internal/audio-worker.d.ts +1 -0
- package/dist/internal/audio-worker.js +134 -0
- package/dist/internal/glsl-value.d.ts +26 -0
- package/dist/internal/glsl-value.js +44 -0
- package/dist/internal/graphics-state.d.ts +45 -0
- package/dist/internal/graphics-state.js +123 -0
- package/dist/internal/input-stream.d.ts +4 -0
- package/dist/internal/input-stream.js +25 -0
- package/dist/internal/lazy-value.d.ts +17 -0
- package/dist/internal/lazy-value.js +43 -0
- package/dist/internal/native.d.ts +317 -0
- package/dist/internal/native.js +8 -0
- package/dist/internal/numeric-properties.d.ts +2 -0
- package/dist/internal/numeric-properties.js +39 -0
- package/dist/internal/render-states.d.ts +4 -0
- package/dist/internal/render-states.js +44 -0
- package/dist/internal/scalar.d.ts +44 -0
- package/dist/internal/scalar.js +95 -0
- package/dist/internal/shaped-glyph.d.ts +32 -0
- package/dist/internal/shaped-glyph.js +51 -0
- package/dist/internal/struct-view.d.ts +11 -0
- package/dist/internal/struct-view.js +39 -0
- package/dist/internal/text-indices.d.ts +7 -0
- package/dist/internal/text-indices.js +22 -0
- package/dist/internal/transformable.d.ts +53 -0
- package/dist/internal/transformable.js +121 -0
- package/dist/internal/value-storage.d.ts +26 -0
- package/dist/internal/value-storage.js +21 -0
- package/dist/network/common.d.ts +18 -0
- package/dist/network/common.js +73 -0
- package/dist/network/dns.d.ts +35 -0
- package/dist/network/dns.js +93 -0
- package/dist/network/ftp.d.ts +81 -0
- package/dist/network/ftp.js +233 -0
- package/dist/network/gen/constants.d.ts +252 -0
- package/dist/network/gen/constants.js +260 -0
- package/dist/network/http.d.ts +150 -0
- package/dist/network/http.js +424 -0
- package/dist/network/ip-address.d.ts +57 -0
- package/dist/network/ip-address.js +161 -0
- package/dist/network/packet.d.ts +78 -0
- package/dist/network/packet.js +238 -0
- package/dist/network/sftp.d.ts +220 -0
- package/dist/network/sftp.js +557 -0
- package/dist/network/socket-selector.d.ts +38 -0
- package/dist/network/socket-selector.js +125 -0
- package/dist/network/socket.d.ts +89 -0
- package/dist/network/socket.js +225 -0
- package/dist/network/tcp-listener.d.ts +36 -0
- package/dist/network/tcp-listener.js +126 -0
- package/dist/network/tcp-socket.d.ts +108 -0
- package/dist/network/tcp-socket.js +362 -0
- package/dist/network/tls-material.d.ts +6 -0
- package/dist/network/tls-material.js +36 -0
- package/dist/network/udp-socket.d.ts +60 -0
- package/dist/network/udp-socket.js +197 -0
- package/dist/system/angle.d.ts +27 -0
- package/dist/system/angle.js +72 -0
- package/dist/system/clock.d.ts +22 -0
- package/dist/system/clock.js +56 -0
- package/dist/system/err.d.ts +6 -0
- package/dist/system/err.js +49 -0
- package/dist/system/error.d.ts +5 -0
- package/dist/system/error.js +12 -0
- package/dist/system/file-input-stream.d.ts +21 -0
- package/dist/system/file-input-stream.js +101 -0
- package/dist/system/input-stream.d.ts +30 -0
- package/dist/system/input-stream.js +54 -0
- package/dist/system/operators.d.ts +164 -0
- package/dist/system/operators.js +402 -0
- package/dist/system/sleep.d.ts +4 -0
- package/dist/system/sleep.js +23 -0
- package/dist/system/suspend-aware-clock.d.ts +7 -0
- package/dist/system/suspend-aware-clock.js +14 -0
- package/dist/system/time.d.ts +31 -0
- package/dist/system/time.js +134 -0
- package/dist/system/timeout-with-predicate.d.ts +19 -0
- package/dist/system/timeout-with-predicate.js +35 -0
- package/dist/system/unicode.d.ts +18 -0
- package/dist/system/unicode.js +31 -0
- package/dist/system/vector2.d.ts +98 -0
- package/dist/system/vector2.js +225 -0
- package/dist/system/vector3.d.ts +83 -0
- package/dist/system/vector3.js +178 -0
- package/dist/system/version.d.ts +15 -0
- package/dist/system/version.js +18 -0
- package/dist/window/clipboard.d.ts +4 -0
- package/dist/window/clipboard.js +16 -0
- package/dist/window/context-settings.d.ts +29 -0
- package/dist/window/context-settings.js +59 -0
- package/dist/window/context.d.ts +27 -0
- package/dist/window/context.js +77 -0
- package/dist/window/cursor.d.ts +20 -0
- package/dist/window/cursor.js +56 -0
- package/dist/window/event.d.ts +176 -0
- package/dist/window/event.js +57 -0
- package/dist/window/gen/constants.d.ts +637 -0
- package/dist/window/gen/constants.js +651 -0
- package/dist/window/joystick.d.ts +25 -0
- package/dist/window/joystick.js +44 -0
- package/dist/window/keyboard.d.ts +14 -0
- package/dist/window/keyboard.js +37 -0
- package/dist/window/mouse.d.ts +10 -0
- package/dist/window/mouse.js +36 -0
- package/dist/window/sensor.d.ts +9 -0
- package/dist/window/sensor.js +23 -0
- package/dist/window/touch.d.ts +12 -0
- package/dist/window/touch.js +29 -0
- package/dist/window/video-mode.d.ts +26 -0
- package/dist/window/video-mode.js +69 -0
- package/dist/window/vulkan.d.ts +9 -0
- package/dist/window/vulkan.js +22 -0
- package/dist/window/window.d.ts +103 -0
- package/dist/window/window.js +227 -0
- package/docs/api.md +1113 -0
- package/docs/audio.md +212 -0
- package/docs/development.md +77 -0
- package/docs/network.md +169 -0
- package/native/addon.cc +129 -0
- package/native/audio-binding.cc +543 -0
- package/native/audio-codec-binding.cc +246 -0
- package/native/audio-device-binding.cc +160 -0
- package/native/audio-file-binding.cc +192 -0
- package/native/audio-recorder-binding.cc +237 -0
- package/native/audio-recorder.h +39 -0
- package/native/audio-state.h +220 -0
- package/native/audio-stream-binding.cc +284 -0
- package/native/audio-stream.h +28 -0
- package/native/audio-worker-binding.cc +447 -0
- package/native/audio-worker.h +121 -0
- package/native/batch-drawable.cc +189 -0
- package/native/batch-drawable.h +57 -0
- package/native/context-binding.cc +180 -0
- package/native/context-settings.h +74 -0
- package/native/deferred-delete.cc +49 -0
- package/native/deferred-delete.h +84 -0
- package/native/error-stream-binding.cc +270 -0
- package/native/exception-boundary.h +97 -0
- package/native/font-binding.cc +210 -0
- package/native/font-state.h +27 -0
- package/native/graphics-binding.cc +338 -0
- package/native/graphics-state.h +253 -0
- package/native/image-binding.cc +258 -0
- package/native/image-state.h +93 -0
- package/native/input-binding.cc +246 -0
- package/native/numeric-fields.h +96 -0
- package/native/render-window-binding.cc +103 -0
- package/native/render-window-state.h +22 -0
- package/native/shader-binding.cc +292 -0
- package/native/shape-binding.cc +283 -0
- package/native/shape-state.h +68 -0
- package/native/shaped-glyph-storage.h +45 -0
- package/native/shared-handle.h +69 -0
- package/native/stream-binding.cc +286 -0
- package/native/system-binding.cc +91 -0
- package/native/text-binding.cc +205 -0
- package/native/text-state.h +101 -0
- package/native/texture-binding.cc +330 -0
- package/native/texture-resource.h +52 -0
- package/native/time-value.h +28 -0
- package/native/transformable-binding.cc +23 -0
- package/native/transformable-state.h +44 -0
- package/native/value-binding.h +200 -0
- package/native/value-layout.h +116 -0
- package/native/values-binding.cc +27 -0
- package/native/vertex-binding.cc +50 -0
- package/native/vertex-buffer-binding.cc +232 -0
- package/native/vertex-storage.h +20 -0
- package/native/view-data.h +24 -0
- package/native/window-binding.cc +388 -0
- package/native/window-event.h +92 -0
- package/native/window-owner.h +81 -0
- package/package.json +77 -35
- package/src/audio/effect-processor.ts +41 -0
- package/src/audio/input-sound-file.ts +173 -0
- package/src/audio/listener.ts +74 -0
- package/src/audio/music.ts +191 -0
- package/src/audio/output-sound-file.ts +64 -0
- package/src/audio/playback-device.ts +59 -0
- package/src/audio/sound-buffer-recorder.ts +61 -0
- package/src/audio/sound-buffer.ts +170 -0
- package/src/audio/sound-file-factory.ts +162 -0
- package/src/audio/sound-file-reader.ts +93 -0
- package/src/audio/sound-file-writer.ts +19 -0
- package/src/audio/sound-recorder.ts +180 -0
- package/src/audio/sound-source.ts +168 -0
- package/src/audio/sound-stream.ts +60 -0
- package/src/audio/sound.ts +36 -0
- package/src/audio/value.ts +165 -0
- package/src/audio/worker.ts +90 -0
- package/src/graphics/blend-mode.ts +125 -0
- package/src/graphics/boolean-vector.ts +139 -0
- package/src/graphics/circle-shape.ts +56 -0
- package/src/graphics/color.ts +189 -0
- package/src/graphics/convex-shape.ts +38 -0
- package/src/graphics/drawable.ts +19 -0
- package/src/graphics/font.ts +248 -0
- package/src/graphics/glsl-matrix.ts +73 -0
- package/src/graphics/glsl.ts +121 -0
- package/src/graphics/glyph.ts +97 -0
- package/src/graphics/image.ts +231 -0
- package/src/graphics/primitive-type.ts +21 -0
- package/src/graphics/rect.ts +214 -0
- package/src/graphics/rectangle-shape.ts +39 -0
- package/src/graphics/render-states.ts +110 -0
- package/src/graphics/render-target.ts +431 -0
- package/src/graphics/render-texture.ts +150 -0
- package/src/graphics/render-window.ts +155 -0
- package/src/graphics/shader.ts +224 -0
- package/src/graphics/shape.ts +231 -0
- package/src/graphics/sprite.ts +143 -0
- package/src/graphics/stencil-mode.ts +97 -0
- package/src/graphics/swap.ts +17 -0
- package/src/graphics/text.ts +423 -0
- package/src/graphics/texture.ts +352 -0
- package/src/graphics/transform.ts +242 -0
- package/src/graphics/transformable.ts +26 -0
- package/src/graphics/vertex-array.ts +201 -0
- package/src/graphics/vertex-buffer.ts +209 -0
- package/src/graphics/vertex.ts +142 -0
- package/src/graphics/view.ts +237 -0
- package/src/index.ts +147 -0
- package/src/internal/audio-codec-registry.ts +68 -0
- package/src/internal/audio-input-stream.ts +42 -0
- package/src/internal/audio-music-pump.ts +199 -0
- package/src/internal/audio-native.ts +176 -0
- package/src/internal/audio-recorder-session.ts +234 -0
- package/src/internal/audio-worker-session.ts +89 -0
- package/src/internal/audio-worker.ts +146 -0
- package/src/internal/glsl-value.ts +54 -0
- package/src/internal/graphics-state.ts +131 -0
- package/src/internal/input-stream.ts +30 -0
- package/src/internal/lazy-value.ts +62 -0
- package/src/internal/native.ts +581 -0
- package/src/internal/numeric-properties.ts +37 -0
- package/src/internal/render-states.ts +42 -0
- package/src/internal/scalar.ts +109 -0
- package/src/internal/shaped-glyph.ts +68 -0
- package/src/internal/struct-view.ts +49 -0
- package/src/internal/text-indices.ts +19 -0
- package/src/internal/transformable.ts +189 -0
- package/src/internal/value-storage.ts +33 -0
- package/src/network/common.ts +53 -0
- package/src/network/dns.ts +102 -0
- package/src/network/ftp.ts +202 -0
- package/src/network/gen/constants.ts +253 -0
- package/src/network/http.ts +372 -0
- package/src/network/ip-address.ts +158 -0
- package/src/network/packet.ts +217 -0
- package/src/network/sftp.ts +574 -0
- package/src/network/socket-selector.ts +112 -0
- package/src/network/socket.ts +203 -0
- package/src/network/tcp-listener.ts +115 -0
- package/src/network/tcp-socket.ts +370 -0
- package/src/network/tls-material.ts +30 -0
- package/src/network/udp-socket.ts +176 -0
- package/src/system/angle.ts +82 -0
- package/src/system/clock.ts +61 -0
- package/src/system/err.ts +46 -0
- package/src/system/error.ts +8 -0
- package/src/system/file-input-stream.ts +100 -0
- package/src/system/input-stream.ts +66 -0
- package/src/system/operators.ts +554 -0
- package/src/system/sleep.ts +20 -0
- package/src/system/suspend-aware-clock.ts +12 -0
- package/src/system/time.ts +149 -0
- package/src/system/timeout-with-predicate.ts +53 -0
- package/src/system/unicode.ts +28 -0
- package/src/system/vector2.ts +345 -0
- package/src/system/vector3.ts +267 -0
- package/src/system/version.ts +30 -0
- package/src/window/clipboard.ts +12 -0
- package/src/window/context-settings.ts +78 -0
- package/src/window/context.ts +92 -0
- package/src/window/cursor.ts +78 -0
- package/src/window/event.ts +227 -0
- package/src/window/gen/constants.ts +655 -0
- package/src/window/joystick.ts +52 -0
- package/src/window/keyboard.ts +42 -0
- package/src/window/mouse.ts +37 -0
- package/src/window/sensor.ts +20 -0
- package/src/window/touch.ts +27 -0
- package/src/window/video-mode.ts +85 -0
- package/src/window/vulkan.ts +19 -0
- package/src/window/window.ts +311 -0
- package/test/native/audio-probes.cc +181 -0
- package/test/native/deferred-delete-probes.cc +62 -0
- package/test/native/drawable-probes.cc +168 -0
- package/test/native/exception-probes.cc +83 -0
- package/test/native/image-probes.cc +105 -0
- package/test/native/matrix-probes.cc +67 -0
- package/test/native/network-oracle.cc +32 -0
- package/test/native/render-texture-probes.cc +193 -0
- package/test/native/shader-probes.cc +69 -0
- package/test/native/shape-probes.cc +160 -0
- package/test/native/sprite-probes.cc +146 -0
- package/test/native/system-probes.cc +109 -0
- package/test/native/text-probes.cc +211 -0
- package/test/native/texture-probes.cc +200 -0
- package/test/native/time-probes.cc +143 -0
- package/test/native/transform-probes.cc +92 -0
- package/test/native/transformable-probes.cc +152 -0
- package/test/native/value-oracle.h +88 -0
- package/test/native/value-probes.cc +379 -0
- package/test/native/vertex-array-probes.cc +82 -0
- package/test/native/vertex-buffer-probes.cc +87 -0
- package/test/native/view-probes.cc +150 -0
- package/test/native/window-probes.cc +172 -0
- package/test/tsconfig.json +8 -0
- package/tools/configure-lsp.cjs +23 -0
- package/tools/generate-network-constants.cjs +47 -0
- package/tools/generate-window-constants.cjs +164 -0
- package/tools/lib_downloader.cjs +92 -0
- package/tools/lib_downloader_urls.cjs +23 -0
- package/tsconfig.json +11 -4
- package/index.d.ts +0 -1
- package/lib/clock.d.ts +0 -8
- package/lib/clock.js +0 -5
- package/lib/color.d.ts +0 -11
- package/lib/color.js +0 -98
- package/lib/common.js +0 -47
- package/lib/drawable/circle_shape.d.ts +0 -5
- package/lib/drawable/circle_shape.js +0 -26
- package/lib/drawable/convex_shape.d.ts +0 -5
- package/lib/drawable/convex_shape.js +0 -35
- package/lib/drawable/drawable.d.ts +0 -6
- package/lib/drawable/drawable.js +0 -18
- package/lib/drawable/plugin_package.d.ts +0 -31
- package/lib/drawable/plugin_package.js +0 -102
- package/lib/drawable/rectangle_shape.d.ts +0 -9
- package/lib/drawable/rectangle_shape.js +0 -28
- package/lib/drawable/shape.d.ts +0 -14
- package/lib/drawable/shape.js +0 -30
- package/lib/drawable/sprite.d.ts +0 -17
- package/lib/drawable/sprite.js +0 -53
- package/lib/drawable/text.d.ts +0 -26
- package/lib/drawable/text.js +0 -88
- package/lib/drawable/transformable.d.ts +0 -28
- package/lib/drawable/transformable.js +0 -113
- package/lib/drawable/vertex_array.d.ts +0 -40
- package/lib/drawable/vertex_array.js +0 -128
- package/lib/font.d.ts +0 -24
- package/lib/font.js +0 -137
- package/lib/image.d.ts +0 -26
- package/lib/image.js +0 -147
- package/lib/joystick.d.ts +0 -21
- package/lib/joystick.js +0 -72
- package/lib/keyboard.d.ts +0 -113
- package/lib/keyboard.js +0 -17
- package/lib/mouse.d.ts +0 -6
- package/lib/mouse.js +0 -39
- package/lib/poll_event.d.ts +0 -138
- package/lib/rect.d.ts +0 -18
- package/lib/rect.js +0 -119
- package/lib/render_window.d.ts +0 -67
- package/lib/render_window.js +0 -197
- package/lib/sensor.d.ts +0 -12
- package/lib/sensor.js +0 -34
- package/lib/sfml.d.ts +0 -32
- package/lib/sfml.js +0 -36
- package/lib/sound/base.d.ts +0 -33
- package/lib/sound/base.js +0 -109
- package/lib/sound/music.d.ts +0 -15
- package/lib/sound/music.js +0 -65
- package/lib/sound/sound.d.ts +0 -16
- package/lib/sound/sound.js +0 -55
- package/lib/sound/sound_buffer.d.ts +0 -14
- package/lib/sound/sound_buffer.js +0 -78
- package/lib/texture.d.ts +0 -21
- package/lib/texture.js +0 -127
- package/lib/time.d.ts +0 -13
- package/lib/time.js +0 -41
- package/lib/touch.d.ts +0 -7
- package/lib/touch.js +0 -34
- package/lib/vector2.d.ts +0 -49
- package/lib/vector2.js +0 -141
- package/lib/vector3.d.ts +0 -47
- package/lib/vector3.js +0 -154
- package/lib/vertex.d.ts +0 -14
- package/lib/vertex.js +0 -177
- package/lib/video_mode.d.ts +0 -12
- package/lib/video_mode.js +0 -99
- package/src/base_class_with_loading.h +0 -21
- package/src/clock.cc +0 -71
- package/src/clock.h +0 -30
- package/src/color.cc +0 -189
- package/src/color.h +0 -49
- package/src/drawable/circle_shape.cc +0 -78
- package/src/drawable/circle_shape.h +0 -28
- package/src/drawable/convex_shape.cc +0 -57
- package/src/drawable/convex_shape.h +0 -29
- package/src/drawable/drawable-inl.h +0 -29
- package/src/drawable/drawable.cc +0 -41
- package/src/drawable/drawable.h +0 -49
- package/src/drawable/package_plugin-inl.h +0 -191
- package/src/drawable/package_plugin.h +0 -60
- package/src/drawable/rectangle_shape.cc +0 -69
- package/src/drawable/rectangle_shape.h +0 -29
- package/src/drawable/shape.cc +0 -67
- package/src/drawable/shape.h +0 -39
- package/src/drawable/sprite.cc +0 -122
- package/src/drawable/sprite.h +0 -45
- package/src/drawable/text.cc +0 -133
- package/src/drawable/text.h +0 -54
- package/src/drawable/vertex_array.cc +0 -248
- package/src/drawable/vertex_array.h +0 -46
- package/src/font.cc +0 -214
- package/src/font.h +0 -44
- package/src/gen/.gitkeep +0 -0
- package/src/gen/joystick_axis.cc +0 -30
- package/src/gen/keycode.cc +0 -226
- package/src/gen/mouse_button.cc +0 -30
- package/src/gen/sensor_type.cc +0 -26
- package/src/image.cc +0 -379
- package/src/image.h +0 -72
- package/src/joystick.cc +0 -132
- package/src/joystick.h +0 -32
- package/src/keyboard.cc +0 -65
- package/src/keyboard.h +0 -27
- package/src/mouse.cc +0 -95
- package/src/mouse.h +0 -30
- package/src/plugins/transformable_plugin-inl.h +0 -121
- package/src/plugins/transformable_plugin.h +0 -42
- package/src/poll_event.cc +0 -326
- package/src/poll_event.h +0 -18
- package/src/rect-inl.h +0 -154
- package/src/rect.cc +0 -28
- package/src/rect.h +0 -105
- package/src/render_window.cc +0 -413
- package/src/render_window.h +0 -111
- package/src/render_window_async_display.cc +0 -49
- package/src/render_window_async_draw.cc +0 -56
- package/src/resizable_buffer.h +0 -104
- package/src/sensor.cc +0 -82
- package/src/sensor.h +0 -28
- package/src/sfml.cc +0 -85
- package/src/sound/music.cc +0 -113
- package/src/sound/music.h +0 -35
- package/src/sound/sound.cc +0 -116
- package/src/sound/sound.h +0 -41
- package/src/sound/sound_buffer.cc +0 -226
- package/src/sound/sound_buffer.h +0 -46
- package/src/sound/sound_source.cc +0 -124
- package/src/sound/sound_source.h +0 -80
- package/src/texture.cc +0 -246
- package/src/texture.h +0 -47
- package/src/time.cc +0 -177
- package/src/time.h +0 -42
- package/src/touch.cc +0 -54
- package/src/touch.h +0 -23
- package/src/utils-inl.h +0 -48
- package/src/utils.h +0 -21
- package/src/vector2-inl.h +0 -198
- package/src/vector2.cc +0 -36
- package/src/vector2.h +0 -133
- package/src/vector3-inl.h +0 -200
- package/src/vector3.cc +0 -36
- package/src/vector3.h +0 -134
- package/src/vertex.cc +0 -238
- package/src/vertex.h +0 -114
- package/src/video_mode.cc +0 -184
- package/src/video_mode.h +0 -38
- package/src/workers/load_from_file_worker.h +0 -79
- package/src/workers/save_to_file_worker.h +0 -79
- package/third_party/sfml/include/SFML/Audio/AlResource.hpp +0 -70
- package/third_party/sfml/include/SFML/Audio/Export.hpp +0 -48
- package/third_party/sfml/include/SFML/Audio/InputSoundFile.hpp +0 -268
- package/third_party/sfml/include/SFML/Audio/Listener.hpp +0 -234
- package/third_party/sfml/include/SFML/Audio/Music.hpp +0 -337
- package/third_party/sfml/include/SFML/Audio/OutputSoundFile.hpp +0 -133
- package/third_party/sfml/include/SFML/Audio/Sound.hpp +0 -264
- package/third_party/sfml/include/SFML/Audio/SoundBuffer.hpp +0 -352
- package/third_party/sfml/include/SFML/Audio/SoundBufferRecorder.hpp +0 -144
- package/third_party/sfml/include/SFML/Audio/SoundFileFactory.hpp +0 -197
- package/third_party/sfml/include/SFML/Audio/SoundFileFactory.inl +0 -100
- package/third_party/sfml/include/SFML/Audio/SoundFileReader.hpp +0 -165
- package/third_party/sfml/include/SFML/Audio/SoundFileWriter.hpp +0 -125
- package/third_party/sfml/include/SFML/Audio/SoundRecorder.hpp +0 -410
- package/third_party/sfml/include/SFML/Audio/SoundSource.hpp +0 -332
- package/third_party/sfml/include/SFML/Audio/SoundStream.hpp +0 -420
- package/third_party/sfml/include/SFML/Audio.hpp +0 -56
- package/third_party/sfml/include/SFML/Config.hpp +0 -248
- package/third_party/sfml/include/SFML/GpuPreference.hpp +0 -74
- package/third_party/sfml/include/SFML/Graphics/BlendMode.hpp +0 -219
- package/third_party/sfml/include/SFML/Graphics/CircleShape.hpp +0 -154
- package/third_party/sfml/include/SFML/Graphics/Color.hpp +0 -275
- package/third_party/sfml/include/SFML/Graphics/ConvexShape.hpp +0 -153
- package/third_party/sfml/include/SFML/Graphics/Drawable.hpp +0 -126
- package/third_party/sfml/include/SFML/Graphics/Export.hpp +0 -48
- package/third_party/sfml/include/SFML/Graphics/Font.hpp +0 -496
- package/third_party/sfml/include/SFML/Graphics/Glsl.hpp +0 -227
- package/third_party/sfml/include/SFML/Graphics/Glsl.inl +0 -155
- package/third_party/sfml/include/SFML/Graphics/Glyph.hpp +0 -81
- package/third_party/sfml/include/SFML/Graphics/Image.hpp +0 -346
- package/third_party/sfml/include/SFML/Graphics/PrimitiveType.hpp +0 -58
- package/third_party/sfml/include/SFML/Graphics/Rect.hpp +0 -274
- package/third_party/sfml/include/SFML/Graphics/Rect.inl +0 -171
- package/third_party/sfml/include/SFML/Graphics/RectangleShape.hpp +0 -132
- package/third_party/sfml/include/SFML/Graphics/RenderStates.hpp +0 -174
- package/third_party/sfml/include/SFML/Graphics/RenderTarget.hpp +0 -518
- package/third_party/sfml/include/SFML/Graphics/RenderTexture.hpp +0 -334
- package/third_party/sfml/include/SFML/Graphics/RenderWindow.hpp +0 -302
- package/third_party/sfml/include/SFML/Graphics/Shader.hpp +0 -875
- package/third_party/sfml/include/SFML/Graphics/Shape.hpp +0 -355
- package/third_party/sfml/include/SFML/Graphics/Sprite.hpp +0 -279
- package/third_party/sfml/include/SFML/Graphics/Text.hpp +0 -513
- package/third_party/sfml/include/SFML/Graphics/Texture.hpp +0 -733
- package/third_party/sfml/include/SFML/Graphics/Transform.hpp +0 -497
- package/third_party/sfml/include/SFML/Graphics/Transformable.hpp +0 -429
- package/third_party/sfml/include/SFML/Graphics/Vertex.hpp +0 -148
- package/third_party/sfml/include/SFML/Graphics/VertexArray.hpp +0 -223
- package/third_party/sfml/include/SFML/Graphics/VertexBuffer.hpp +0 -408
- package/third_party/sfml/include/SFML/Graphics/View.hpp +0 -343
- package/third_party/sfml/include/SFML/Graphics.hpp +0 -68
- package/third_party/sfml/include/SFML/Main.hpp +0 -43
- package/third_party/sfml/include/SFML/Network/Export.hpp +0 -48
- package/third_party/sfml/include/SFML/Network/Ftp.hpp +0 -616
- package/third_party/sfml/include/SFML/Network/Http.hpp +0 -482
- package/third_party/sfml/include/SFML/Network/IpAddress.hpp +0 -328
- package/third_party/sfml/include/SFML/Network/Packet.hpp +0 -545
- package/third_party/sfml/include/SFML/Network/Socket.hpp +0 -219
- package/third_party/sfml/include/SFML/Network/SocketHandle.hpp +0 -57
- package/third_party/sfml/include/SFML/Network/SocketSelector.hpp +0 -263
- package/third_party/sfml/include/SFML/Network/TcpListener.hpp +0 -170
- package/third_party/sfml/include/SFML/Network/TcpSocket.hpp +0 -316
- package/third_party/sfml/include/SFML/Network/UdpSocket.hpp +0 -292
- package/third_party/sfml/include/SFML/Network.hpp +0 -53
- package/third_party/sfml/include/SFML/OpenGL.hpp +0 -78
- package/third_party/sfml/include/SFML/System/Clock.hpp +0 -117
- package/third_party/sfml/include/SFML/System/Err.hpp +0 -80
- package/third_party/sfml/include/SFML/System/Export.hpp +0 -48
- package/third_party/sfml/include/SFML/System/FileInputStream.hpp +0 -169
- package/third_party/sfml/include/SFML/System/InputStream.hpp +0 -152
- package/third_party/sfml/include/SFML/System/Lock.hpp +0 -139
- package/third_party/sfml/include/SFML/System/MemoryInputStream.hpp +0 -148
- package/third_party/sfml/include/SFML/System/Mutex.hpp +0 -148
- package/third_party/sfml/include/SFML/System/NativeActivity.hpp +0 -62
- package/third_party/sfml/include/SFML/System/NonCopyable.hpp +0 -129
- package/third_party/sfml/include/SFML/System/Sleep.hpp +0 -52
- package/third_party/sfml/include/SFML/System/String.hpp +0 -669
- package/third_party/sfml/include/SFML/System/String.inl +0 -53
- package/third_party/sfml/include/SFML/System/Thread.hpp +0 -282
- package/third_party/sfml/include/SFML/System/Thread.inl +0 -90
- package/third_party/sfml/include/SFML/System/ThreadLocal.hpp +0 -103
- package/third_party/sfml/include/SFML/System/ThreadLocalPtr.hpp +0 -158
- package/third_party/sfml/include/SFML/System/ThreadLocalPtr.inl +0 -77
- package/third_party/sfml/include/SFML/System/Time.hpp +0 -488
- package/third_party/sfml/include/SFML/System/Utf.hpp +0 -763
- package/third_party/sfml/include/SFML/System/Utf.inl +0 -752
- package/third_party/sfml/include/SFML/System/Vector2.hpp +0 -301
- package/third_party/sfml/include/SFML/System/Vector2.inl +0 -161
- package/third_party/sfml/include/SFML/System/Vector3.hpp +0 -302
- package/third_party/sfml/include/SFML/System/Vector3.inl +0 -168
- package/third_party/sfml/include/SFML/System.hpp +0 -60
- package/third_party/sfml/include/SFML/Window/Clipboard.hpp +0 -119
- package/third_party/sfml/include/SFML/Window/Context.hpp +0 -195
- package/third_party/sfml/include/SFML/Window/ContextSettings.hpp +0 -149
- package/third_party/sfml/include/SFML/Window/Cursor.hpp +0 -241
- package/third_party/sfml/include/SFML/Window/Event.hpp +0 -285
- package/third_party/sfml/include/SFML/Window/Export.hpp +0 -48
- package/third_party/sfml/include/SFML/Window/GlResource.hpp +0 -109
- package/third_party/sfml/include/SFML/Window/Joystick.hpp +0 -227
- package/third_party/sfml/include/SFML/Window/Keyboard.hpp +0 -491
- package/third_party/sfml/include/SFML/Window/Mouse.hpp +0 -180
- package/third_party/sfml/include/SFML/Window/Sensor.hpp +0 -150
- package/third_party/sfml/include/SFML/Window/Touch.hpp +0 -137
- package/third_party/sfml/include/SFML/Window/VideoMode.hpp +0 -228
- package/third_party/sfml/include/SFML/Window/Vulkan.hpp +0 -115
- package/third_party/sfml/include/SFML/Window/Window.hpp +0 -354
- package/third_party/sfml/include/SFML/Window/WindowBase.hpp +0 -518
- package/third_party/sfml/include/SFML/Window/WindowHandle.hpp +0 -101
- package/third_party/sfml/include/SFML/Window/WindowStyle.hpp +0 -53
- package/third_party/sfml/include/SFML/Window.hpp +0 -58
- package/tools/clang_format.js +0 -9
- package/tools/copier/linux.js +0 -21
- package/tools/copier/macos.js +0 -34
- package/tools/copier/windows.js +0 -33
- package/tools/joystick_axis.js +0 -63
- package/tools/keycode.js +0 -92
- package/tools/lib_downloader.js +0 -107
- package/tools/lib_downloader_urls.js +0 -59
- package/tools/mouse_button.js +0 -92
- package/tools/sensor_type.js +0 -63
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Font = exports.textFloat = exports.fontUnsigned = exports.fontRevision = void 0;
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const native_1 = require("../internal/native");
|
|
7
|
+
const struct_view_1 = require("../internal/struct-view");
|
|
8
|
+
const graphics_state_1 = require("../internal/graphics-state");
|
|
9
|
+
const input_stream_1 = require("../system/input-stream");
|
|
10
|
+
const glyph_1 = require("./glyph");
|
|
11
|
+
const texture_1 = require("./texture");
|
|
12
|
+
exports.fontRevision = Symbol('Font.revision');
|
|
13
|
+
function fontUnsigned(value, maximum = 0xffffffff) {
|
|
14
|
+
if (!Number.isInteger(value) || value < 0 || value > maximum) {
|
|
15
|
+
throw new RangeError('Expected an unsigned integer within range');
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
exports.fontUnsigned = fontUnsigned;
|
|
20
|
+
function textFloat(value) {
|
|
21
|
+
if (typeof value !== 'number')
|
|
22
|
+
throw new TypeError('Expected a number');
|
|
23
|
+
const result = Math.fround(value);
|
|
24
|
+
if (!Number.isFinite(result))
|
|
25
|
+
throw new RangeError('Expected a finite float32 value');
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
exports.textFloat = textFloat;
|
|
29
|
+
function flag(value) {
|
|
30
|
+
if (typeof value !== 'boolean')
|
|
31
|
+
throw new TypeError('Expected a boolean');
|
|
32
|
+
}
|
|
33
|
+
function fontViews(mapping) {
|
|
34
|
+
const { smooth, ...fields } = mapping.fields;
|
|
35
|
+
return {
|
|
36
|
+
info: (0, struct_view_1.nativeStruct)({ buffers: mapping.buffers, fields }, { family: mapping.family }),
|
|
37
|
+
sampling: (0, struct_view_1.nativeStruct)({
|
|
38
|
+
buffers: mapping.buffers, fields: { smooth },
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Native-owned font face, input storage and retained glyph atlases. */
|
|
43
|
+
class Font {
|
|
44
|
+
/** 创建空字体,或从现有字体创建副本。 */
|
|
45
|
+
constructor(source) {
|
|
46
|
+
this[_a] = 0;
|
|
47
|
+
this.textures = new Map();
|
|
48
|
+
this.glyphs = new Map();
|
|
49
|
+
this.metrics = new Map();
|
|
50
|
+
this.kernings = new Map();
|
|
51
|
+
this.coverage = new Map();
|
|
52
|
+
if (source !== undefined && !(source instanceof Font)) {
|
|
53
|
+
throw new TypeError('Expected a Font');
|
|
54
|
+
}
|
|
55
|
+
const mapping = native_1.native.createFont((0, graphics_state_1.graphicsContext)(), source?.[graphics_state_1.graphicsNative]);
|
|
56
|
+
this[graphics_state_1.graphicsNative] = mapping.handle;
|
|
57
|
+
this.state = fontViews(mapping);
|
|
58
|
+
}
|
|
59
|
+
/** 异步打开字体文件,成功后替换字体并清空度量缓存,返回是否成功。 */
|
|
60
|
+
async openFromFile(filename) {
|
|
61
|
+
if (typeof filename !== 'string' || filename.includes('\0')) {
|
|
62
|
+
throw new TypeError('Expected a font path without null bytes');
|
|
63
|
+
}
|
|
64
|
+
return this.open(filename ? (0, node_path_1.resolve)(filename) : filename);
|
|
65
|
+
}
|
|
66
|
+
/** 从编码字体字节异步打开字体,返回是否成功。 */
|
|
67
|
+
async openFromMemory(data) {
|
|
68
|
+
if (!(data instanceof Uint8Array))
|
|
69
|
+
throw new TypeError('Expected a Uint8Array');
|
|
70
|
+
return this.open(data);
|
|
71
|
+
}
|
|
72
|
+
/** 从流起点读取全部字体字节并异步打开;返回是否成功,流异常会拒绝 Promise。 */
|
|
73
|
+
async openFromStream(stream) {
|
|
74
|
+
if (!(stream instanceof input_stream_1.InputStream))
|
|
75
|
+
throw new TypeError('Expected an InputStream');
|
|
76
|
+
const size = await stream.getSize();
|
|
77
|
+
if (size === undefined || size === 0n)
|
|
78
|
+
return false;
|
|
79
|
+
if (typeof size !== 'bigint' || size < 0n || size > 0x7fffffffn) {
|
|
80
|
+
throw new RangeError('Font stream size exceeds the buffer limit');
|
|
81
|
+
}
|
|
82
|
+
const position = await stream.seek(0n);
|
|
83
|
+
if (position === undefined)
|
|
84
|
+
return false;
|
|
85
|
+
if (position !== 0n)
|
|
86
|
+
throw new RangeError('Font stream must seek to its beginning');
|
|
87
|
+
const bytes = new Uint8Array(Number(size));
|
|
88
|
+
let offset = 0;
|
|
89
|
+
while (offset < bytes.length) {
|
|
90
|
+
const count = await stream.read(bytes.subarray(offset));
|
|
91
|
+
if (count === undefined || count === 0n)
|
|
92
|
+
return false;
|
|
93
|
+
if (typeof count !== 'bigint' || count < 0n ||
|
|
94
|
+
count > BigInt(bytes.length - offset)) {
|
|
95
|
+
throw new RangeError('Invalid font stream read count');
|
|
96
|
+
}
|
|
97
|
+
offset += Number(count);
|
|
98
|
+
}
|
|
99
|
+
return this.open(bytes);
|
|
100
|
+
}
|
|
101
|
+
/** 返回当前字体信息的只读视图。 */
|
|
102
|
+
getInfo() { return this.state.info; }
|
|
103
|
+
/** 获取 Unicode 码点对应的缓存字形;字号和轮廓厚度以像素计,bold 控制加粗。 */
|
|
104
|
+
getGlyph(codePoint, characterSize, bold, outlineThickness = 0) {
|
|
105
|
+
fontUnsigned(codePoint, 0x10ffff);
|
|
106
|
+
return this.glyph(codePoint, characterSize, bold, outlineThickness, false);
|
|
107
|
+
}
|
|
108
|
+
/** 按字体内部字形编号取得字形;字号和轮廓厚度以像素计。 */
|
|
109
|
+
getGlyphById(id, characterSize, bold, outlineThickness = 0) {
|
|
110
|
+
fontUnsigned(id);
|
|
111
|
+
return this.glyph(id, characterSize, bold, outlineThickness, true);
|
|
112
|
+
}
|
|
113
|
+
/** 返回字体是否包含指定 Unicode 码点的字形。 */
|
|
114
|
+
hasGlyph(codePoint) {
|
|
115
|
+
fontUnsigned(codePoint, 0x10ffff);
|
|
116
|
+
let exists = this.coverage.get(codePoint);
|
|
117
|
+
if (exists === undefined) {
|
|
118
|
+
exists = native_1.native.fontMetric(this[graphics_state_1.graphicsNative], 5, codePoint);
|
|
119
|
+
this.coverage.set(codePoint, exists);
|
|
120
|
+
}
|
|
121
|
+
return exists;
|
|
122
|
+
}
|
|
123
|
+
/** 返回两个 Unicode 码点之间的字距调整量,单位为像素。 */
|
|
124
|
+
getKerning(first, second, characterSize, bold = false) {
|
|
125
|
+
fontUnsigned(first, 0x10ffff);
|
|
126
|
+
fontUnsigned(second, 0x10ffff);
|
|
127
|
+
fontUnsigned(characterSize);
|
|
128
|
+
flag(bold);
|
|
129
|
+
const key = `${first}:${second}:${characterSize}:${+bold}`;
|
|
130
|
+
let value = this.kernings.get(key);
|
|
131
|
+
if (value === undefined) {
|
|
132
|
+
(0, graphics_state_1.flushGraphics)();
|
|
133
|
+
value = native_1.native.fontMetric(this[graphics_state_1.graphicsNative], 6, first, second, characterSize, bold);
|
|
134
|
+
this.kernings.set(key, value);
|
|
135
|
+
}
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
/** 返回指定像素字号的上升度量,单位为像素。 */
|
|
139
|
+
getAscent(size) { return this.metric(0, size); }
|
|
140
|
+
/** 返回指定像素字号的下降度量,单位为像素。 */
|
|
141
|
+
getDescent(size) { return this.metric(1, size); }
|
|
142
|
+
/** 返回指定像素字号的推荐基线间距。 */
|
|
143
|
+
getLineSpacing(size) { return this.metric(2, size); }
|
|
144
|
+
/** 返回下划线相对基线的位置,单位为像素。 */
|
|
145
|
+
getUnderlinePosition(size) { return this.metric(3, size); }
|
|
146
|
+
/** 返回下划线厚度,单位为像素。 */
|
|
147
|
+
getUnderlineThickness(size) { return this.metric(4, size); }
|
|
148
|
+
/** 返回指定像素字号的字形图集只读纹理引用,后续加载字形可能更新其内容。 */
|
|
149
|
+
getTexture(characterSize) {
|
|
150
|
+
fontUnsigned(characterSize);
|
|
151
|
+
let texture = this.textures.get(characterSize);
|
|
152
|
+
if (!texture) {
|
|
153
|
+
(0, graphics_state_1.flushGraphics)();
|
|
154
|
+
texture = (0, texture_1.fontTextureFromMapping)(native_1.native.getFontTexture(this[graphics_state_1.graphicsNative], characterSize), this);
|
|
155
|
+
this.textures.set(characterSize, texture);
|
|
156
|
+
}
|
|
157
|
+
return texture;
|
|
158
|
+
}
|
|
159
|
+
/** 设置字体纹理是否使用平滑过滤。 */
|
|
160
|
+
setSmooth(smooth) {
|
|
161
|
+
flag(smooth);
|
|
162
|
+
if (smooth === this.state.sampling.smooth)
|
|
163
|
+
return;
|
|
164
|
+
(0, graphics_state_1.flushGraphics)();
|
|
165
|
+
native_1.native.setFontSmooth(this[graphics_state_1.graphicsNative], smooth);
|
|
166
|
+
}
|
|
167
|
+
/** 返回字体纹理是否启用平滑过滤。 */
|
|
168
|
+
isSmooth() { return this.state.sampling.smooth; }
|
|
169
|
+
metric(metric, size) {
|
|
170
|
+
fontUnsigned(size);
|
|
171
|
+
let values = this.metrics.get(size);
|
|
172
|
+
if (!values)
|
|
173
|
+
this.metrics.set(size, values = []);
|
|
174
|
+
let value = values[metric];
|
|
175
|
+
if (value === undefined) {
|
|
176
|
+
value = native_1.native.fontMetric(this[graphics_state_1.graphicsNative], metric, size);
|
|
177
|
+
values[metric] = value;
|
|
178
|
+
}
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
glyph(id, size, bold, outline, byId) {
|
|
182
|
+
fontUnsigned(size);
|
|
183
|
+
flag(bold);
|
|
184
|
+
outline = textFloat(outline);
|
|
185
|
+
const key = `${+byId}:${id}:${size}:${+bold}:${outline}`;
|
|
186
|
+
let glyph = this.glyphs.get(key);
|
|
187
|
+
if (!glyph) {
|
|
188
|
+
(0, graphics_state_1.flushGraphics)();
|
|
189
|
+
const value = (0, glyph_1.glyphFromMapping)(native_1.native.getFontGlyph(this[graphics_state_1.graphicsNative], id, size, bold, outline, byId));
|
|
190
|
+
glyph = value;
|
|
191
|
+
this.glyphs.set(key, glyph);
|
|
192
|
+
}
|
|
193
|
+
return glyph;
|
|
194
|
+
}
|
|
195
|
+
open(input) {
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
197
|
+
native_1.native.openFont(input, (error, data) => {
|
|
198
|
+
if (error)
|
|
199
|
+
return reject(error);
|
|
200
|
+
if (!data)
|
|
201
|
+
return resolve(false);
|
|
202
|
+
try {
|
|
203
|
+
(0, graphics_state_1.flushGraphics)();
|
|
204
|
+
this.state = fontViews(native_1.native.commitFont(this[graphics_state_1.graphicsNative], data));
|
|
205
|
+
this[exports.fontRevision]++;
|
|
206
|
+
this.glyphs.clear();
|
|
207
|
+
this.metrics.clear();
|
|
208
|
+
this.kernings.clear();
|
|
209
|
+
this.coverage.clear();
|
|
210
|
+
this.textures.clear();
|
|
211
|
+
resolve(true);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
reject(error);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.Font = Font;
|
|
221
|
+
_a = exports.fontRevision;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GlslValue } from '../internal/glsl-value';
|
|
2
|
+
import { type NativeValueMapping } from '../internal/native';
|
|
3
|
+
import { type ReadonlyValue as R } from '../internal/value-storage';
|
|
4
|
+
import { Transform } from './transform';
|
|
5
|
+
type Kind = 'mat3' | 'mat4';
|
|
6
|
+
type Source<K extends Kind> = ArrayLike<number> | R<Matrix<K>> | R<Transform>;
|
|
7
|
+
/** SFML GLSL matrices are column-major data containers without operators. */
|
|
8
|
+
declare abstract class Matrix<K extends Kind> extends GlslValue<K, Float32Array> {
|
|
9
|
+
protected constructor(length: 9 | 16, source: Source<K>, wrap: (buffer: ArrayBuffer) => NativeValueMapping<K>);
|
|
10
|
+
/** 列主序矩阵数据的可修改共享视图。 */
|
|
11
|
+
get array(): Float32Array;
|
|
12
|
+
/** 复制同长度数组到矩阵的现有存储。 */
|
|
13
|
+
set array(source: ArrayLike<number>);
|
|
14
|
+
}
|
|
15
|
+
/** GLSL mat3,九个列主序 float32 分量。 */
|
|
16
|
+
export declare class Mat3 extends Matrix<'mat3'> {
|
|
17
|
+
/** 复制九个列主序分量、Mat3 或 Transform 中的二维 3×3 矩阵。 */
|
|
18
|
+
constructor(source: ArrayLike<number> | R<Mat3> | R<Transform>);
|
|
19
|
+
}
|
|
20
|
+
/** GLSL mat4,十六个列主序 float32 分量。 */
|
|
21
|
+
export declare class Mat4 extends Matrix<'mat4'> {
|
|
22
|
+
/** 复制十六个列主序分量、Mat4 或 Transform 的 OpenGL 矩阵。 */
|
|
23
|
+
constructor(source: ArrayLike<number> | R<Mat4> | R<Transform>);
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mat4 = exports.Mat3 = void 0;
|
|
4
|
+
const glsl_value_1 = require("../internal/glsl-value");
|
|
5
|
+
const native_1 = require("../internal/native");
|
|
6
|
+
const value_storage_1 = require("../internal/value-storage");
|
|
7
|
+
const transform_1 = require("./transform");
|
|
8
|
+
const transform3Indices = [0, 1, 3, 4, 5, 7, 12, 13, 15];
|
|
9
|
+
function copyArray(target, source) {
|
|
10
|
+
if (source === null || typeof source !== 'object') {
|
|
11
|
+
throw new TypeError('Expected an array of matrix elements');
|
|
12
|
+
}
|
|
13
|
+
if (source.length !== target.length) {
|
|
14
|
+
throw new RangeError(`Expected ${target.length} matrix elements`);
|
|
15
|
+
}
|
|
16
|
+
for (let i = 0; i < source.length; i++) {
|
|
17
|
+
if (typeof source[i] !== 'number') {
|
|
18
|
+
throw new TypeError('Matrix elements must be numbers');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// TypedArray.set preserves float32 NaN payloads and supports self-assignment.
|
|
22
|
+
target.set(source);
|
|
23
|
+
}
|
|
24
|
+
/** SFML GLSL matrices are column-major data containers without operators. */
|
|
25
|
+
class Matrix extends glsl_value_1.GlslValue {
|
|
26
|
+
constructor(length, source, wrap) {
|
|
27
|
+
super(new Float32Array(length), wrap);
|
|
28
|
+
const values = this[glsl_value_1.glslStorage];
|
|
29
|
+
if (source instanceof transform_1.Transform) {
|
|
30
|
+
const data = source[value_storage_1.transformStorage];
|
|
31
|
+
if (length === 16) {
|
|
32
|
+
values.set(data);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Copy the nine SFML entries as bits, including signed zero and NaN.
|
|
36
|
+
const input = new Uint32Array(data.buffer, data.byteOffset, 16);
|
|
37
|
+
const output = new Uint32Array(values.buffer);
|
|
38
|
+
for (let i = 0; i < 9; i++)
|
|
39
|
+
output[i] = input[transform3Indices[i]];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (source instanceof Matrix) {
|
|
43
|
+
copyArray(values, source[glsl_value_1.glslStorage]);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
copyArray(values, source);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** 列主序矩阵数据的可修改共享视图。 */
|
|
50
|
+
get array() { return this[glsl_value_1.glslStorage]; }
|
|
51
|
+
/** 复制同长度数组到矩阵的现有存储。 */
|
|
52
|
+
set array(source) { copyArray(this[glsl_value_1.glslStorage], source); }
|
|
53
|
+
}
|
|
54
|
+
/** GLSL mat3,九个列主序 float32 分量。 */
|
|
55
|
+
class Mat3 extends Matrix {
|
|
56
|
+
/** 复制九个列主序分量、Mat3 或 Transform 中的二维 3×3 矩阵。 */
|
|
57
|
+
constructor(source) {
|
|
58
|
+
super(9, source, buffer => native_1.native.wrapMat3(buffer));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Mat3 = Mat3;
|
|
62
|
+
/** GLSL mat4,十六个列主序 float32 分量。 */
|
|
63
|
+
class Mat4 extends Matrix {
|
|
64
|
+
/** 复制十六个列主序分量、Mat4 或 Transform 的 OpenGL 矩阵。 */
|
|
65
|
+
constructor(source) {
|
|
66
|
+
super(16, source, buffer => native_1.native.wrapMat4(buffer));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Mat4 = Mat4;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GlslValue, BooleanComponents } from '../internal/glsl-value';
|
|
2
|
+
import type { ReadonlyValue as R } from '../internal/value-storage';
|
|
3
|
+
import { Color } from './color';
|
|
4
|
+
export { Vector2f as Vec2, Vector2i as Ivec2 } from '../system/vector2';
|
|
5
|
+
export { Vector3f as Vec3, Vector3i as Ivec3 } from '../system/vector3';
|
|
6
|
+
export { Bvec2, Bvec3 } from './boolean-vector';
|
|
7
|
+
export { Mat3, Mat4 } from './glsl-matrix';
|
|
8
|
+
type Source4 = R<Vec4> | R<Ivec4> | R<Bvec4>;
|
|
9
|
+
type NumericArguments = [] | [x: number, y: number, z: number, w: number] | [source: Source4 | R<Color>];
|
|
10
|
+
/** SFML's four-dimensional GLSL vectors expose data, not vector arithmetic. */
|
|
11
|
+
declare class Vector4<T extends 'i32' | 'f32'> extends GlslValue<'vector4', Int32Array | Float32Array> {
|
|
12
|
+
/** 分量存储类型,i32 或 f32。 */
|
|
13
|
+
private readonly type;
|
|
14
|
+
constructor(type: T, ...args: NumericArguments);
|
|
15
|
+
/** 分量的存储类型:i32 或 f32。 */
|
|
16
|
+
get scalarType(): T;
|
|
17
|
+
/** X 分量。 */
|
|
18
|
+
get x(): number;
|
|
19
|
+
/** 设置 X 分量,按存储类型转换。 */
|
|
20
|
+
set x(value: number);
|
|
21
|
+
/** Y 分量。 */
|
|
22
|
+
get y(): number;
|
|
23
|
+
/** 设置 Y 分量,按存储类型转换。 */
|
|
24
|
+
set y(value: number);
|
|
25
|
+
/** Z 分量。 */
|
|
26
|
+
get z(): number;
|
|
27
|
+
/** 设置 Z 分量,按存储类型转换。 */
|
|
28
|
+
set z(value: number);
|
|
29
|
+
/** W 分量。 */
|
|
30
|
+
get w(): number;
|
|
31
|
+
/** 设置 W 分量,按存储类型转换。 */
|
|
32
|
+
set w(value: number);
|
|
33
|
+
}
|
|
34
|
+
/** GLSL vec4,四个 float32 分量。 */
|
|
35
|
+
export declare class Vec4 extends Vector4<'f32'> {
|
|
36
|
+
/** 创建零向量、指定四个分量或复制向量;从 Color 创建时将 RGBA 归一化到 [0, 1]。 */
|
|
37
|
+
constructor(...args: NumericArguments);
|
|
38
|
+
}
|
|
39
|
+
/** GLSL ivec4,四个有符号 32 位整数分量。 */
|
|
40
|
+
export declare class Ivec4 extends Vector4<'i32'> {
|
|
41
|
+
/** 创建零向量、指定四个分量或复制向量;从 Color 创建时保留 0~255 的 RGBA。 */
|
|
42
|
+
constructor(...args: NumericArguments);
|
|
43
|
+
}
|
|
44
|
+
type BooleanArguments = [] | [x: boolean, y: boolean, z: boolean, w: boolean] | [source: Source4];
|
|
45
|
+
/** GLSL bvec4,四个布尔分量。 */
|
|
46
|
+
export declare class Bvec4 extends BooleanComponents<'vector4'> {
|
|
47
|
+
/** 创建全 false 向量、指定四个分量,或按非零为 true 转换复制向量。 */
|
|
48
|
+
constructor(...args: BooleanArguments);
|
|
49
|
+
/** Z 布尔分量。 */
|
|
50
|
+
get z(): boolean;
|
|
51
|
+
/** 设置 Z 分量。 */
|
|
52
|
+
set z(value: boolean);
|
|
53
|
+
/** W 布尔分量。 */
|
|
54
|
+
get w(): boolean;
|
|
55
|
+
/** 设置 W 分量。 */
|
|
56
|
+
set w(value: boolean);
|
|
57
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bvec4 = exports.Ivec4 = exports.Vec4 = exports.Mat4 = exports.Mat3 = exports.Bvec3 = exports.Bvec2 = exports.Ivec3 = exports.Vec3 = exports.Ivec2 = exports.Vec2 = void 0;
|
|
4
|
+
const glsl_value_1 = require("../internal/glsl-value");
|
|
5
|
+
const native_1 = require("../internal/native");
|
|
6
|
+
const color_1 = require("./color");
|
|
7
|
+
var vector2_1 = require("../system/vector2");
|
|
8
|
+
Object.defineProperty(exports, "Vec2", { enumerable: true, get: function () { return vector2_1.Vector2f; } });
|
|
9
|
+
Object.defineProperty(exports, "Ivec2", { enumerable: true, get: function () { return vector2_1.Vector2i; } });
|
|
10
|
+
var vector3_1 = require("../system/vector3");
|
|
11
|
+
Object.defineProperty(exports, "Vec3", { enumerable: true, get: function () { return vector3_1.Vector3f; } });
|
|
12
|
+
Object.defineProperty(exports, "Ivec3", { enumerable: true, get: function () { return vector3_1.Vector3i; } });
|
|
13
|
+
var boolean_vector_1 = require("./boolean-vector");
|
|
14
|
+
Object.defineProperty(exports, "Bvec2", { enumerable: true, get: function () { return boolean_vector_1.Bvec2; } });
|
|
15
|
+
Object.defineProperty(exports, "Bvec3", { enumerable: true, get: function () { return boolean_vector_1.Bvec3; } });
|
|
16
|
+
var glsl_matrix_1 = require("./glsl-matrix");
|
|
17
|
+
Object.defineProperty(exports, "Mat3", { enumerable: true, get: function () { return glsl_matrix_1.Mat3; } });
|
|
18
|
+
Object.defineProperty(exports, "Mat4", { enumerable: true, get: function () { return glsl_matrix_1.Mat4; } });
|
|
19
|
+
/** SFML's four-dimensional GLSL vectors expose data, not vector arithmetic. */
|
|
20
|
+
class Vector4 extends glsl_value_1.GlslValue {
|
|
21
|
+
constructor(type, ...args) {
|
|
22
|
+
super(type === 'f32' ? new Float32Array(4) : new Int32Array(4), buffer => native_1.native.wrapVector4(type, buffer));
|
|
23
|
+
this.type = type;
|
|
24
|
+
const source = args[0];
|
|
25
|
+
if (source instanceof Vector4 && source.scalarType === type) {
|
|
26
|
+
// Same-scalar copies retain NaN payloads and signed zero verbatim.
|
|
27
|
+
this[glsl_value_1.glslStorage].set(source[glsl_value_1.glslStorage]);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (source instanceof color_1.Color) {
|
|
31
|
+
const divisor = type === 'f32' ? 255 : 1;
|
|
32
|
+
this.x = source.r / divisor;
|
|
33
|
+
this.y = source.g / divisor;
|
|
34
|
+
this.z = source.b / divisor;
|
|
35
|
+
this.w = source.a / divisor;
|
|
36
|
+
// Both vector classes are initialized before a public constructor runs.
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
38
|
+
}
|
|
39
|
+
else if (source instanceof Vector4 || source instanceof Bvec4) {
|
|
40
|
+
this.x = Number(source.x);
|
|
41
|
+
this.y = Number(source.y);
|
|
42
|
+
this.z = Number(source.z);
|
|
43
|
+
this.w = Number(source.w);
|
|
44
|
+
}
|
|
45
|
+
else if (typeof source === 'number' && args.length === 4) {
|
|
46
|
+
this.x = source;
|
|
47
|
+
this.y = args[1];
|
|
48
|
+
this.z = args[2];
|
|
49
|
+
this.w = args[3];
|
|
50
|
+
}
|
|
51
|
+
else if (args.length !== 0) {
|
|
52
|
+
throw new TypeError('Expected four numbers, a Glsl vector or a Color');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** 分量的存储类型:i32 或 f32。 */
|
|
56
|
+
get scalarType() { return this.type; }
|
|
57
|
+
/** X 分量。 */
|
|
58
|
+
get x() { return this[glsl_value_1.glslStorage][0]; }
|
|
59
|
+
/** 设置 X 分量,按存储类型转换。 */
|
|
60
|
+
set x(value) { this[glsl_value_1.glslStorage][0] = value; }
|
|
61
|
+
/** Y 分量。 */
|
|
62
|
+
get y() { return this[glsl_value_1.glslStorage][1]; }
|
|
63
|
+
/** 设置 Y 分量,按存储类型转换。 */
|
|
64
|
+
set y(value) { this[glsl_value_1.glslStorage][1] = value; }
|
|
65
|
+
/** Z 分量。 */
|
|
66
|
+
get z() { return this[glsl_value_1.glslStorage][2]; }
|
|
67
|
+
/** 设置 Z 分量,按存储类型转换。 */
|
|
68
|
+
set z(value) { this[glsl_value_1.glslStorage][2] = value; }
|
|
69
|
+
/** W 分量。 */
|
|
70
|
+
get w() { return this[glsl_value_1.glslStorage][3]; }
|
|
71
|
+
/** 设置 W 分量,按存储类型转换。 */
|
|
72
|
+
set w(value) { this[glsl_value_1.glslStorage][3] = value; }
|
|
73
|
+
}
|
|
74
|
+
/** GLSL vec4,四个 float32 分量。 */
|
|
75
|
+
class Vec4 extends Vector4 {
|
|
76
|
+
/** 创建零向量、指定四个分量或复制向量;从 Color 创建时将 RGBA 归一化到 [0, 1]。 */
|
|
77
|
+
constructor(...args) { super('f32', ...args); }
|
|
78
|
+
}
|
|
79
|
+
exports.Vec4 = Vec4;
|
|
80
|
+
/** GLSL ivec4,四个有符号 32 位整数分量。 */
|
|
81
|
+
class Ivec4 extends Vector4 {
|
|
82
|
+
/** 创建零向量、指定四个分量或复制向量;从 Color 创建时保留 0~255 的 RGBA。 */
|
|
83
|
+
constructor(...args) { super('i32', ...args); }
|
|
84
|
+
}
|
|
85
|
+
exports.Ivec4 = Ivec4;
|
|
86
|
+
/** GLSL bvec4,四个布尔分量。 */
|
|
87
|
+
class Bvec4 extends glsl_value_1.BooleanComponents {
|
|
88
|
+
/** 创建全 false 向量、指定四个分量,或按非零为 true 转换复制向量。 */
|
|
89
|
+
constructor(...args) {
|
|
90
|
+
const source = args[0];
|
|
91
|
+
if (source instanceof Vector4 || source instanceof Bvec4) {
|
|
92
|
+
super([source.x, source.y, source.z, source.w], buffer => native_1.native.wrapVector4('bool', buffer));
|
|
93
|
+
}
|
|
94
|
+
else if (args.length === 0 ||
|
|
95
|
+
(args.length === 4 && args.every(value => typeof value === 'boolean'))) {
|
|
96
|
+
super(args.length === 0 ? [false, false, false, false]
|
|
97
|
+
: args, buffer => native_1.native.wrapVector4('bool', buffer));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new TypeError('Expected four booleans or a four-dimensional vector');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Z 布尔分量。 */
|
|
104
|
+
get z() { return this[glsl_value_1.glslStorage][2] !== 0; }
|
|
105
|
+
/** 设置 Z 分量。 */
|
|
106
|
+
set z(value) { this[glsl_value_1.glslStorage][2] = value ? 1 : 0; }
|
|
107
|
+
/** W 布尔分量。 */
|
|
108
|
+
get w() { return this[glsl_value_1.glslStorage][3] !== 0; }
|
|
109
|
+
/** 设置 W 分量。 */
|
|
110
|
+
set w(value) { this[glsl_value_1.glslStorage][3] = value ? 1 : 0; }
|
|
111
|
+
}
|
|
112
|
+
exports.Bvec4 = Bvec4;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type NativeValueHandle, type NativeValueMapping } from '../internal/native';
|
|
2
|
+
import { LazyValue } from '../internal/lazy-value';
|
|
3
|
+
import { glyphStorage, glyphNative, mutableValue, type ReadonlyValue as R } from '../internal/value-storage';
|
|
4
|
+
import { FloatRect, IntRect } from './rect';
|
|
5
|
+
export declare let glyphFromMapping: (mapping: NativeValueMapping<'glyph'>) => Glyph;
|
|
6
|
+
export declare let glyphFromState: (state: LazyValue<'glyph', Uint8Array>) => Glyph;
|
|
7
|
+
/** sf::Glyph and its rectangle members share a 44-byte allocation. */
|
|
8
|
+
export declare class Glyph {
|
|
9
|
+
readonly [mutableValue] = true;
|
|
10
|
+
/** 原生字形分配的惰性值,共享 44 字节。 */
|
|
11
|
+
private readonly state;
|
|
12
|
+
/** state 缓冲区的 Float32 视图。 */
|
|
13
|
+
private readonly floats;
|
|
14
|
+
/** state 缓冲区的 Int32 视图。 */
|
|
15
|
+
private readonly integers;
|
|
16
|
+
/** bounds 属性的延迟 FloatRect 视图缓存。 */
|
|
17
|
+
private boundsView?;
|
|
18
|
+
/** textureRect 属性的延迟 IntRect 视图缓存。 */
|
|
19
|
+
private textureView?;
|
|
20
|
+
/** 创建数值全为零的字形,或复制 source 的所有字形度量。 */
|
|
21
|
+
constructor(source?: R<Glyph>);
|
|
22
|
+
get [glyphStorage](): Uint8Array;
|
|
23
|
+
get [glyphNative](): NativeValueHandle<'glyph'>;
|
|
24
|
+
/** 绘制后笔位置的水平前进量,单位为像素。 */
|
|
25
|
+
get advance(): number;
|
|
26
|
+
/** 设置水平前进量,单位为像素。 */
|
|
27
|
+
set advance(value: number);
|
|
28
|
+
/** 自动微调前后左侧边距的差,单位为 1/64 像素。 */
|
|
29
|
+
get lsbDelta(): number;
|
|
30
|
+
/** 设置左侧边距微调差。 */
|
|
31
|
+
set lsbDelta(value: number);
|
|
32
|
+
/** 自动微调前后右侧边距的差,单位为 1/64 像素。 */
|
|
33
|
+
get rsbDelta(): number;
|
|
34
|
+
/** 设置右侧边距微调差。 */
|
|
35
|
+
set rsbDelta(value: number);
|
|
36
|
+
/** 相对于基线和笔位置的像素包围框,共享可修改视图。 */
|
|
37
|
+
get bounds(): FloatRect;
|
|
38
|
+
/** 复制字形包围框。 */
|
|
39
|
+
set bounds(value: R<FloatRect>);
|
|
40
|
+
/** 字形在字体纹理中的像素矩形,共享可修改视图。 */
|
|
41
|
+
get textureRect(): IntRect;
|
|
42
|
+
/** 复制字体纹理中的字形矩形。 */
|
|
43
|
+
set textureRect(value: R<IntRect>);
|
|
44
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Glyph = exports.glyphFromState = exports.glyphFromMapping = void 0;
|
|
5
|
+
const native_1 = require("../internal/native");
|
|
6
|
+
const lazy_value_1 = require("../internal/lazy-value");
|
|
7
|
+
const value_storage_1 = require("../internal/value-storage");
|
|
8
|
+
const rect_1 = require("./rect");
|
|
9
|
+
/** sf::Glyph and its rectangle members share a 44-byte allocation. */
|
|
10
|
+
class Glyph {
|
|
11
|
+
/** 创建数值全为零的字形,或复制 source 的所有字形度量。 */
|
|
12
|
+
constructor(source) {
|
|
13
|
+
this[_a] = true;
|
|
14
|
+
this.state = new lazy_value_1.LazyValue(new Uint8Array(44), buffer => native_1.native.wrapGlyph(buffer));
|
|
15
|
+
this.floats = new Float32Array(this.state.values.buffer);
|
|
16
|
+
this.integers = new Int32Array(this.state.values.buffer);
|
|
17
|
+
if (source !== undefined) {
|
|
18
|
+
if (!(source instanceof Glyph))
|
|
19
|
+
throw new TypeError('Expected a Glyph');
|
|
20
|
+
this.state.values.set(source[value_storage_1.glyphStorage]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
get [(_a = value_storage_1.mutableValue, value_storage_1.glyphStorage)]() { return this.state.values; }
|
|
24
|
+
get [value_storage_1.glyphNative]() {
|
|
25
|
+
return (0, lazy_value_1.nativeValue)(this, value_storage_1.glyphNative, this.state);
|
|
26
|
+
}
|
|
27
|
+
/** 绘制后笔位置的水平前进量,单位为像素。 */
|
|
28
|
+
get advance() { return this.floats[0]; }
|
|
29
|
+
/** 设置水平前进量,单位为像素。 */
|
|
30
|
+
set advance(value) { this.floats[0] = value; }
|
|
31
|
+
/** 自动微调前后左侧边距的差,单位为 1/64 像素。 */
|
|
32
|
+
get lsbDelta() { return this.integers[1]; }
|
|
33
|
+
/** 设置左侧边距微调差。 */
|
|
34
|
+
set lsbDelta(value) { this.integers[1] = value; }
|
|
35
|
+
/** 自动微调前后右侧边距的差,单位为 1/64 像素。 */
|
|
36
|
+
get rsbDelta() { return this.integers[2]; }
|
|
37
|
+
/** 设置右侧边距微调差。 */
|
|
38
|
+
set rsbDelta(value) { this.integers[2] = value; }
|
|
39
|
+
/** 相对于基线和笔位置的像素包围框,共享可修改视图。 */
|
|
40
|
+
get bounds() {
|
|
41
|
+
this.boundsView ?? (this.boundsView = (0, rect_1.floatRectFromState)((0, lazy_value_1.memberValue)(this.state, this.floats.subarray(3, 7), handle => native_1.native.glyphMember(handle, 0))));
|
|
42
|
+
return this.boundsView;
|
|
43
|
+
}
|
|
44
|
+
/** 复制字形包围框。 */
|
|
45
|
+
set bounds(value) {
|
|
46
|
+
if (!(value instanceof rect_1.FloatRect))
|
|
47
|
+
throw new TypeError('Expected a FloatRect');
|
|
48
|
+
this.floats.set(value[value_storage_1.rectStorage], 3);
|
|
49
|
+
}
|
|
50
|
+
/** 字形在字体纹理中的像素矩形,共享可修改视图。 */
|
|
51
|
+
get textureRect() {
|
|
52
|
+
this.textureView ?? (this.textureView = (0, rect_1.intRectFromState)((0, lazy_value_1.memberValue)(this.state, this.integers.subarray(7, 11), handle => native_1.native.glyphMember(handle, 1))));
|
|
53
|
+
return this.textureView;
|
|
54
|
+
}
|
|
55
|
+
/** 复制字体纹理中的字形矩形。 */
|
|
56
|
+
set textureRect(value) {
|
|
57
|
+
if (!(value instanceof rect_1.IntRect))
|
|
58
|
+
throw new TypeError('Expected an IntRect');
|
|
59
|
+
this.integers.set(value[value_storage_1.rectStorage], 7);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.Glyph = Glyph;
|
|
63
|
+
(() => {
|
|
64
|
+
exports.glyphFromState = state => {
|
|
65
|
+
const { buffer, byteOffset } = state.values;
|
|
66
|
+
return Object.assign(Object.create(Glyph.prototype), {
|
|
67
|
+
[value_storage_1.mutableValue]: true,
|
|
68
|
+
state,
|
|
69
|
+
floats: new Float32Array(buffer, byteOffset, 11),
|
|
70
|
+
integers: new Int32Array(buffer, byteOffset, 11),
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
exports.glyphFromMapping = mapping => (0, exports.glyphFromState)(new lazy_value_1.LazyValue(new Uint8Array(mapping.buffer), () => mapping));
|
|
74
|
+
})();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type NativeGraphicsHandle, type NativeImageResource } from '../internal/native';
|
|
2
|
+
import { graphicsNative } from '../internal/graphics-state';
|
|
3
|
+
import type { InputStream } from '../system/input-stream';
|
|
4
|
+
import { type ReadonlyValue } from '../internal/value-storage';
|
|
5
|
+
import { Vector2u } from '../system/vector2';
|
|
6
|
+
import { Color } from './color';
|
|
7
|
+
import { IntRect } from './rect';
|
|
8
|
+
/** Compile-time const view. Runtime storage is the same native Uint8Array. */
|
|
9
|
+
export type ReadonlyPixels = Readonly<Pick<Uint8Array, number | 'length' | 'byteLength' | 'byteOffset' | typeof Symbol.iterator | 'slice' | 'entries' | 'keys' | 'values'>>;
|
|
10
|
+
/** Internal ownership transfer for native image producers. */
|
|
11
|
+
export declare let imageFromMapping: (mapping: NativeImageResource) => Image;
|
|
12
|
+
/** Native-owned RGBA8 pixels with asynchronous file and codec operations. */
|
|
13
|
+
export declare class Image {
|
|
14
|
+
readonly [graphicsNative]: NativeGraphicsHandle<'image'>;
|
|
15
|
+
/** 原生图像元信息和 RGBA 像素视图。 */
|
|
16
|
+
private state;
|
|
17
|
+
/** 创建没有像素的空图像。 */
|
|
18
|
+
constructor();
|
|
19
|
+
/** 深复制图像的 RGBA 像素。 */
|
|
20
|
+
constructor(source: Image);
|
|
21
|
+
/** 创建指定像素尺寸的图像;使用颜色填充或复制 RGBA8 字节,默认黑色。 */
|
|
22
|
+
constructor(size: Readonly<Vector2u>, colorOrPixels?: ReadonlyValue<Color> | Uint8Array);
|
|
23
|
+
/** Writable extension; old views retain old images after resize or load. */
|
|
24
|
+
get pixels(): Uint8Array;
|
|
25
|
+
/** 返回图像像素宽度和高度的副本。 */
|
|
26
|
+
getSize(): Vector2u;
|
|
27
|
+
/** Empty images have no pixel pointer. Constness is enforced by TypeScript. */
|
|
28
|
+
getPixelsPtr(): ReadonlyPixels | undefined;
|
|
29
|
+
/** 重建像素存储并填充颜色或复制 RGBA8 数据;之前的 pixels 视图保留旧存储。 */
|
|
30
|
+
resize(size: Readonly<Vector2u>, colorOrPixels?: ReadonlyValue<Color> | Uint8Array): void;
|
|
31
|
+
/** 返回指定像素的颜色副本;坐标越界抛出 RangeError。 */
|
|
32
|
+
getPixel(coords: Readonly<Vector2u>): Color;
|
|
33
|
+
/** 复制颜色到指定像素;坐标越界抛出 RangeError。 */
|
|
34
|
+
setPixel(coords: Readonly<Vector2u>, color: ReadonlyValue<Color>): void;
|
|
35
|
+
/** 将与 color 完全匹配的像素透明度设为 alpha(默认 0),保留 RGB。 */
|
|
36
|
+
createMaskFromColor(color: ReadonlyValue<Color>, alpha?: number): void;
|
|
37
|
+
/** 复制 sourceRect(默认整个源图)到 dest;applyAlpha 启用透明度混合,返回是否成功。 */
|
|
38
|
+
copy(source: Image, dest: Readonly<Vector2u>, sourceRect?: ReadonlyValue<IntRect>, applyAlpha?: boolean): boolean;
|
|
39
|
+
/** 原地左右翻转像素。 */
|
|
40
|
+
flipHorizontally(): void;
|
|
41
|
+
/** 原地上下翻转像素。 */
|
|
42
|
+
flipVertically(): void;
|
|
43
|
+
/** 异步读取并解码图像文件,成功后替换像素存储,返回是否成功。 */
|
|
44
|
+
loadFromFile(filename: string): Promise<boolean>;
|
|
45
|
+
/** 异步解码 PNG/JPEG 等编码图像字节,返回是否成功。 */
|
|
46
|
+
loadFromMemory(data: Uint8Array): Promise<boolean>;
|
|
47
|
+
/** 从可寻址输入流异步解码图像;流异常会拒绝 Promise。 */
|
|
48
|
+
loadFromStream(stream: InputStream): Promise<boolean>;
|
|
49
|
+
/** 按文件扩展名异步编码并保存图像,返回是否成功。 */
|
|
50
|
+
saveToFile(filename: string): Promise<boolean>;
|
|
51
|
+
/** 异步编码为 format(如 png)指定的格式,返回字节;编码失败返回 undefined。 */
|
|
52
|
+
saveToMemory(format: string): Promise<Uint8Array | undefined>;
|
|
53
|
+
/** 通用异步加载入口,用回调驱动原生解码。 */
|
|
54
|
+
private load;
|
|
55
|
+
/** 将像素坐标转换为 state.pixels 中的字节偏移。 */
|
|
56
|
+
private offset;
|
|
57
|
+
}
|