1681-engine 0.0.0-stage → 0.5.8
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/CHANGELOG.md +304 -0
- package/LICENSE +21 -0
- package/README.md +164 -2
- package/dist/1681-engine.js +417 -0
- package/dist/1681-engine.js.map +1 -0
- package/dist/ambient/ColorGrade.js +41 -0
- package/dist/ambient/ColorGrade.js.map +1 -0
- package/dist/ambient/DayClock.js +57 -0
- package/dist/ambient/DayClock.js.map +1 -0
- package/dist/ambient/WeatherLayer.js +91 -0
- package/dist/ambient/WeatherLayer.js.map +1 -0
- package/dist/ambient/grade.js +13 -0
- package/dist/ambient/grade.js.map +1 -0
- package/dist/ambient/weather.js +52 -0
- package/dist/ambient/weather.js.map +1 -0
- package/dist/anim/AnimStateMachine.js +164 -0
- package/dist/anim/AnimStateMachine.js.map +1 -0
- package/dist/anim/Animator.js +67 -0
- package/dist/anim/Animator.js.map +1 -0
- package/dist/anim/animStateCompile.js +113 -0
- package/dist/anim/animStateCompile.js.map +1 -0
- package/dist/anim/animStateSystem.js +17 -0
- package/dist/anim/animStateSystem.js.map +1 -0
- package/dist/anim/animationSystem.js +15 -0
- package/dist/anim/animationSystem.js.map +1 -0
- package/dist/anim/asepriteSlices.js +22 -0
- package/dist/anim/asepriteSlices.js.map +1 -0
- package/dist/anim/asepriteTags.js +35 -0
- package/dist/anim/asepriteTags.js.map +1 -0
- package/dist/anim/parseAseprite.js +83 -0
- package/dist/anim/parseAseprite.js.map +1 -0
- package/dist/assets/AssetLoader.js +104 -0
- package/dist/assets/AssetLoader.js.map +1 -0
- package/dist/assets/loadAseprite.js +50 -0
- package/dist/assets/loadAseprite.js.map +1 -0
- package/dist/assets/takeCleanerWorker-DTcI_Jqr.js +31 -0
- package/dist/assets/takeCleanerWorker-DTcI_Jqr.js.map +1 -0
- package/dist/audio/Footsteps.js +26 -0
- package/dist/audio/Footsteps.js.map +1 -0
- package/dist/audio/MusicPlayer.js +78 -0
- package/dist/audio/MusicPlayer.js.map +1 -0
- package/dist/audio/SoundEngine.js +119 -0
- package/dist/audio/SoundEngine.js.map +1 -0
- package/dist/audio/cleanTake.js +30 -0
- package/dist/audio/cleanTake.js.map +1 -0
- package/dist/audio/music/ElementVoice.js +35 -0
- package/dist/audio/music/ElementVoice.js.map +1 -0
- package/dist/audio/music/GraphVoice.js +39 -0
- package/dist/audio/music/GraphVoice.js.map +1 -0
- package/dist/audio/music/MusicChannel.js +58 -0
- package/dist/audio/music/MusicChannel.js.map +1 -0
- package/dist/audio/music/musicVoice.js +13 -0
- package/dist/audio/music/musicVoice.js.map +1 -0
- package/dist/audio/sampleBank.js +82 -0
- package/dist/audio/sampleBank.js.map +1 -0
- package/dist/audio/soundTable.js +9 -0
- package/dist/audio/soundTable.js.map +1 -0
- package/dist/audio/synth.js +36 -0
- package/dist/audio/synth.js.map +1 -0
- package/dist/core/BitmapLabel.js +49 -0
- package/dist/core/BitmapLabel.js.map +1 -0
- package/dist/core/Camera.js +150 -0
- package/dist/core/Camera.js.map +1 -0
- package/dist/core/Clock.js +30 -0
- package/dist/core/Clock.js.map +1 -0
- package/dist/core/Graphics.js +69 -0
- package/dist/core/Graphics.js.map +1 -0
- package/dist/core/Group.js +29 -0
- package/dist/core/Group.js.map +1 -0
- package/dist/core/Image.js +51 -0
- package/dist/core/Image.js.map +1 -0
- package/dist/core/ObjectFactory.js +55 -0
- package/dist/core/ObjectFactory.js.map +1 -0
- package/dist/core/Pointer.js +58 -0
- package/dist/core/Pointer.js.map +1 -0
- package/dist/core/Rectangle.js +51 -0
- package/dist/core/Rectangle.js.map +1 -0
- package/dist/core/Stage.js +86 -0
- package/dist/core/Stage.js.map +1 -0
- package/dist/core/Text.js +22 -0
- package/dist/core/Text.js.map +1 -0
- package/dist/core/TextureRegistry.js +111 -0
- package/dist/core/TextureRegistry.js.map +1 -0
- package/dist/core/Timeline.js +211 -0
- package/dist/core/Timeline.js.map +1 -0
- package/dist/core/TimelineBuilder.js +73 -0
- package/dist/core/TimelineBuilder.js.map +1 -0
- package/dist/core/TimelineChild.js +84 -0
- package/dist/core/TimelineChild.js.map +1 -0
- package/dist/core/Tweener.js +136 -0
- package/dist/core/Tweener.js.map +1 -0
- package/dist/core/atlas.js +38 -0
- package/dist/core/atlas.js.map +1 -0
- package/dist/core/atlasPlan.js +22 -0
- package/dist/core/atlasPlan.js.map +1 -0
- package/dist/core/eases.js +21 -0
- package/dist/core/eases.js.map +1 -0
- package/dist/core/gameObject.js +115 -0
- package/dist/core/gameObject.js.map +1 -0
- package/dist/core/pixiPatches.js +18 -0
- package/dist/core/pixiPatches.js.map +1 -0
- package/dist/core/timelinePlace.js +24 -0
- package/dist/core/timelinePlace.js.map +1 -0
- package/dist/core/tweenProps.js +12 -0
- package/dist/core/tweenProps.js.map +1 -0
- package/dist/debug/DebugOverlay.js +94 -0
- package/dist/debug/DebugOverlay.js.map +1 -0
- package/dist/debug/DrawCallCounter.js +41 -0
- package/dist/debug/DrawCallCounter.js.map +1 -0
- package/dist/debug/ErrorLog.js +22 -0
- package/dist/debug/ErrorLog.js.map +1 -0
- package/dist/debug/FrameStats.js +42 -0
- package/dist/debug/FrameStats.js.map +1 -0
- package/dist/debug/inspectWorld.js +29 -0
- package/dist/debug/inspectWorld.js.map +1 -0
- package/dist/diagnostics/ErrorDeduper.js +27 -0
- package/dist/diagnostics/ErrorDeduper.js.map +1 -0
- package/dist/diagnostics/FrameSampler.js +42 -0
- package/dist/diagnostics/FrameSampler.js.map +1 -0
- package/dist/diagnostics/bootWatch.js +21 -0
- package/dist/diagnostics/bootWatch.js.map +1 -0
- package/dist/diagnostics/captureErrors.js +27 -0
- package/dist/diagnostics/captureErrors.js.map +1 -0
- package/dist/diagnostics/contextLoss.js +25 -0
- package/dist/diagnostics/contextLoss.js.map +1 -0
- package/dist/diagnostics/frameStats.js +31 -0
- package/dist/diagnostics/frameStats.js.map +1 -0
- package/dist/diagnostics/gpuInfo.js +22 -0
- package/dist/diagnostics/gpuInfo.js.map +1 -0
- package/dist/diagnostics/renderGuard.js +24 -0
- package/dist/diagnostics/renderGuard.js.map +1 -0
- package/dist/ecs/SparseSet.js +55 -0
- package/dist/ecs/SparseSet.js.map +1 -0
- package/dist/ecs/World.js +307 -0
- package/dist/ecs/World.js.map +1 -0
- package/dist/ecs/fields.js +26 -0
- package/dist/ecs/fields.js.map +1 -0
- package/dist/engine/Engine.js +82 -0
- package/dist/engine/Engine.js.map +1 -0
- package/dist/engine/FixedLoop.js +37 -0
- package/dist/engine/FixedLoop.js.map +1 -0
- package/dist/engine/Scene.js +79 -0
- package/dist/engine/Scene.js.map +1 -0
- package/dist/engine/SceneManager.js +73 -0
- package/dist/engine/SceneManager.js.map +1 -0
- package/dist/events/EventBus.js +42 -0
- package/dist/events/EventBus.js.map +1 -0
- package/dist/fx/FloatingText.js +72 -0
- package/dist/fx/FloatingText.js.map +1 -0
- package/dist/fx/hitStop.js +28 -0
- package/dist/fx/hitStop.js.map +1 -0
- package/dist/fx/viewCull.js +10 -0
- package/dist/fx/viewCull.js.map +1 -0
- package/dist/i18n/Translator.js +72 -0
- package/dist/i18n/Translator.js.map +1 -0
- package/dist/i18n/extractStrings.js +58 -0
- package/dist/i18n/extractStrings.js.map +1 -0
- package/dist/i18n/formatMessage.js +19 -0
- package/dist/i18n/formatMessage.js.map +1 -0
- package/dist/input/Actions.js +131 -0
- package/dist/input/Actions.js.map +1 -0
- package/dist/input/AimGesture.js +75 -0
- package/dist/input/AimGesture.js.map +1 -0
- package/dist/input/Keyboard.js +54 -0
- package/dist/input/Keyboard.js.map +1 -0
- package/dist/input/Keymap.js +171 -0
- package/dist/input/Keymap.js.map +1 -0
- package/dist/input/TargetLock.js +73 -0
- package/dist/input/TargetLock.js.map +1 -0
- package/dist/input/aimAxis.js +8 -0
- package/dist/input/aimAxis.js.map +1 -0
- package/dist/input/keyChord.js +29 -0
- package/dist/input/keyChord.js.map +1 -0
- package/dist/input/longPress.js +32 -0
- package/dist/input/longPress.js.map +1 -0
- package/dist/input/stickAxis.js +23 -0
- package/dist/input/stickAxis.js.map +1 -0
- package/dist/input/touchDetect.js +7 -0
- package/dist/input/touchDetect.js.map +1 -0
- package/dist/light/LightLayer.js +84 -0
- package/dist/light/LightLayer.js.map +1 -0
- package/dist/nav/MinHeap.js +39 -0
- package/dist/nav/MinHeap.js.map +1 -0
- package/dist/nav/findPath.js +78 -0
- package/dist/nav/findPath.js.map +1 -0
- package/dist/nav/navGrid.js +36 -0
- package/dist/nav/navGrid.js.map +1 -0
- package/dist/nav/nearestOpen.js +19 -0
- package/dist/nav/nearestOpen.js.map +1 -0
- package/dist/nav/straightenPath.js +51 -0
- package/dist/nav/straightenPath.js.map +1 -0
- package/dist/net/Connection.js +84 -0
- package/dist/net/Connection.js.map +1 -0
- package/dist/net/InterpolationBuffer.js +57 -0
- package/dist/net/InterpolationBuffer.js.map +1 -0
- package/dist/net/PredictedMover.js +61 -0
- package/dist/net/PredictedMover.js.map +1 -0
- package/dist/net/Room.js +92 -0
- package/dist/net/Room.js.map +1 -0
- package/dist/net/RoomHost.js +101 -0
- package/dist/net/RoomHost.js.map +1 -0
- package/dist/net/cadence.js +22 -0
- package/dist/net/cadence.js.map +1 -0
- package/dist/net/constants.js +11 -0
- package/dist/net/constants.js.map +1 -0
- package/dist/net/lobby/LobbyClient.js +124 -0
- package/dist/net/lobby/LobbyClient.js.map +1 -0
- package/dist/net/lobby/LobbyHost.js +366 -0
- package/dist/net/lobby/LobbyHost.js.map +1 -0
- package/dist/net/lobby/LobbyRooms.js +66 -0
- package/dist/net/lobby/LobbyRooms.js.map +1 -0
- package/dist/net/lobby/Matchmaker.js +106 -0
- package/dist/net/lobby/Matchmaker.js.map +1 -0
- package/dist/net/movement.js +83 -0
- package/dist/net/movement.js.map +1 -0
- package/dist/net/protocol.js +11 -0
- package/dist/net/protocol.js.map +1 -0
- package/dist/net/serverClock.js +22 -0
- package/dist/net/serverClock.js.map +1 -0
- package/dist/net/snapshotCodec.js +92 -0
- package/dist/net/snapshotCodec.js.map +1 -0
- package/dist/parallax/Parallax.js +32 -0
- package/dist/parallax/Parallax.js.map +1 -0
- package/dist/parallax/ParallaxLayer.js +70 -0
- package/dist/parallax/ParallaxLayer.js.map +1 -0
- package/dist/parallax/parallaxMath.js +27 -0
- package/dist/parallax/parallaxMath.js.map +1 -0
- package/dist/particles/Emitter.js +108 -0
- package/dist/particles/Emitter.js.map +1 -0
- package/dist/particles/ParticleBudget.js +32 -0
- package/dist/particles/ParticleBudget.js.map +1 -0
- package/dist/particles/ParticleSim.js +60 -0
- package/dist/particles/ParticleSim.js.map +1 -0
- package/dist/particles/particleCurves.js +48 -0
- package/dist/particles/particleCurves.js.map +1 -0
- package/dist/particles/particleSampling.js +30 -0
- package/dist/particles/particleSampling.js.map +1 -0
- package/dist/physics/Body.js +202 -0
- package/dist/physics/Body.js.map +1 -0
- package/dist/physics/BroadPhase.js +56 -0
- package/dist/physics/BroadPhase.js.map +1 -0
- package/dist/physics/Contact.js +76 -0
- package/dist/physics/Contact.js.map +1 -0
- package/dist/physics/ContactSolver.js +70 -0
- package/dist/physics/ContactSolver.js.map +1 -0
- package/dist/physics/PhysicsWorld.js +221 -0
- package/dist/physics/PhysicsWorld.js.map +1 -0
- package/dist/physics/SpatialHash.js +39 -0
- package/dist/physics/SpatialHash.js.map +1 -0
- package/dist/physics/collide.js +76 -0
- package/dist/physics/collide.js.map +1 -0
- package/dist/physics/collidePolygon.js +94 -0
- package/dist/physics/collidePolygon.js.map +1 -0
- package/dist/physics/contactReport.js +14 -0
- package/dist/physics/contactReport.js.map +1 -0
- package/dist/physics/drawColliders.js +31 -0
- package/dist/physics/drawColliders.js.map +1 -0
- package/dist/physics/physicsSystem.js +8 -0
- package/dist/physics/physicsSystem.js.map +1 -0
- package/dist/physics/polygon.js +80 -0
- package/dist/physics/polygon.js.map +1 -0
- package/dist/physics/raycast.js +62 -0
- package/dist/physics/raycast.js.map +1 -0
- package/dist/physics/syncToBody.js +19 -0
- package/dist/physics/syncToBody.js.map +1 -0
- package/dist/physics/tileBodies.js +59 -0
- package/dist/physics/tileBodies.js.map +1 -0
- package/dist/physics/types.js +8 -0
- package/dist/physics/types.js.map +1 -0
- package/dist/pixel/Darkness.js +166 -0
- package/dist/pixel/Darkness.js.map +1 -0
- package/dist/pixel/DitherVignette.js +57 -0
- package/dist/pixel/DitherVignette.js.map +1 -0
- package/dist/pixel/Evaporation.js +85 -0
- package/dist/pixel/Evaporation.js.map +1 -0
- package/dist/pixel/NightShade.js +34 -0
- package/dist/pixel/NightShade.js.map +1 -0
- package/dist/pixel/PixelLayer.js +211 -0
- package/dist/pixel/PixelLayer.js.map +1 -0
- package/dist/pixel/SwayProp.js +75 -0
- package/dist/pixel/SwayProp.js.map +1 -0
- package/dist/pixel/lights.js +44 -0
- package/dist/pixel/lights.js.map +1 -0
- package/dist/pixel/nineSlice.js +62 -0
- package/dist/pixel/nineSlice.js.map +1 -0
- package/dist/pixel/paintLayer.js +36 -0
- package/dist/pixel/paintLayer.js.map +1 -0
- package/dist/pixel/palette.js +57 -0
- package/dist/pixel/palette.js.map +1 -0
- package/dist/pixel/pixel.js +278 -0
- package/dist/pixel/pixel.js.map +1 -0
- package/dist/pixel/pixelPaint.js +194 -0
- package/dist/pixel/pixelPaint.js.map +1 -0
- package/dist/pixel/pixelTone.js +164 -0
- package/dist/pixel/pixelTone.js.map +1 -0
- package/dist/pixel/propKit.js +41 -0
- package/dist/pixel/propKit.js.map +1 -0
- package/dist/pixel/ramp.js +102 -0
- package/dist/pixel/ramp.js.map +1 -0
- package/dist/pixel/selout.js +35 -0
- package/dist/pixel/selout.js.map +1 -0
- package/dist/pixel/spritePixels.js +59 -0
- package/dist/pixel/spritePixels.js.map +1 -0
- package/dist/pixel/swayRig.js +87 -0
- package/dist/pixel/swayRig.js.map +1 -0
- package/dist/pixel/vignetteMask.js +24 -0
- package/dist/pixel/vignetteMask.js.map +1 -0
- package/dist/pixel/weatherArt.js +61 -0
- package/dist/pixel/weatherArt.js.map +1 -0
- package/dist/pixel.js +90 -0
- package/dist/pixel.js.map +1 -0
- package/dist/platform/touch.js +33 -0
- package/dist/platform/touch.js.map +1 -0
- package/dist/postfx/BloomFilter.js +65 -0
- package/dist/postfx/BloomFilter.js.map +1 -0
- package/dist/postfx/ChromaticAberrationFilter.js +25 -0
- package/dist/postfx/ChromaticAberrationFilter.js.map +1 -0
- package/dist/postfx/ColorAdjustFilter.js +76 -0
- package/dist/postfx/ColorAdjustFilter.js.map +1 -0
- package/dist/postfx/CrtFilter.js +42 -0
- package/dist/postfx/CrtFilter.js.map +1 -0
- package/dist/postfx/PixelateFilter.js +27 -0
- package/dist/postfx/PixelateFilter.js.map +1 -0
- package/dist/postfx/PostFx.js +123 -0
- package/dist/postfx/PostFx.js.map +1 -0
- package/dist/postfx/ShockwaveFilter.js +49 -0
- package/dist/postfx/ShockwaveFilter.js.map +1 -0
- package/dist/postfx/VignetteFilter.js +37 -0
- package/dist/postfx/VignetteFilter.js.map +1 -0
- package/dist/postfx/fxAnimator.js +38 -0
- package/dist/postfx/fxAnimator.js.map +1 -0
- package/dist/postfx/fxShader.js +128 -0
- package/dist/postfx/fxShader.js.map +1 -0
- package/dist/postfx.js +26 -0
- package/dist/postfx.js.map +1 -0
- package/dist/react/ChoiceDialog.js +51 -0
- package/dist/react/ChoiceDialog.js.map +1 -0
- package/dist/react/ConfirmDialog.js +53 -0
- package/dist/react/ConfirmDialog.js.map +1 -0
- package/dist/react/Glyph.js +63 -0
- package/dist/react/Glyph.js.map +1 -0
- package/dist/react/Modal.js +38 -0
- package/dist/react/Modal.js.map +1 -0
- package/dist/react/Panel.js +24 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/PixelImage.js +24 -0
- package/dist/react/PixelImage.js.map +1 -0
- package/dist/react/Select.js +99 -0
- package/dist/react/Select.js.map +1 -0
- package/dist/react/Slider.js +62 -0
- package/dist/react/Slider.js.map +1 -0
- package/dist/react/SplitPane.js +24 -0
- package/dist/react/SplitPane.js.map +1 -0
- package/dist/react/TabStrip.js +32 -0
- package/dist/react/TabStrip.js.map +1 -0
- package/dist/react/TitleTips.js +42 -0
- package/dist/react/TitleTips.js.map +1 -0
- package/dist/react/Tooltip.js +28 -0
- package/dist/react/Tooltip.js.map +1 -0
- package/dist/react/UiProvider.js +50 -0
- package/dist/react/UiProvider.js.map +1 -0
- package/dist/react/baseCss.js +222 -0
- package/dist/react/baseCss.js.map +1 -0
- package/dist/react/choiceStore.js +23 -0
- package/dist/react/choiceStore.js.map +1 -0
- package/dist/react/classNames.js +19 -0
- package/dist/react/classNames.js.map +1 -0
- package/dist/react/confirmStore.js +30 -0
- package/dist/react/confirmStore.js.map +1 -0
- package/dist/react/labels.js +18 -0
- package/dist/react/labels.js.map +1 -0
- package/dist/react/placement.js +49 -0
- package/dist/react/placement.js.map +1 -0
- package/dist/react/useFillSheet.js +23 -0
- package/dist/react/useFillSheet.js.map +1 -0
- package/dist/react/useFitToViewport.js +29 -0
- package/dist/react/useFitToViewport.js.map +1 -0
- package/dist/react/usePicked.js +13 -0
- package/dist/react/usePicked.js.map +1 -0
- package/dist/react/useStore.js +9 -0
- package/dist/react/useStore.js.map +1 -0
- package/dist/react/useViewport.js +17 -0
- package/dist/react/useViewport.js.map +1 -0
- package/dist/react.js +78 -0
- package/dist/react.js.map +1 -0
- package/dist/rig/PosePlayer.js +92 -0
- package/dist/rig/PosePlayer.js.map +1 -0
- package/dist/rig/RigView.js +125 -0
- package/dist/rig/RigView.js.map +1 -0
- package/dist/rig/Skeleton.js +31 -0
- package/dist/rig/Skeleton.js.map +1 -0
- package/dist/rig/humanoid.js +6 -0
- package/dist/rig/humanoid.js.map +1 -0
- package/dist/rig/humanoid.json.js +30 -0
- package/dist/rig/humanoid.json.js.map +1 -0
- package/dist/rig/humanoidPoses.js +30 -0
- package/dist/rig/humanoidPoses.js.map +1 -0
- package/dist/rig/poseMath.js +54 -0
- package/dist/rig/poseMath.js.map +1 -0
- package/dist/rig/poses.json.js +150 -0
- package/dist/rig/poses.json.js.map +1 -0
- package/dist/save/Autosaver.js +54 -0
- package/dist/save/Autosaver.js.map +1 -0
- package/dist/save/MemoryBackend.js +19 -0
- package/dist/save/MemoryBackend.js.map +1 -0
- package/dist/save/SaveStore.js +103 -0
- package/dist/save/SaveStore.js.map +1 -0
- package/dist/save/WebStorageBackend.js +27 -0
- package/dist/save/WebStorageBackend.js.map +1 -0
- package/dist/save/checksum.js +10 -0
- package/dist/save/checksum.js.map +1 -0
- package/dist/save/migrateSave.js +27 -0
- package/dist/save/migrateSave.js.map +1 -0
- package/dist/settings.js +27 -0
- package/dist/settings.js.map +1 -0
- package/dist/tilemap/TilemapView.js +69 -0
- package/dist/tilemap/TilemapView.js.map +1 -0
- package/dist/tilemap/collision.js +25 -0
- package/dist/tilemap/collision.js.map +1 -0
- package/dist/tilemap/tiled.js +138 -0
- package/dist/tilemap/tiled.js.map +1 -0
- package/dist/transitions/CrossfadeTransition.js +24 -0
- package/dist/transitions/CrossfadeTransition.js.map +1 -0
- package/dist/transitions/DitherWipeTransition.js +70 -0
- package/dist/transitions/DitherWipeTransition.js.map +1 -0
- package/dist/transitions/FadeTransition.js +34 -0
- package/dist/transitions/FadeTransition.js.map +1 -0
- package/dist/transitions/Letterbox.js +42 -0
- package/dist/transitions/Letterbox.js.map +1 -0
- package/dist/transitions/ditherMask.js +15 -0
- package/dist/transitions/ditherMask.js.map +1 -0
- package/dist/transitions/transitionTo.js +28 -0
- package/dist/transitions/transitionTo.js.map +1 -0
- package/dist/transitions/tweenDone.js +15 -0
- package/dist/transitions/tweenDone.js.map +1 -0
- package/dist/types/ambient/ColorGrade.d.ts +41 -0
- package/dist/types/ambient/ColorGrade.d.ts.map +1 -0
- package/dist/types/ambient/DayClock.d.ts +80 -0
- package/dist/types/ambient/DayClock.d.ts.map +1 -0
- package/dist/types/ambient/WeatherLayer.d.ts +78 -0
- package/dist/types/ambient/WeatherLayer.d.ts.map +1 -0
- package/dist/types/ambient/grade.d.ts +22 -0
- package/dist/types/ambient/grade.d.ts.map +1 -0
- package/dist/types/ambient/weather.d.ts +49 -0
- package/dist/types/ambient/weather.d.ts.map +1 -0
- package/dist/types/anim/AnimStateMachine.d.ts +80 -0
- package/dist/types/anim/AnimStateMachine.d.ts.map +1 -0
- package/dist/types/anim/Animator.d.ts +50 -0
- package/dist/types/anim/Animator.d.ts.map +1 -0
- package/dist/types/anim/animStateCompile.d.ts +52 -0
- package/dist/types/anim/animStateCompile.d.ts.map +1 -0
- package/dist/types/anim/animStateSystem.d.ts +10 -0
- package/dist/types/anim/animStateSystem.d.ts.map +1 -0
- package/dist/types/anim/animStateTypes.d.ts +50 -0
- package/dist/types/anim/animStateTypes.d.ts.map +1 -0
- package/dist/types/anim/animationSystem.d.ts +13 -0
- package/dist/types/anim/animationSystem.d.ts.map +1 -0
- package/dist/types/anim/asepriteSlices.d.ts +19 -0
- package/dist/types/anim/asepriteSlices.d.ts.map +1 -0
- package/dist/types/anim/asepriteTags.d.ts +16 -0
- package/dist/types/anim/asepriteTags.d.ts.map +1 -0
- package/dist/types/anim/asepriteTypes.d.ts +159 -0
- package/dist/types/anim/asepriteTypes.d.ts.map +1 -0
- package/dist/types/anim/parseAseprite.d.ts +21 -0
- package/dist/types/anim/parseAseprite.d.ts.map +1 -0
- package/dist/types/assets/AssetLoader.d.ts +85 -0
- package/dist/types/assets/AssetLoader.d.ts.map +1 -0
- package/dist/types/assets/loadAseprite.d.ts +27 -0
- package/dist/types/assets/loadAseprite.d.ts.map +1 -0
- package/dist/types/audio/Footsteps.d.ts +33 -0
- package/dist/types/audio/Footsteps.d.ts.map +1 -0
- package/dist/types/audio/MusicPlayer.d.ts +65 -0
- package/dist/types/audio/MusicPlayer.d.ts.map +1 -0
- package/dist/types/audio/SoundEngine.d.ts +42 -0
- package/dist/types/audio/SoundEngine.d.ts.map +1 -0
- package/dist/types/audio/cleanTake.d.ts +3 -0
- package/dist/types/audio/cleanTake.d.ts.map +1 -0
- package/dist/types/audio/music/ElementVoice.d.ts +14 -0
- package/dist/types/audio/music/ElementVoice.d.ts.map +1 -0
- package/dist/types/audio/music/GraphVoice.d.ts +22 -0
- package/dist/types/audio/music/GraphVoice.d.ts.map +1 -0
- package/dist/types/audio/music/MusicChannel.d.ts +35 -0
- package/dist/types/audio/music/MusicChannel.d.ts.map +1 -0
- package/dist/types/audio/music/musicVoice.d.ts +26 -0
- package/dist/types/audio/music/musicVoice.d.ts.map +1 -0
- package/dist/types/audio/sampleBank.d.ts +27 -0
- package/dist/types/audio/sampleBank.d.ts.map +1 -0
- package/dist/types/audio/soundTable.d.ts +14 -0
- package/dist/types/audio/soundTable.d.ts.map +1 -0
- package/dist/types/audio/synth.d.ts +34 -0
- package/dist/types/audio/synth.d.ts.map +1 -0
- package/dist/types/audio/takeCleanerWorker.d.ts +2 -0
- package/dist/types/audio/takeCleanerWorker.d.ts.map +1 -0
- package/dist/types/core/BitmapLabel.d.ts +36 -0
- package/dist/types/core/BitmapLabel.d.ts.map +1 -0
- package/dist/types/core/Camera.d.ts +115 -0
- package/dist/types/core/Camera.d.ts.map +1 -0
- package/dist/types/core/Clock.d.ts +11 -0
- package/dist/types/core/Clock.d.ts.map +1 -0
- package/dist/types/core/Graphics.d.ts +37 -0
- package/dist/types/core/Graphics.d.ts.map +1 -0
- package/dist/types/core/Group.d.ts +15 -0
- package/dist/types/core/Group.d.ts.map +1 -0
- package/dist/types/core/Image.d.ts +25 -0
- package/dist/types/core/Image.d.ts.map +1 -0
- package/dist/types/core/ObjectFactory.d.ts +34 -0
- package/dist/types/core/ObjectFactory.d.ts.map +1 -0
- package/dist/types/core/Pointer.d.ts +27 -0
- package/dist/types/core/Pointer.d.ts.map +1 -0
- package/dist/types/core/Rectangle.d.ts +26 -0
- package/dist/types/core/Rectangle.d.ts.map +1 -0
- package/dist/types/core/Stage.d.ts +58 -0
- package/dist/types/core/Stage.d.ts.map +1 -0
- package/dist/types/core/Text.d.ts +22 -0
- package/dist/types/core/Text.d.ts.map +1 -0
- package/dist/types/core/TextureRegistry.d.ts +51 -0
- package/dist/types/core/TextureRegistry.d.ts.map +1 -0
- package/dist/types/core/Timeline.d.ts +115 -0
- package/dist/types/core/Timeline.d.ts.map +1 -0
- package/dist/types/core/TimelineBuilder.d.ts +53 -0
- package/dist/types/core/TimelineBuilder.d.ts.map +1 -0
- package/dist/types/core/TimelineChild.d.ts +51 -0
- package/dist/types/core/TimelineChild.d.ts.map +1 -0
- package/dist/types/core/Tweener.d.ts +70 -0
- package/dist/types/core/Tweener.d.ts.map +1 -0
- package/dist/types/core/atlas.d.ts +16 -0
- package/dist/types/core/atlas.d.ts.map +1 -0
- package/dist/types/core/atlasPlan.d.ts +34 -0
- package/dist/types/core/atlasPlan.d.ts.map +1 -0
- package/dist/types/core/eases.d.ts +3 -0
- package/dist/types/core/eases.d.ts.map +1 -0
- package/dist/types/core/gameObject.d.ts +42 -0
- package/dist/types/core/gameObject.d.ts.map +1 -0
- package/dist/types/core/pixiPatches.d.ts +9 -0
- package/dist/types/core/pixiPatches.d.ts.map +1 -0
- package/dist/types/core/timelinePlace.d.ts +23 -0
- package/dist/types/core/timelinePlace.d.ts.map +1 -0
- package/dist/types/core/tweenProps.d.ts +8 -0
- package/dist/types/core/tweenProps.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +4 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/debug/DebugOverlay.d.ts +63 -0
- package/dist/types/debug/DebugOverlay.d.ts.map +1 -0
- package/dist/types/debug/DrawCallCounter.d.ts +20 -0
- package/dist/types/debug/DrawCallCounter.d.ts.map +1 -0
- package/dist/types/debug/ErrorLog.d.ts +20 -0
- package/dist/types/debug/ErrorLog.d.ts.map +1 -0
- package/dist/types/debug/FrameStats.d.ts +21 -0
- package/dist/types/debug/FrameStats.d.ts.map +1 -0
- package/dist/types/debug/inspectWorld.d.ts +14 -0
- package/dist/types/debug/inspectWorld.d.ts.map +1 -0
- package/dist/types/diagnostics/ErrorDeduper.d.ts +17 -0
- package/dist/types/diagnostics/ErrorDeduper.d.ts.map +1 -0
- package/dist/types/diagnostics/FrameSampler.d.ts +37 -0
- package/dist/types/diagnostics/FrameSampler.d.ts.map +1 -0
- package/dist/types/diagnostics/bootWatch.d.ts +25 -0
- package/dist/types/diagnostics/bootWatch.d.ts.map +1 -0
- package/dist/types/diagnostics/captureErrors.d.ts +24 -0
- package/dist/types/diagnostics/captureErrors.d.ts.map +1 -0
- package/dist/types/diagnostics/contextLoss.d.ts +35 -0
- package/dist/types/diagnostics/contextLoss.d.ts.map +1 -0
- package/dist/types/diagnostics/frameStats.d.ts +30 -0
- package/dist/types/diagnostics/frameStats.d.ts.map +1 -0
- package/dist/types/diagnostics/gpuInfo.d.ts +9 -0
- package/dist/types/diagnostics/gpuInfo.d.ts.map +1 -0
- package/dist/types/diagnostics/renderGuard.d.ts +12 -0
- package/dist/types/diagnostics/renderGuard.d.ts.map +1 -0
- package/dist/types/ecs/SparseSet.d.ts +25 -0
- package/dist/types/ecs/SparseSet.d.ts.map +1 -0
- package/dist/types/ecs/World.d.ts +137 -0
- package/dist/types/ecs/World.d.ts.map +1 -0
- package/dist/types/ecs/fields.d.ts +34 -0
- package/dist/types/ecs/fields.d.ts.map +1 -0
- package/dist/types/engine/Engine.d.ts +80 -0
- package/dist/types/engine/Engine.d.ts.map +1 -0
- package/dist/types/engine/FixedLoop.d.ts +32 -0
- package/dist/types/engine/FixedLoop.d.ts.map +1 -0
- package/dist/types/engine/Scene.d.ts +67 -0
- package/dist/types/engine/Scene.d.ts.map +1 -0
- package/dist/types/engine/SceneManager.d.ts +36 -0
- package/dist/types/engine/SceneManager.d.ts.map +1 -0
- package/dist/types/events/EventBus.d.ts +20 -0
- package/dist/types/events/EventBus.d.ts.map +1 -0
- package/dist/types/fx/FloatingText.d.ts +71 -0
- package/dist/types/fx/FloatingText.d.ts.map +1 -0
- package/dist/types/fx/hitStop.d.ts +20 -0
- package/dist/types/fx/hitStop.d.ts.map +1 -0
- package/dist/types/fx/viewCull.d.ts +14 -0
- package/dist/types/fx/viewCull.d.ts.map +1 -0
- package/dist/types/i18n/Translator.d.ts +52 -0
- package/dist/types/i18n/Translator.d.ts.map +1 -0
- package/dist/types/i18n/extractStrings.d.ts +25 -0
- package/dist/types/i18n/extractStrings.d.ts.map +1 -0
- package/dist/types/i18n/formatMessage.d.ts +10 -0
- package/dist/types/i18n/formatMessage.d.ts.map +1 -0
- package/dist/types/index.d.ts +149 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/input/Actions.d.ts +94 -0
- package/dist/types/input/Actions.d.ts.map +1 -0
- package/dist/types/input/AimGesture.d.ts +106 -0
- package/dist/types/input/AimGesture.d.ts.map +1 -0
- package/dist/types/input/Keyboard.d.ts +30 -0
- package/dist/types/input/Keyboard.d.ts.map +1 -0
- package/dist/types/input/Keymap.d.ts +85 -0
- package/dist/types/input/Keymap.d.ts.map +1 -0
- package/dist/types/input/TargetLock.d.ts +56 -0
- package/dist/types/input/TargetLock.d.ts.map +1 -0
- package/dist/types/input/aimAxis.d.ts +9 -0
- package/dist/types/input/aimAxis.d.ts.map +1 -0
- package/dist/types/input/keyChord.d.ts +15 -0
- package/dist/types/input/keyChord.d.ts.map +1 -0
- package/dist/types/input/longPress.d.ts +21 -0
- package/dist/types/input/longPress.d.ts.map +1 -0
- package/dist/types/input/stickAxis.d.ts +26 -0
- package/dist/types/input/stickAxis.d.ts.map +1 -0
- package/dist/types/input/touchDetect.d.ts +18 -0
- package/dist/types/input/touchDetect.d.ts.map +1 -0
- package/dist/types/light/LightLayer.d.ts +65 -0
- package/dist/types/light/LightLayer.d.ts.map +1 -0
- package/dist/types/nav/MinHeap.d.ts +15 -0
- package/dist/types/nav/MinHeap.d.ts.map +1 -0
- package/dist/types/nav/findPath.d.ts +38 -0
- package/dist/types/nav/findPath.d.ts.map +1 -0
- package/dist/types/nav/navGrid.d.ts +48 -0
- package/dist/types/nav/navGrid.d.ts.map +1 -0
- package/dist/types/nav/nearestOpen.d.ts +8 -0
- package/dist/types/nav/nearestOpen.d.ts.map +1 -0
- package/dist/types/nav/straightenPath.d.ts +13 -0
- package/dist/types/nav/straightenPath.d.ts.map +1 -0
- package/dist/types/net/Connection.d.ts +66 -0
- package/dist/types/net/Connection.d.ts.map +1 -0
- package/dist/types/net/InterpolationBuffer.d.ts +36 -0
- package/dist/types/net/InterpolationBuffer.d.ts.map +1 -0
- package/dist/types/net/PredictedMover.d.ts +43 -0
- package/dist/types/net/PredictedMover.d.ts.map +1 -0
- package/dist/types/net/Room.d.ts +69 -0
- package/dist/types/net/Room.d.ts.map +1 -0
- package/dist/types/net/RoomHost.d.ts +74 -0
- package/dist/types/net/RoomHost.d.ts.map +1 -0
- package/dist/types/net/cadence.d.ts +22 -0
- package/dist/types/net/cadence.d.ts.map +1 -0
- package/dist/types/net/constants.d.ts +24 -0
- package/dist/types/net/constants.d.ts.map +1 -0
- package/dist/types/net/lobby/LobbyClient.d.ts +107 -0
- package/dist/types/net/lobby/LobbyClient.d.ts.map +1 -0
- package/dist/types/net/lobby/LobbyHost.d.ts +147 -0
- package/dist/types/net/lobby/LobbyHost.d.ts.map +1 -0
- package/dist/types/net/lobby/LobbyRooms.d.ts +56 -0
- package/dist/types/net/lobby/LobbyRooms.d.ts.map +1 -0
- package/dist/types/net/lobby/Matchmaker.d.ts +57 -0
- package/dist/types/net/lobby/Matchmaker.d.ts.map +1 -0
- package/dist/types/net/lobby/index.d.ts +6 -0
- package/dist/types/net/lobby/index.d.ts.map +1 -0
- package/dist/types/net/lobby/lobbyProtocol.d.ts +143 -0
- package/dist/types/net/lobby/lobbyProtocol.d.ts.map +1 -0
- package/dist/types/net/movement.d.ts +50 -0
- package/dist/types/net/movement.d.ts.map +1 -0
- package/dist/types/net/protocol.d.ts +59 -0
- package/dist/types/net/protocol.d.ts.map +1 -0
- package/dist/types/net/serverClock.d.ts +14 -0
- package/dist/types/net/serverClock.d.ts.map +1 -0
- package/dist/types/net/snapshotCodec.d.ts +55 -0
- package/dist/types/net/snapshotCodec.d.ts.map +1 -0
- package/dist/types/parallax/Parallax.d.ts +37 -0
- package/dist/types/parallax/Parallax.d.ts.map +1 -0
- package/dist/types/parallax/ParallaxLayer.d.ts +80 -0
- package/dist/types/parallax/ParallaxLayer.d.ts.map +1 -0
- package/dist/types/parallax/parallaxMath.d.ts +50 -0
- package/dist/types/parallax/parallaxMath.d.ts.map +1 -0
- package/dist/types/particles/Emitter.d.ts +97 -0
- package/dist/types/particles/Emitter.d.ts.map +1 -0
- package/dist/types/particles/ParticleBudget.d.ts +28 -0
- package/dist/types/particles/ParticleBudget.d.ts.map +1 -0
- package/dist/types/particles/ParticleSim.d.ts +38 -0
- package/dist/types/particles/ParticleSim.d.ts.map +1 -0
- package/dist/types/particles/particleCurves.d.ts +21 -0
- package/dist/types/particles/particleCurves.d.ts.map +1 -0
- package/dist/types/particles/particleSampling.d.ts +20 -0
- package/dist/types/particles/particleSampling.d.ts.map +1 -0
- package/dist/types/physics/Body.d.ts +130 -0
- package/dist/types/physics/Body.d.ts.map +1 -0
- package/dist/types/physics/BroadPhase.d.ts +26 -0
- package/dist/types/physics/BroadPhase.d.ts.map +1 -0
- package/dist/types/physics/Contact.d.ts +62 -0
- package/dist/types/physics/Contact.d.ts.map +1 -0
- package/dist/types/physics/ContactSolver.d.ts +29 -0
- package/dist/types/physics/ContactSolver.d.ts.map +1 -0
- package/dist/types/physics/PhysicsWorld.d.ts +78 -0
- package/dist/types/physics/PhysicsWorld.d.ts.map +1 -0
- package/dist/types/physics/PhysicsWorldOptions.d.ts +24 -0
- package/dist/types/physics/PhysicsWorldOptions.d.ts.map +1 -0
- package/dist/types/physics/SpatialHash.d.ts +23 -0
- package/dist/types/physics/SpatialHash.d.ts.map +1 -0
- package/dist/types/physics/collide.d.ts +27 -0
- package/dist/types/physics/collide.d.ts.map +1 -0
- package/dist/types/physics/collidePolygon.d.ts +14 -0
- package/dist/types/physics/collidePolygon.d.ts.map +1 -0
- package/dist/types/physics/contactReport.d.ts +8 -0
- package/dist/types/physics/contactReport.d.ts.map +1 -0
- package/dist/types/physics/drawColliders.d.ts +43 -0
- package/dist/types/physics/drawColliders.d.ts.map +1 -0
- package/dist/types/physics/physicsSystem.d.ts +5 -0
- package/dist/types/physics/physicsSystem.d.ts.map +1 -0
- package/dist/types/physics/polygon.d.ts +28 -0
- package/dist/types/physics/polygon.d.ts.map +1 -0
- package/dist/types/physics/raycast.d.ts +19 -0
- package/dist/types/physics/raycast.d.ts.map +1 -0
- package/dist/types/physics/syncToBody.d.ts +16 -0
- package/dist/types/physics/syncToBody.d.ts.map +1 -0
- package/dist/types/physics/tileBodies.d.ts +36 -0
- package/dist/types/physics/tileBodies.d.ts.map +1 -0
- package/dist/types/physics/types.d.ts +116 -0
- package/dist/types/physics/types.d.ts.map +1 -0
- package/dist/types/pixel/Darkness.d.ts +78 -0
- package/dist/types/pixel/Darkness.d.ts.map +1 -0
- package/dist/types/pixel/DitherVignette.d.ts +35 -0
- package/dist/types/pixel/DitherVignette.d.ts.map +1 -0
- package/dist/types/pixel/Evaporation.d.ts +30 -0
- package/dist/types/pixel/Evaporation.d.ts.map +1 -0
- package/dist/types/pixel/NightShade.d.ts +38 -0
- package/dist/types/pixel/NightShade.d.ts.map +1 -0
- package/dist/types/pixel/PixelLayer.d.ts +85 -0
- package/dist/types/pixel/PixelLayer.d.ts.map +1 -0
- package/dist/types/pixel/SwayProp.d.ts +52 -0
- package/dist/types/pixel/SwayProp.d.ts.map +1 -0
- package/dist/types/pixel/index.d.ts +31 -0
- package/dist/types/pixel/index.d.ts.map +1 -0
- package/dist/types/pixel/lights.d.ts +34 -0
- package/dist/types/pixel/lights.d.ts.map +1 -0
- package/dist/types/pixel/nineSlice.d.ts +71 -0
- package/dist/types/pixel/nineSlice.d.ts.map +1 -0
- package/dist/types/pixel/paintLayer.d.ts +35 -0
- package/dist/types/pixel/paintLayer.d.ts.map +1 -0
- package/dist/types/pixel/palette.d.ts +58 -0
- package/dist/types/pixel/palette.d.ts.map +1 -0
- package/dist/types/pixel/pixel.d.ts +80 -0
- package/dist/types/pixel/pixel.d.ts.map +1 -0
- package/dist/types/pixel/pixelPaint.d.ts +43 -0
- package/dist/types/pixel/pixelPaint.d.ts.map +1 -0
- package/dist/types/pixel/pixelTone.d.ts +51 -0
- package/dist/types/pixel/pixelTone.d.ts.map +1 -0
- package/dist/types/pixel/propKit.d.ts +26 -0
- package/dist/types/pixel/propKit.d.ts.map +1 -0
- package/dist/types/pixel/ramp.d.ts +57 -0
- package/dist/types/pixel/ramp.d.ts.map +1 -0
- package/dist/types/pixel/selout.d.ts +3 -0
- package/dist/types/pixel/selout.d.ts.map +1 -0
- package/dist/types/pixel/spritePixels.d.ts +29 -0
- package/dist/types/pixel/spritePixels.d.ts.map +1 -0
- package/dist/types/pixel/swayRig.d.ts +72 -0
- package/dist/types/pixel/swayRig.d.ts.map +1 -0
- package/dist/types/pixel/vignetteMask.d.ts +16 -0
- package/dist/types/pixel/vignetteMask.d.ts.map +1 -0
- package/dist/types/pixel/weatherArt.d.ts +29 -0
- package/dist/types/pixel/weatherArt.d.ts.map +1 -0
- package/dist/types/platform/touch.d.ts +10 -0
- package/dist/types/platform/touch.d.ts.map +1 -0
- package/dist/types/postfx/BloomFilter.d.ts +33 -0
- package/dist/types/postfx/BloomFilter.d.ts.map +1 -0
- package/dist/types/postfx/ChromaticAberrationFilter.d.ts +11 -0
- package/dist/types/postfx/ChromaticAberrationFilter.d.ts.map +1 -0
- package/dist/types/postfx/ColorAdjustFilter.d.ts +32 -0
- package/dist/types/postfx/ColorAdjustFilter.d.ts.map +1 -0
- package/dist/types/postfx/CrtFilter.d.ts +16 -0
- package/dist/types/postfx/CrtFilter.d.ts.map +1 -0
- package/dist/types/postfx/PixelateFilter.d.ts +8 -0
- package/dist/types/postfx/PixelateFilter.d.ts.map +1 -0
- package/dist/types/postfx/PostFx.d.ts +92 -0
- package/dist/types/postfx/PostFx.d.ts.map +1 -0
- package/dist/types/postfx/ShockwaveFilter.d.ts +20 -0
- package/dist/types/postfx/ShockwaveFilter.d.ts.map +1 -0
- package/dist/types/postfx/VignetteFilter.d.ts +19 -0
- package/dist/types/postfx/VignetteFilter.d.ts.map +1 -0
- package/dist/types/postfx/fxAnimator.d.ts +32 -0
- package/dist/types/postfx/fxAnimator.d.ts.map +1 -0
- package/dist/types/postfx/fxShader.d.ts +49 -0
- package/dist/types/postfx/fxShader.d.ts.map +1 -0
- package/dist/types/postfx/index.d.ts +11 -0
- package/dist/types/postfx/index.d.ts.map +1 -0
- package/dist/types/react/ChoiceDialog.d.ts +8 -0
- package/dist/types/react/ChoiceDialog.d.ts.map +1 -0
- package/dist/types/react/ConfirmDialog.d.ts +9 -0
- package/dist/types/react/ConfirmDialog.d.ts.map +1 -0
- package/dist/types/react/Glyph.d.ts +54 -0
- package/dist/types/react/Glyph.d.ts.map +1 -0
- package/dist/types/react/Modal.d.ts +22 -0
- package/dist/types/react/Modal.d.ts.map +1 -0
- package/dist/types/react/Panel.d.ts +29 -0
- package/dist/types/react/Panel.d.ts.map +1 -0
- package/dist/types/react/PixelImage.d.ts +19 -0
- package/dist/types/react/PixelImage.d.ts.map +1 -0
- package/dist/types/react/Select.d.ts +27 -0
- package/dist/types/react/Select.d.ts.map +1 -0
- package/dist/types/react/Slider.d.ts +24 -0
- package/dist/types/react/Slider.d.ts.map +1 -0
- package/dist/types/react/SplitPane.d.ts +26 -0
- package/dist/types/react/SplitPane.d.ts.map +1 -0
- package/dist/types/react/TabStrip.d.ts +31 -0
- package/dist/types/react/TabStrip.d.ts.map +1 -0
- package/dist/types/react/TitleTips.d.ts +15 -0
- package/dist/types/react/TitleTips.d.ts.map +1 -0
- package/dist/types/react/Tooltip.d.ts +22 -0
- package/dist/types/react/Tooltip.d.ts.map +1 -0
- package/dist/types/react/UiProvider.d.ts +52 -0
- package/dist/types/react/UiProvider.d.ts.map +1 -0
- package/dist/types/react/baseCss.d.ts +27 -0
- package/dist/types/react/baseCss.d.ts.map +1 -0
- package/dist/types/react/choiceStore.d.ts +34 -0
- package/dist/types/react/choiceStore.d.ts.map +1 -0
- package/dist/types/react/classNames.d.ts +12 -0
- package/dist/types/react/classNames.d.ts.map +1 -0
- package/dist/types/react/confirmStore.d.ts +30 -0
- package/dist/types/react/confirmStore.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +33 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/react/labels.d.ts +24 -0
- package/dist/types/react/labels.d.ts.map +1 -0
- package/dist/types/react/placement.d.ts +59 -0
- package/dist/types/react/placement.d.ts.map +1 -0
- package/dist/types/react/useFillSheet.d.ts +9 -0
- package/dist/types/react/useFillSheet.d.ts.map +1 -0
- package/dist/types/react/useFitToViewport.d.ts +20 -0
- package/dist/types/react/useFitToViewport.d.ts.map +1 -0
- package/dist/types/react/usePicked.d.ts +9 -0
- package/dist/types/react/usePicked.d.ts.map +1 -0
- package/dist/types/react/useStore.d.ts +8 -0
- package/dist/types/react/useStore.d.ts.map +1 -0
- package/dist/types/react/useViewport.d.ts +4 -0
- package/dist/types/react/useViewport.d.ts.map +1 -0
- package/dist/types/rig/PosePlayer.d.ts +64 -0
- package/dist/types/rig/PosePlayer.d.ts.map +1 -0
- package/dist/types/rig/RigView.d.ts +68 -0
- package/dist/types/rig/RigView.d.ts.map +1 -0
- package/dist/types/rig/Skeleton.d.ts +14 -0
- package/dist/types/rig/Skeleton.d.ts.map +1 -0
- package/dist/types/rig/humanoid.d.ts +4 -0
- package/dist/types/rig/humanoid.d.ts.map +1 -0
- package/dist/types/rig/humanoidPoses.d.ts +117 -0
- package/dist/types/rig/humanoidPoses.d.ts.map +1 -0
- package/dist/types/rig/poseMath.d.ts +14 -0
- package/dist/types/rig/poseMath.d.ts.map +1 -0
- package/dist/types/rig/rigTypes.d.ts +82 -0
- package/dist/types/rig/rigTypes.d.ts.map +1 -0
- package/dist/types/save/Autosaver.d.ts +43 -0
- package/dist/types/save/Autosaver.d.ts.map +1 -0
- package/dist/types/save/MemoryBackend.d.ts +10 -0
- package/dist/types/save/MemoryBackend.d.ts.map +1 -0
- package/dist/types/save/SaveBackend.d.ts +14 -0
- package/dist/types/save/SaveBackend.d.ts.map +1 -0
- package/dist/types/save/SaveStore.d.ts +73 -0
- package/dist/types/save/SaveStore.d.ts.map +1 -0
- package/dist/types/save/WebStorageBackend.d.ts +14 -0
- package/dist/types/save/WebStorageBackend.d.ts.map +1 -0
- package/dist/types/save/checksum.d.ts +7 -0
- package/dist/types/save/checksum.d.ts.map +1 -0
- package/dist/types/save/migrateSave.d.ts +17 -0
- package/dist/types/save/migrateSave.d.ts.map +1 -0
- package/dist/types/settings.d.ts +25 -0
- package/dist/types/settings.d.ts.map +1 -0
- package/dist/types/tilemap/TilemapView.d.ts +42 -0
- package/dist/types/tilemap/TilemapView.d.ts.map +1 -0
- package/dist/types/tilemap/collision.d.ts +16 -0
- package/dist/types/tilemap/collision.d.ts.map +1 -0
- package/dist/types/tilemap/tiled.d.ts +104 -0
- package/dist/types/tilemap/tiled.d.ts.map +1 -0
- package/dist/types/transitions/CrossfadeTransition.d.ts +20 -0
- package/dist/types/transitions/CrossfadeTransition.d.ts.map +1 -0
- package/dist/types/transitions/DitherWipeTransition.d.ts +35 -0
- package/dist/types/transitions/DitherWipeTransition.d.ts.map +1 -0
- package/dist/types/transitions/FadeTransition.d.ts +20 -0
- package/dist/types/transitions/FadeTransition.d.ts.map +1 -0
- package/dist/types/transitions/Letterbox.d.ts +33 -0
- package/dist/types/transitions/Letterbox.d.ts.map +1 -0
- package/dist/types/transitions/Transition.d.ts +22 -0
- package/dist/types/transitions/Transition.d.ts.map +1 -0
- package/dist/types/transitions/ditherMask.d.ts +13 -0
- package/dist/types/transitions/ditherMask.d.ts.map +1 -0
- package/dist/types/transitions/transitionTo.d.ts +16 -0
- package/dist/types/transitions/transitionTo.d.ts.map +1 -0
- package/dist/types/transitions/tweenDone.d.ts +5 -0
- package/dist/types/transitions/tweenDone.d.ts.map +1 -0
- package/dist/types/ui/Bar.d.ts +41 -0
- package/dist/types/ui/Bar.d.ts.map +1 -0
- package/dist/types/ui/Button.d.ts +47 -0
- package/dist/types/ui/Button.d.ts.map +1 -0
- package/dist/types/ui/Dialog.d.ts +47 -0
- package/dist/types/ui/Dialog.d.ts.map +1 -0
- package/dist/types/ui/FocusManager.d.ts +53 -0
- package/dist/types/ui/FocusManager.d.ts.map +1 -0
- package/dist/types/ui/Label.d.ts +24 -0
- package/dist/types/ui/Label.d.ts.map +1 -0
- package/dist/types/ui/List.d.ts +23 -0
- package/dist/types/ui/List.d.ts.map +1 -0
- package/dist/types/ui/Panel.d.ts +38 -0
- package/dist/types/ui/Panel.d.ts.map +1 -0
- package/dist/types/ui/ScrollView.d.ts +56 -0
- package/dist/types/ui/ScrollView.d.ts.map +1 -0
- package/dist/types/ui/Slider.d.ts +47 -0
- package/dist/types/ui/Slider.d.ts.map +1 -0
- package/dist/types/ui/Stack.d.ts +16 -0
- package/dist/types/ui/Stack.d.ts.map +1 -0
- package/dist/types/ui/Toggle.d.ts +31 -0
- package/dist/types/ui/Toggle.d.ts.map +1 -0
- package/dist/types/ui/UiHost.d.ts +18 -0
- package/dist/types/ui/UiHost.d.ts.map +1 -0
- package/dist/types/ui/UiPointerGate.d.ts +17 -0
- package/dist/types/ui/UiPointerGate.d.ts.map +1 -0
- package/dist/types/ui/UiRoot.d.ts +73 -0
- package/dist/types/ui/UiRoot.d.ts.map +1 -0
- package/dist/types/ui/Widget.d.ts +56 -0
- package/dist/types/ui/Widget.d.ts.map +1 -0
- package/dist/types/ui/dom/DomOverlay.d.ts +52 -0
- package/dist/types/ui/dom/DomOverlay.d.ts.map +1 -0
- package/dist/types/ui/dom/DomWorldAnchors.d.ts +50 -0
- package/dist/types/ui/dom/DomWorldAnchors.d.ts.map +1 -0
- package/dist/types/ui/dom/InputShield.d.ts +20 -0
- package/dist/types/ui/dom/InputShield.d.ts.map +1 -0
- package/dist/types/ui/dom/createStore.d.ts +22 -0
- package/dist/types/ui/dom/createStore.d.ts.map +1 -0
- package/dist/types/ui/dom/shieldDecision.d.ts +34 -0
- package/dist/types/ui/dom/shieldDecision.d.ts.map +1 -0
- package/dist/types/ui/dom/worldToScreen.d.ts +24 -0
- package/dist/types/ui/dom/worldToScreen.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +38 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/dist/types/ui/layout/anchor.d.ts +9 -0
- package/dist/types/ui/layout/anchor.d.ts.map +1 -0
- package/dist/types/ui/layout/barDrain.d.ts +25 -0
- package/dist/types/ui/layout/barDrain.d.ts.map +1 -0
- package/dist/types/ui/layout/fitToViewport.d.ts +32 -0
- package/dist/types/ui/layout/fitToViewport.d.ts.map +1 -0
- package/dist/types/ui/layout/focusNav.d.ts +13 -0
- package/dist/types/ui/layout/focusNav.d.ts.map +1 -0
- package/dist/types/ui/layout/geometry.d.ts +35 -0
- package/dist/types/ui/layout/geometry.d.ts.map +1 -0
- package/dist/types/ui/layout/listWidth.d.ts +13 -0
- package/dist/types/ui/layout/listWidth.d.ts.map +1 -0
- package/dist/types/ui/layout/placeTooltip.d.ts +23 -0
- package/dist/types/ui/layout/placeTooltip.d.ts.map +1 -0
- package/dist/types/ui/layout/scroll.d.ts +17 -0
- package/dist/types/ui/layout/scroll.d.ts.map +1 -0
- package/dist/types/ui/layout/slider.d.ts +7 -0
- package/dist/types/ui/layout/slider.d.ts.map +1 -0
- package/dist/types/ui/layout/stack.d.ts +26 -0
- package/dist/types/ui/layout/stack.d.ts.map +1 -0
- package/dist/types/ui/layout/wrapRow.d.ts +6 -0
- package/dist/types/ui/layout/wrapRow.d.ts.map +1 -0
- package/dist/ui/Bar.js +54 -0
- package/dist/ui/Bar.js.map +1 -0
- package/dist/ui/Button.js +58 -0
- package/dist/ui/Button.js.map +1 -0
- package/dist/ui/Dialog.js +56 -0
- package/dist/ui/Dialog.js.map +1 -0
- package/dist/ui/FocusManager.js +97 -0
- package/dist/ui/FocusManager.js.map +1 -0
- package/dist/ui/Label.js +36 -0
- package/dist/ui/Label.js.map +1 -0
- package/dist/ui/List.js +45 -0
- package/dist/ui/List.js.map +1 -0
- package/dist/ui/Panel.js +38 -0
- package/dist/ui/Panel.js.map +1 -0
- package/dist/ui/ScrollView.js +96 -0
- package/dist/ui/ScrollView.js.map +1 -0
- package/dist/ui/Slider.js +55 -0
- package/dist/ui/Slider.js.map +1 -0
- package/dist/ui/Stack.js +28 -0
- package/dist/ui/Stack.js.map +1 -0
- package/dist/ui/Toggle.js +37 -0
- package/dist/ui/Toggle.js.map +1 -0
- package/dist/ui/UiHost.js +9 -0
- package/dist/ui/UiHost.js.map +1 -0
- package/dist/ui/UiPointerGate.js +25 -0
- package/dist/ui/UiPointerGate.js.map +1 -0
- package/dist/ui/UiRoot.js +93 -0
- package/dist/ui/UiRoot.js.map +1 -0
- package/dist/ui/Widget.js +90 -0
- package/dist/ui/Widget.js.map +1 -0
- package/dist/ui/dom/DomOverlay.js +59 -0
- package/dist/ui/dom/DomOverlay.js.map +1 -0
- package/dist/ui/dom/DomWorldAnchors.js +59 -0
- package/dist/ui/dom/DomWorldAnchors.js.map +1 -0
- package/dist/ui/dom/InputShield.js +27 -0
- package/dist/ui/dom/InputShield.js.map +1 -0
- package/dist/ui/dom/createStore.js +42 -0
- package/dist/ui/dom/createStore.js.map +1 -0
- package/dist/ui/dom/shieldDecision.js +36 -0
- package/dist/ui/dom/shieldDecision.js.map +1 -0
- package/dist/ui/dom/worldToScreen.js +11 -0
- package/dist/ui/dom/worldToScreen.js.map +1 -0
- package/dist/ui/layout/anchor.js +20 -0
- package/dist/ui/layout/anchor.js.map +1 -0
- package/dist/ui/layout/barDrain.js +25 -0
- package/dist/ui/layout/barDrain.js.map +1 -0
- package/dist/ui/layout/fitToViewport.js +17 -0
- package/dist/ui/layout/fitToViewport.js.map +1 -0
- package/dist/ui/layout/focusNav.js +42 -0
- package/dist/ui/layout/focusNav.js.map +1 -0
- package/dist/ui/layout/geometry.js +21 -0
- package/dist/ui/layout/geometry.js.map +1 -0
- package/dist/ui/layout/listWidth.js +10 -0
- package/dist/ui/layout/listWidth.js.map +1 -0
- package/dist/ui/layout/placeTooltip.js +28 -0
- package/dist/ui/layout/placeTooltip.js.map +1 -0
- package/dist/ui/layout/scroll.js +24 -0
- package/dist/ui/layout/scroll.js.map +1 -0
- package/dist/ui/layout/slider.js +20 -0
- package/dist/ui/layout/slider.js.map +1 -0
- package/dist/ui/layout/stack.js +27 -0
- package/dist/ui/layout/stack.js.map +1 -0
- package/dist/ui/layout/wrapRow.js +13 -0
- package/dist/ui/layout/wrapRow.js.map +1 -0
- package/dist/ui.js +85 -0
- package/dist/ui.js.map +1 -0
- package/package.json +115 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixel.js","sources":["../../src/pixel/pixel.ts"],"sourcesContent":["/*\n * Minimal pixel-art canvas. All game art is painted procedurally with these primitives\n * (no external/copyrighted assets). Colors are packed little-endian RGBA (ImageData layout).\n */\n\nexport type Color = number;\n\nexport const CLEAR: Color = 0;\n\nexport function rgba(r: number, g: number, b: number, a = 255): Color {\n const R = Math.max(0, Math.min(255, Math.round(r)));\n const G = Math.max(0, Math.min(255, Math.round(g)));\n const B = Math.max(0, Math.min(255, Math.round(b)));\n const A = Math.max(0, Math.min(255, Math.round(a)));\n return ((A << 24) | (B << 16) | (G << 8) | R) >>> 0;\n}\n\nexport function hex(s: string): Color {\n let h = s.startsWith('#') ? s.slice(1) : s;\n if (h.length === 3) h = [...h].map((c) => c + c).join('');\n const r = parseInt(h.slice(0, 2), 16);\n const g = parseInt(h.slice(2, 4), 16);\n const b = parseInt(h.slice(4, 6), 16);\n const a = h.length >= 8 ? parseInt(h.slice(6, 8), 16) : 255;\n return rgba(r, g, b, a);\n}\n\nexport function channels(c: Color): [number, number, number, number] {\n return [c & 255, (c >>> 8) & 255, (c >>> 16) & 255, (c >>> 24) & 255];\n}\n\n/** f < 1 darkens, f > 1 lightens toward white. */\nexport function shade(c: Color, f: number): Color {\n const [r, g, b, a] = channels(c);\n if (f >= 1) {\n const t = Math.min(1, f - 1);\n return rgba(r + (255 - r) * t, g + (255 - g) * t, b + (255 - b) * t, a);\n }\n return rgba(r * f, g * f, b * f, a);\n}\n\nexport function mix(c1: Color, c2: Color, t: number): Color {\n const a = channels(c1);\n const b = channels(c2);\n return rgba(a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t, a[3] + (b[3] - a[3]) * t);\n}\n\nexport function withAlpha(c: Color, alpha: number): Color {\n const [r, g, b] = channels(c);\n return rgba(r, g, b, alpha);\n}\n\nexport function toCss(c: Color): string {\n const [r, g, b, a] = channels(c);\n return `rgba(${r},${g},${b},${(a / 255).toFixed(3)})`;\n}\n\nexport function hash2(x: number, y: number, seed = 0): number {\n let h = (x * 374761393 + y * 668265263 + seed * 2147483647) | 0;\n h = Math.imul(h ^ (h >>> 13), 1274126177);\n return ((h ^ (h >>> 16)) >>> 0) / 4294967296;\n}\n\nexport function mulberry32(seed: number): () => number {\n let a = seed >>> 0;\n return () => {\n a = (a + 0x6d2b79f5) >>> 0;\n let t = a;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport function valueNoise(x: number, y: number, scale: number, seed: number): number {\n const fx = x / scale;\n const fy = y / scale;\n const x0 = Math.floor(fx);\n const y0 = Math.floor(fy);\n const tx = fx - x0;\n const ty = fy - y0;\n const sx = tx * tx * (3 - 2 * tx);\n const sy = ty * ty * (3 - 2 * ty);\n const a = hash2(x0, y0, seed);\n const b = hash2(x0 + 1, y0, seed);\n const c = hash2(x0, y0 + 1, seed);\n const d = hash2(x0 + 1, y0 + 1, seed);\n return a + (b - a) * sx + (c - a) * sy + (a - b - c + d) * sx * sy;\n}\n\n\n\n\nexport class PixelGrid {\n readonly data: Uint32Array;\n\n constructor(\n readonly w: number,\n readonly h: number,\n ) {\n this.data = new Uint32Array(w * h);\n }\n\n inBounds(x: number, y: number): boolean {\n return x >= 0 && y >= 0 && x < this.w && y < this.h;\n }\n\n px(x: number, y: number, c: Color): void {\n x = Math.floor(x);\n y = Math.floor(y);\n if (x >= 0 && y >= 0 && x < this.w && y < this.h) this.data[y * this.w + x] = c;\n }\n\n get(x: number, y: number): Color {\n if (x < 0 || y < 0 || x >= this.w || y >= this.h) return CLEAR;\n return this.data[y * this.w + x] ?? CLEAR;\n }\n\n alphaAt(x: number, y: number): number {\n return this.get(x, y) >>> 24;\n }\n\n rect(x: number, y: number, w: number, h: number, c: Color): void {\n for (let yy = Math.floor(y); yy < y + h; yy++) for (let xx = Math.floor(x); xx < x + w; xx++) this.px(xx, yy, c);\n }\n\n hline(x0: number, x1: number, y: number, c: Color): void {\n for (let x = Math.min(x0, x1); x <= Math.max(x0, x1); x++) this.px(x, y, c);\n }\n\n vline(x: number, y0: number, y1: number, c: Color): void {\n for (let y = Math.min(y0, y1); y <= Math.max(y0, y1); y++) this.px(x, y, c);\n }\n\n /** Filled ellipse; a pixel is inside when its center lies inside the ellipse. */\n ellipse(cx: number, cy: number, rx: number, ry: number, c: Color): void {\n if (rx <= 0 || ry <= 0) return;\n for (let y = Math.floor(cy - ry); y <= Math.ceil(cy + ry); y++)\n for (let x = Math.floor(cx - rx); x <= Math.ceil(cx + rx); x++) {\n const dx = (x + 0.5 - cx) / rx;\n const dy = (y + 0.5 - cy) / ry;\n if (dx * dx + dy * dy <= 1) this.px(x, y, c);\n }\n }\n\n circle(cx: number, cy: number, r: number, c: Color): void {\n this.ellipse(cx, cy, r, r, c);\n }\n\n ring(cx: number, cy: number, r: number, thickness: number, c: Color): void {\n for (let y = Math.floor(cy - r - 1); y <= Math.ceil(cy + r + 1); y++)\n for (let x = Math.floor(cx - r - 1); x <= Math.ceil(cx + r + 1); x++) {\n const d = Math.hypot(x + 0.5 - cx, y + 0.5 - cy);\n if (d <= r && d >= r - thickness) this.px(x, y, c);\n }\n }\n\n line(x0: number, y0: number, x1: number, y1: number, c: Color, thickness = 1): void {\n x0 = Math.round(x0);\n y0 = Math.round(y0);\n x1 = Math.round(x1);\n y1 = Math.round(y1);\n const dx = Math.abs(x1 - x0);\n const dy = -Math.abs(y1 - y0);\n const sx = x0 < x1 ? 1 : -1;\n const sy = y0 < y1 ? 1 : -1;\n let err = dx + dy;\n for (;;) {\n if (thickness <= 1) this.px(x0, y0, c);\n else this.rect(x0 - Math.floor((thickness - 1) / 2), y0 - Math.floor((thickness - 1) / 2), thickness, thickness, c);\n if (x0 === x1 && y0 === y1) break;\n const e2 = 2 * err;\n if (e2 >= dy) {\n err += dy;\n x0 += sx;\n }\n if (e2 <= dx) {\n err += dx;\n y0 += sy;\n }\n }\n }\n\n /** Filled polygon (even-odd scanline on pixel centers). */\n poly(points: [number, number][], c: Color): void {\n if (points.length < 3) return;\n const minY = Math.floor(Math.min(...points.map((p) => p[1])));\n const maxY = Math.ceil(Math.max(...points.map((p) => p[1])));\n for (let y = minY; y <= maxY; y++) {\n const sy = y + 0.5;\n const xs: number[] = [];\n for (let i = 0; i < points.length; i++) {\n const a = points[i]!;\n const b = points[(i + 1) % points.length]!;\n if ((a[1] <= sy && b[1] > sy) || (b[1] <= sy && a[1] > sy)) {\n xs.push(a[0] + ((sy - a[1]) / (b[1] - a[1])) * (b[0] - a[0]));\n }\n }\n xs.sort((p, q) => p - q);\n for (let i = 0; i + 1 < xs.length; i += 2) {\n for (let x = Math.ceil(xs[i]! - 0.5); x <= Math.floor(xs[i + 1]! - 0.5); x++) this.px(x, y, c);\n }\n }\n }\n\n /**\n * Adds `width` pixels of outline around all opaque pixels, one ring at a time — the same result as calling it\n * `width` times, but each ring only visits the neighbours of the ring before it instead of the whole grid again.\n * (A pixel next to ring `k` is always filled by ring `k+1`, so nothing further back can still be waiting.)\n */\n outline(c: Color, diagonal = false, width = 1): void {\n const w = this.w;\n const h = this.h;\n const solid = new Uint8Array(this.data.length);\n let x0 = w, y0 = h, x1 = -1, y1 = -1;\n for (let y = 0; y < h; y++)\n for (let x = 0; x < w; x++) {\n const i = y * w + x;\n if ((this.data[i]! >>> 24) === 0) continue;\n solid[i] = 1;\n if (x < x0) x0 = x;\n if (x > x1) x1 = x;\n if (y < y0) y0 = y;\n y1 = y;\n }\n if (x1 < 0) return;\n const has = (x: number, y: number, i: number) => x >= 0 && y >= 0 && x < w && y < h && solid[i] === 1;\n // The first ring is one sweep of the box the body actually fills, so its interior never reaches a frontier list.\n let frontier: number[] = [];\n for (let y = Math.max(0, y0 - 1); y <= Math.min(h - 1, y1 + 1); y++)\n for (let x = Math.max(0, x0 - 1); x <= Math.min(w - 1, x1 + 1); x++) {\n const i = y * w + x;\n if (solid[i]) continue;\n let hit = has(x - 1, y, i - 1) || has(x + 1, y, i + 1) || has(x, y - 1, i - w) || has(x, y + 1, i + w);\n if (!hit && diagonal)\n hit = has(x - 1, y - 1, i - w - 1) || has(x + 1, y - 1, i - w + 1) || has(x - 1, y + 1, i + w - 1) || has(x + 1, y + 1, i + w + 1);\n if (hit) {\n this.data[i] = c;\n frontier.push(i);\n }\n }\n for (const i of frontier) solid[i] = 1;\n // Later rings only visit the neighbours of the ring before them.\n for (let step = 1; step < width && frontier.length; step++) {\n const next: number[] = [];\n for (const i of frontier) {\n const x = i % w;\n const y = (i / w) | 0;\n const grow = (nx: number, ny: number, k: number) => {\n if (nx < 0 || ny < 0 || nx >= w || ny >= h || solid[k]) return;\n solid[k] = 1;\n this.data[k] = c;\n next.push(k);\n };\n grow(x - 1, y, i - 1);\n grow(x + 1, y, i + 1);\n grow(x, y - 1, i - w);\n grow(x, y + 1, i + w);\n if (diagonal) {\n grow(x - 1, y - 1, i - w - 1);\n grow(x + 1, y - 1, i - w + 1);\n grow(x - 1, y + 1, i + w - 1);\n grow(x + 1, y + 1, i + w + 1);\n }\n }\n frontier = next;\n }\n }\n\n /** Replaces every pixel whose color matches `from`. */\n recolor(from: Color, to: Color): void {\n for (let i = 0; i < this.data.length; i++) if (this.data[i] === from) this.data[i] = to;\n }\n\n /** Multiplies brightness of opaque pixels matching `pred`. */\n tint(f: number, pred: (x: number, y: number) => boolean): void {\n for (let y = 0; y < this.h; y++)\n for (let x = 0; x < this.w; x++) {\n const i = y * this.w + x;\n const c = this.data[i] ?? 0;\n if (c >>> 24 && pred(x, y)) this.data[i] = shade(c, f);\n }\n }\n\n blit(src: PixelGrid, dx: number, dy: number, flipX = false): void {\n for (let y = 0; y < src.h; y++)\n for (let x = 0; x < src.w; x++) {\n const c = src.data[y * src.w + x] ?? 0;\n if (c >>> 24 === 0) continue;\n this.px(dx + (flipX ? src.w - 1 - x : x), dy + y, c);\n }\n }\n\n /** Alpha-blends a color onto an existing pixel. */\n blend(x: number, y: number, c: Color): void {\n if (!this.inBounds(x, y)) return;\n const i = y * this.w + x;\n const dst = this.data[i] ?? 0;\n const [r, g, b, a] = channels(c);\n const t = a / 255;\n const d = channels(dst);\n this.data[i] = rgba(d[0] + (r - d[0]) * t, d[1] + (g - d[1]) * t, d[2] + (b - d[2]) * t, Math.max(d[3], a));\n }\n\n /** Reads a canvas back into a grid (a PNG layer of the paper doll joining the painted ones). */\n static from(canvas: HTMLCanvasElement): PixelGrid {\n const g = new PixelGrid(canvas.width, canvas.height);\n const img = canvas.getContext('2d')!.getImageData(0, 0, canvas.width, canvas.height);\n g.data.set(new Uint32Array(img.data.buffer, img.data.byteOffset, canvas.width * canvas.height));\n return g;\n }\n\n /** The same picture on a grid `factor` times as fine, each pixel becoming a square block. */\n upscaled(factor: number): PixelGrid {\n if (factor === 1) return this;\n const g = new PixelGrid(this.w * factor, this.h * factor);\n for (let y = 0; y < this.h; y++)\n for (let x = 0; x < this.w; x++) {\n const c = this.data[y * this.w + x] ?? 0;\n if (c >>> 24 === 0) continue;\n g.rect(x * factor, y * factor, factor, factor, c);\n }\n return g;\n }\n\n /** Same size and same pixels. */\n equals(other: PixelGrid): boolean {\n if (other.w !== this.w || other.h !== this.h) return false;\n for (let i = 0; i < this.data.length; i++) if (this.data[i] !== other.data[i]) return false;\n return true;\n }\n\n /** Cheap hash of the pixels, for grouping identical frames before comparing them. */\n key(): number {\n let h = 2166136261 >>> 0;\n for (let i = 0; i < this.data.length; i++) {\n h ^= this.data[i]!;\n h = Math.imul(h, 16777619) >>> 0;\n }\n return h >>> 0;\n }\n\n clone(): PixelGrid {\n const g = new PixelGrid(this.w, this.h);\n g.data.set(this.data);\n return g;\n }\n\n toCanvas(): HTMLCanvasElement {\n const canvas = document.createElement('canvas');\n canvas.width = this.w;\n canvas.height = this.h;\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new Error('2D canvas not supported');\n const bytes = new Uint8ClampedArray(this.w * this.h * 4);\n bytes.set(new Uint8Array(this.data.buffer, this.data.byteOffset, this.data.byteLength));\n const img = new ImageData(bytes, this.w, this.h);\n ctx.putImageData(img, 0, 0);\n return canvas;\n }\n}\n\n/**\n * A grid that stands for one window of a larger picture: it is drawn on in the larger picture's coordinates and\n * keeps only what falls inside `[x0, x0 + w) × [y0, y0 + h)`. A ground painter can paint a crop of a map into one, so the\n * login screen does not paint the whole of two maps to show 17 tiles of each. Every drawing method goes through\n * `px`/`get`/`inBounds`/`blend`; `outline`, `tint` and the whole-grid helpers work in window coordinates.\n */\nexport class PixelWindow extends PixelGrid {\n constructor(\n readonly x0: number,\n readonly y0: number,\n w: number,\n h: number,\n ) {\n super(w, h);\n }\n\n override inBounds(x: number, y: number): boolean {\n return super.inBounds(x - this.x0, y - this.y0);\n }\n\n override px(x: number, y: number, c: Color): void {\n super.px(Math.floor(x) - this.x0, Math.floor(y) - this.y0, c);\n }\n\n override get(x: number, y: number): Color {\n return super.get(x - this.x0, y - this.y0);\n }\n\n override blend(x: number, y: number, c: Color): void {\n // not through super.blend: it asks `this.inBounds`, which would move the point a second time\n const lx = x - this.x0;\n const ly = y - this.y0;\n if (!super.inBounds(lx, ly)) return;\n const i = ly * this.w + lx;\n const dst = this.data[i] ?? 0;\n const [r, g, b, a] = channels(c);\n const t = a / 255;\n const d = channels(dst);\n this.data[i] = rgba(d[0] + (r - d[0]) * t, d[1] + (g - d[1]) * t, d[2] + (b - d[2]) * t, Math.max(d[3], a));\n }\n}\n\n/**\n * Packs same-sized frames into rows no wider than `maxWidth`. A browser refuses a canvas past about 16k pixels\n * on a side and hands back a blank one, and a player sheet of six hundred frames at twice the detail is wider\n * than that, so it wraps. Readers work the row out from the canvas width.\n */\nexport function makeSheet(frames: PixelGrid[], maxWidth = 16384): HTMLCanvasElement {\n const first = frames[0];\n if (!first) throw new Error('makeSheet: no frames');\n const cols = Math.max(1, Math.min(frames.length, Math.floor(maxWidth / first.w)));\n const rows = Math.ceil(frames.length / cols);\n const sheet = new PixelGrid(first.w * cols, first.h * rows);\n frames.forEach((f, i) => sheet.blit(f, (i % cols) * first.w, Math.floor(i / cols) * first.h));\n return sheet.toCanvas();\n}\n\n/** Scales a canvas by an integer factor with nearest-neighbour filtering (for UI icons). */\nexport function upscale(src: HTMLCanvasElement, factor: number): HTMLCanvasElement {\n const c = document.createElement('canvas');\n c.width = src.width * factor;\n c.height = src.height * factor;\n const ctx = c.getContext('2d');\n if (!ctx) throw new Error('2D canvas not supported');\n ctx.imageSmoothingEnabled = false;\n ctx.drawImage(src, 0, 0, c.width, c.height);\n return c;\n}\n"],"names":["CLEAR","rgba","g","b","a","R","G","B","hex","s","h","c","r","channels","shade","f","t","mix","c1","c2","withAlpha","alpha","toCss","hash2","x","y","seed","mulberry32","valueNoise","scale","fx","fy","x0","y0","tx","ty","sx","sy","d","PixelGrid","w","yy","xx","x1","y1","cx","cy","rx","ry","dx","dy","thickness","err","e2","points","minY","p","maxY","xs","i","q","diagonal","width","solid","has","frontier","hit","step","next","grow","nx","ny","k","from","to","pred","src","flipX","dst","canvas","img","factor","other","ctx","bytes","PixelWindow","lx","ly","makeSheet","frames","maxWidth","first","cols","rows","sheet","upscale"],"mappings":"AAOO,MAAMA,IAAe;AAErB,SAASC,EAAK,GAAWC,GAAWC,GAAWC,IAAI,KAAY;AACpE,QAAMC,IAA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MC,IAAO,KAAK,IAAI,GAAG,KAAK,IAAIH,EAAO,QAAQ,KAAK,MAAMC,IAAWC,EAAM,CAAC,CAAC,CAAC,GAC1EE,IAAO,KAAK,KAAKJ,EAAO,SAASG,CAAI,GACrCE,IAAQ,IAAIvD,EAAUoD,EAAM,IAAIC,GAAMD,EAAM,IAAIE,CAAI;AAC1D,SAAAJ,EAAO,QAAQ,CAAC1E,GAAG4C,MAAMmC,EAAM,KAAK/E,GAAI4C,IAAIiC,IAAQD,EAAM,GAAG,KAAK,MAAMhC,IAAIiC,CAAI,IAAID,EAAM,CAAC,CAAC,GACrFG,EAAM,SAAA;AACf;AAGO,SAASC,EAAQnB,GAAwBK,GAAmC;AACjF,QAAMtE,IAAI,SAAS,cAAc,QAAQ;AACzC,EAAAA,EAAE,QAAQiE,EAAI,QAAQK,GACtBtE,EAAE,SAASiE,EAAI,SAASK;AACxB,QAAME,IAAMxE,EAAE,WAAW,IAAI;AAC7B,MAAI,CAACwE,EAAK,OAAM,IAAI,MAAM,yBAAyB;AACnD,SAAAA,EAAI,wBAAwB,IAC5BA,EAAI,UAAUP,GAAK,GAAG,GAAGjE,EAAE,OAAOA,EAAE,MAAM,GACnCA;AACT;"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { ramp as P, dithered as R, grade as S, capturing as O, stageRun as v, endOutline as E, pixelKey as F, fillRuns as H, batchFor as T, record as K, beginOutline as L, flushBatch as j, currentCoverage as D } from "./pixelTone.js";
|
|
2
|
+
import { PixelLayer as G } from "./PixelLayer.js";
|
|
3
|
+
const J = 16774358, d = (f) => Math.round(f);
|
|
4
|
+
function y(f, e, o, n, c = 1) {
|
|
5
|
+
const s = d(e), t = d(o);
|
|
6
|
+
if (R(s, t)) return;
|
|
7
|
+
const i = S(n);
|
|
8
|
+
if (O()) {
|
|
9
|
+
for (let a = 0; a < c; a++) for (let h = 0; h < c; h++) K(s + h, t + a, i);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const l = T(f);
|
|
13
|
+
if (l) {
|
|
14
|
+
for (let a = 0; a < c; a++) v(l, s, t + a, c, i);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
f.fillStyle(i, 1).fillRect(s, t, c, c);
|
|
18
|
+
}
|
|
19
|
+
class C {
|
|
20
|
+
at = /* @__PURE__ */ new Map();
|
|
21
|
+
set(e, o, n) {
|
|
22
|
+
this.at.set(F(d(e), d(o)), n);
|
|
23
|
+
}
|
|
24
|
+
lay(e) {
|
|
25
|
+
if (O()) {
|
|
26
|
+
for (const [c, s] of this.at) y(e, (c >>> 16) - 32768, (c & 65535) - 32768, s);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const o = T(e);
|
|
30
|
+
if (o instanceof G) {
|
|
31
|
+
for (const [c, s] of this.at) {
|
|
32
|
+
const t = (c >>> 16) - 32768, i = (c & 65535) - 32768;
|
|
33
|
+
R(t, i) || o.stage(t, i, 1, S(s));
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const n = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const [c, s] of this.at) R((c >>> 16) - 32768, (c & 65535) - 32768) || n.set(c, S(s));
|
|
39
|
+
H(e, n);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function k(f, e, o, n, c) {
|
|
43
|
+
const s = d(e), t = d(n);
|
|
44
|
+
if (!(t <= 0)) {
|
|
45
|
+
if (!O() && !R(s, o) && !R(s + 1, o) && !R(s + 2, o + 1) && !R(s + 3, o + 1)) {
|
|
46
|
+
const i = T(f);
|
|
47
|
+
if (i) {
|
|
48
|
+
v(i, s, d(o), t, S(c));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
f.fillStyle(S(c), 1).fillRect(s, d(o), t, 1);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (let i = 0; i < t; i++) y(f, s + i, o, c);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function Y(f, e, o) {
|
|
58
|
+
L();
|
|
59
|
+
try {
|
|
60
|
+
o();
|
|
61
|
+
} finally {
|
|
62
|
+
E(f, e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function A(f, e, o, n, c = 2) {
|
|
66
|
+
const s = Math.hypot(o.x - e.x, o.y - e.y), t = Math.max(1, Math.ceil(s)), i = s ? -(o.y - e.y) / s : 0, l = s ? (o.x - e.x) / s : 1, a = P(n), h = Math.max(1, Math.round(c));
|
|
67
|
+
for (let r = 0; r <= t; r++) {
|
|
68
|
+
const u = t >= 10 && (r <= 1 || r >= t - 1), x = t >= 16 && Math.abs(r - Math.round(t / 3)) <= 1, m = e.x + (o.x - e.x) * r / t, p = e.y + (o.y - e.y) * r / t;
|
|
69
|
+
for (let M = 0; M < h; M++) {
|
|
70
|
+
const w = M - (h - 1) / 2, g = h >= 2 ? M === 0 ? a.light : M === h - 1 ? a.deep : n : n;
|
|
71
|
+
y(f, m + i * w, p + l * w, u ? a.deep : x && M === 0 ? a.hi : g);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function Z(f, e, o, n = 0, c = 0) {
|
|
76
|
+
const s = P(o), t = Math.max(32, Math.ceil(e * 5)), i = new C();
|
|
77
|
+
for (let l = 0; l < t; l++) {
|
|
78
|
+
const a = ((l * 64 / t + n) % 16 + 16) % 16;
|
|
79
|
+
if (a < 3) continue;
|
|
80
|
+
const h = l * Math.PI * 2 / t, r = Math.sin(h), u = a < 4 ? s.hi : r > 0.35 ? s.light : r < -0.35 ? s.deep : o, x = Math.cos(h) * e, m = c + r * e * 0.5;
|
|
81
|
+
i.set(x, m, u), r > 0.5 && i.set(x, m + 1, s.deep);
|
|
82
|
+
}
|
|
83
|
+
i.lay(f);
|
|
84
|
+
}
|
|
85
|
+
function _(f, e, o, n, c) {
|
|
86
|
+
const s = P(c);
|
|
87
|
+
for (let t = -n; t <= n; t++) {
|
|
88
|
+
const i = Math.max(1, d(n - Math.abs(t))), l = d(e - i / 2);
|
|
89
|
+
if (t > n * 0.45) {
|
|
90
|
+
k(f, l, o + t, i, s.deep);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const a = Math.floor(i / 2);
|
|
94
|
+
n < 3 || a < 1 ? k(f, l, o + t, i, c) : (k(f, l, o + t, a, s.light), k(f, l + a, o + t, i - a, c));
|
|
95
|
+
}
|
|
96
|
+
n >= 5 && y(f, e - 1, o - n + 2, s.hi);
|
|
97
|
+
}
|
|
98
|
+
function $(f, e, o, n, c = !1) {
|
|
99
|
+
for (let s = 0; s < 12; s++) {
|
|
100
|
+
const t = s * Math.PI / 6 + (c ? e * 1.8 : 0), i = o * (c ? 1 - e : e);
|
|
101
|
+
y(f, Math.cos(t) * i, -8 + Math.sin(t) * i * 0.6 - (c ? 0 : Math.sin(e * Math.PI) * 8), s % 3 ? n : J, s % 3 ? 1 : 2);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function N(f, e, o, n, c, s = !1) {
|
|
105
|
+
const t = Math.max(1, Math.round(s ? n * 0.5 : n)), i = P(c);
|
|
106
|
+
for (let l = -t; l <= t; l++) {
|
|
107
|
+
const a = d(n * Math.sqrt(Math.max(0, 1 - (l / t) ** 2)));
|
|
108
|
+
if (a <= 0) continue;
|
|
109
|
+
const h = (l + t) / (2 * t || 1);
|
|
110
|
+
k(f, e - a, o + l, a * 2, h > 0.7 && n >= 3 ? i.deep : c), n >= 3 && h < 0.35 && a >= 2 && k(f, e - a + 1, o + l, d(a * 0.6), i.light);
|
|
111
|
+
}
|
|
112
|
+
n >= 4 && y(f, e - n * 0.4, o - t * 0.55, i.hi);
|
|
113
|
+
}
|
|
114
|
+
function Q(f, e, o, n, c, s = e + 8) {
|
|
115
|
+
const t = c / 1e3, i = e + n * t + 260 * t * t;
|
|
116
|
+
return i > s && n * t + 260 * t * t > 0 ? null : { x: f + o * t, y: i };
|
|
117
|
+
}
|
|
118
|
+
function z(f, e, o, n, c) {
|
|
119
|
+
A(f, { x: e - n, y: o - n }, { x: e + n, y: o + n }, c), A(f, { x: e - n, y: o + n }, { x: e + n, y: o - n }, c);
|
|
120
|
+
}
|
|
121
|
+
function tt(f, e, o, n, c, s) {
|
|
122
|
+
const t = { x: e.x + (o.x - e.x) * n, y: e.y + (o.y - e.y) * n };
|
|
123
|
+
A(f, t, o, c, 4), A(f, t, o, s, 2);
|
|
124
|
+
}
|
|
125
|
+
function nt(f, e, o, n, c, s, t = 0, i = 0.7) {
|
|
126
|
+
if (n = Math.round(n), n < 2) return;
|
|
127
|
+
const l = P(c), a = Math.max(2, Math.round(n * 0.85)), h = i * D();
|
|
128
|
+
j();
|
|
129
|
+
const r = d(e);
|
|
130
|
+
for (let u = -a; u <= a; u++) {
|
|
131
|
+
const x = n * Math.sqrt(Math.max(0, 1 - (u / (a + 0.5)) ** 2));
|
|
132
|
+
let m = 0, p = 0, M = -1, w = 0;
|
|
133
|
+
const g = Math.ceil(x);
|
|
134
|
+
for (let I = -g; I <= g; I++) {
|
|
135
|
+
let q = -1, B = 0;
|
|
136
|
+
if (I < g) {
|
|
137
|
+
const W = x - Math.abs(I + 0.5), b = (I * 73856093 ^ u * 19349663 ^ t * 83492791) >>> 0;
|
|
138
|
+
W < 1 && b % 2 === 0 || (q = u < -a * 0.3 && I < x * 0.2 ? s : u > a * 0.4 ? l.deep : b % 9 === 0 ? l.light : c, B = W < 1 ? h * 0.6 : h);
|
|
139
|
+
}
|
|
140
|
+
if (q === M && B === w && q !== -1) {
|
|
141
|
+
p++;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
M !== -1 && f.fillStyle(S(M), w).fillRect(r + m, d(o + u), p, 1), m = I, p = 1, M = q, w = B;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function ot(f, e, o, n, c, s, t, i = !0, l = 1) {
|
|
149
|
+
const a = Math.max(2, Math.ceil(Math.abs(s - c) * n)), h = P(t);
|
|
150
|
+
l *= 2;
|
|
151
|
+
const r = new C();
|
|
152
|
+
for (let u = 0; u < l; u++) {
|
|
153
|
+
const x = n - u, m = u === 0 ? h.light : u === l - 1 ? h.deep : t;
|
|
154
|
+
for (let p = 0; p <= a; p++) {
|
|
155
|
+
const M = c + (s - c) * p / a, w = p >= a - 1 ? h.hi : l <= 2 && a >= 12 && p < a * 0.2 ? h.deep : m;
|
|
156
|
+
r.set(e + Math.cos(M) * x, o + Math.sin(M) * x * (i ? 0.5 : 1), w);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
r.lay(f);
|
|
160
|
+
}
|
|
161
|
+
function et(f, e, o, n, c = 10, s = 13154458) {
|
|
162
|
+
for (let t = 0; t < 4; t++) {
|
|
163
|
+
const i = t * 1.7 + 0.3, l = Math.round(4 * (1 - n));
|
|
164
|
+
l >= 1 && N(f, e + Math.cos(i) * c * n, o - 2 + Math.sin(i) * c * 0.4 * n - n * 4, l, t % 2 ? s : 14734524);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function st(f, e, o, n, c, s, t) {
|
|
168
|
+
for (let i = 0; i < n; i++) {
|
|
169
|
+
const l = i / n * Math.PI * 2 + 0.3, a = c * (0.6 + i * 7 % 5 * 0.1), h = Q(e, o, Math.cos(l) * a, -70 - i * 17 % 40, s, o + 6);
|
|
170
|
+
if (!h) continue;
|
|
171
|
+
const r = t[i % t.length], u = h.y + Math.sin(l) * a * 0.3 * s / 1e3;
|
|
172
|
+
i % 3 ? y(f, h.x, u, r) : (y(f, h.x, u, r, 2), y(f, h.x, u + 2, P(r).deep, 2), y(f, h.x, u, P(r).hi));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export {
|
|
176
|
+
J as WHITE,
|
|
177
|
+
ot as arc,
|
|
178
|
+
N as blob,
|
|
179
|
+
tt as dashStreak,
|
|
180
|
+
st as debris,
|
|
181
|
+
_ as diamond,
|
|
182
|
+
y as dot,
|
|
183
|
+
Q as drop,
|
|
184
|
+
et as dust,
|
|
185
|
+
k as hline,
|
|
186
|
+
Y as outlined,
|
|
187
|
+
nt as puffBlob,
|
|
188
|
+
Z as ring,
|
|
189
|
+
$ as shards,
|
|
190
|
+
d as snap,
|
|
191
|
+
A as stroke,
|
|
192
|
+
z as xMark
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=pixelPaint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelPaint.js","sources":["../../src/pixel/pixelPaint.ts"],"sourcesContent":["import { batchFor, beginOutline, capturing, currentCoverage, dithered, endOutline, fillRuns, flushBatch, grade, pixelKey, ramp, record, stageRun } from './pixelTone';\nimport { PixelLayer } from './PixelLayer';\nimport type { Graphics } from '../core/Graphics';\n\n/*\n * Pixel painting shared by every kit's effects: every shape lands on the 1px world grid — the pixel size of the\n * character, prop and tile art, so an effect never looks chunkier than the body it sits on — and is redrawn at 12\n * frames per second. Every colour is pulled into the world's palette on the way out (`grade`). Shapes shade themselves from their colour's ramp (pixelTone.ts): rings are\n * brighter on the near side, thick arcs and discs carry a light edge and a deep underside, and strokes taper. Every\n * layer thins out with an ordered dither in its last frames instead of vanishing.\n */\n\nexport type Point = { x: number; y: number };\nexport const WHITE = 0xfff4d6;\nexport const snap = (n: number) => Math.round(n);\n\n/** A `size`-px square (1 by default: one art pixel) on the world grid, graded into the world palette. */\nexport function dot(g: Graphics, x: number, y: number, color: number, size = 1): void {\n const px = snap(x);\n const py = snap(y);\n if (dithered(px, py)) return;\n const c = grade(color);\n if (capturing()) {\n for (let dy = 0; dy < size; dy++) for (let dx = 0; dx < size; dx++) record(px + dx, py + dy, c);\n return;\n }\n const held = batchFor(g);\n if (held) {\n for (let dy = 0; dy < size; dy++) stageRun(held, px, py + dy, size, c);\n return;\n }\n g.fillStyle(c, 1).fillRect(px, py, size, size);\n}\n\n/**\n * Pixels a shape plots, the last plot of a pixel winning as it would on screen, laid when the shape is done as runs of\n * one tone (`fillRuns`) instead of a rect a pixel. A dither fade drops the same pixels `dot` would, and inside an\n * outline capture they are recorded like any `dot`.\n */\nclass Plot {\n private readonly at = new Map<number, number>();\n\n set(x: number, y: number, color: number): void {\n this.at.set(pixelKey(snap(x), snap(y)), color);\n }\n\n lay(g: Graphics): void {\n if (capturing()) {\n for (const [k, c] of this.at) dot(g, (k >>> 16) - 32768, (k & 0xffff) - 32768, c);\n return;\n }\n const held = batchFor(g);\n if (held instanceof PixelLayer) {\n // straight into the layer's staging: the keys are already one a pixel\n for (const [k, c] of this.at) {\n const x = (k >>> 16) - 32768;\n const y = (k & 0xffff) - 32768;\n if (!dithered(x, y)) held.stage(x, y, 1, grade(c));\n }\n return;\n }\n const graded = new Map<number, number>();\n for (const [k, c] of this.at) if (!dithered((k >>> 16) - 32768, (k & 0xffff) - 32768)) graded.set(k, grade(c));\n fillRuns(g, graded);\n }\n}\n\n/** A horizontal run of `w` px from (x, y), one pixel tall; drawn pixel by pixel while a dither fade or outline is on. */\nexport function hline(g: Graphics, x: number, y: number, w: number, color: number): void {\n const x0 = snap(x);\n const width = snap(w);\n if (width <= 0) return;\n if (!capturing() && !dithered(x0, y) && !dithered(x0 + 1, y) && !dithered(x0 + 2, y + 1) && !dithered(x0 + 3, y + 1)) {\n const held = batchFor(g);\n if (held) {\n stageRun(held, x0, snap(y), width, grade(color));\n return;\n }\n g.fillStyle(grade(color), 1).fillRect(x0, snap(y), width, 1);\n return;\n }\n for (let i = 0; i < width; i++) dot(g, x0 + i, y, color);\n}\n\n/** Paints `draw` with a dark 1px outline round everything it drew, like the outline on character and prop sprites. */\nexport function outlined(g: Graphics, outline: number, draw: () => void): void {\n beginOutline();\n try {\n draw();\n } finally {\n endOutline(g, outline);\n }\n}\n\n/**\n * A line `width` px thick built from 1px rows: the row on one side is lit, the far row deep, and a long stroke tapers\n * to the deep tone at both ends and catches a glint a third of the way along.\n */\nexport function stroke(g: Graphics, a: Point, b: Point, color: number, width = 2): void {\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n const steps = Math.max(1, Math.ceil(len));\n const nx = len ? -(b.y - a.y) / len : 0;\n const ny = len ? (b.x - a.x) / len : 1;\n const r = ramp(color);\n const rows = Math.max(1, Math.round(width));\n for (let i = 0; i <= steps; i++) {\n const end = steps >= 10 && (i <= 1 || i >= steps - 1);\n const glint = steps >= 16 && Math.abs(i - Math.round(steps / 3)) <= 1;\n const x = a.x + ((b.x - a.x) * i) / steps;\n const y = a.y + ((b.y - a.y) * i) / steps;\n for (let k = 0; k < rows; k++) {\n const off = k - (rows - 1) / 2;\n const edge = rows >= 2 ? (k === 0 ? r.light : k === rows - 1 ? r.deep : color) : color;\n dot(g, x + nx * off, y + ny * off, end ? r.deep : glint && k === 0 ? r.hi : edge);\n }\n }\n}\n\n/** A broken ellipse of radius `r` in the ground's 2:1 perspective, lit on the near side, turning with `phase`. */\nexport function ring(g: Graphics, r: number, color: number, phase = 0, cy = 0): void {\n const tones = ramp(color);\n const n = Math.max(32, Math.ceil(r * 5));\n const plot = new Plot();\n for (let i = 0; i < n; i++) {\n const seg = ((((i * 64) / n + phase) % 16) + 16) % 16;\n if (seg < 3) continue;\n const a = (i * Math.PI * 2) / n;\n const near = Math.sin(a);\n // the near side of the ellipse is lit and a pixel thicker; the far side sinks into the deep tone\n const tone = seg < 4 ? tones.hi : near > 0.35 ? tones.light : near < -0.35 ? tones.deep : color;\n const x = Math.cos(a) * r;\n const y = cy + near * r * 0.5;\n plot.set(x, y, tone);\n if (near > 0.5) plot.set(x, y + 1, tones.deep);\n }\n plot.lay(g);\n}\n\n/** A faceted gem: light left face, base right face, deep lower tip and a glint on top once it is big enough. */\nexport function diamond(g: Graphics, x: number, y: number, r: number, color: number): void {\n const tones = ramp(color);\n for (let row = -r; row <= r; row++) {\n const width = Math.max(1, snap(r - Math.abs(row)));\n const left = snap(x - width / 2);\n if (row > r * 0.45) {\n hline(g, left, y + row, width, tones.deep);\n continue;\n }\n const half = Math.floor(width / 2);\n if (r < 3 || half < 1) hline(g, left, y + row, width, color);\n else {\n hline(g, left, y + row, half, tones.light);\n hline(g, left + half, y + row, width - half, color);\n }\n }\n if (r >= 5) dot(g, x - 1, y - r + 2, tones.hi);\n}\n\nexport function shards(g: Graphics, t: number, r: number, color: number, inward = false): void {\n for (let i = 0; i < 12; i++) {\n const a = i * Math.PI / 6 + (inward ? t * 1.8 : 0);\n const d = r * (inward ? 1 - t : t);\n dot(g, Math.cos(a) * d, -8 + Math.sin(a) * d * 0.6 - (inward ? 0 : Math.sin(t * Math.PI) * 8), i % 3 ? color : WHITE, i % 3 ? 1 : 2);\n }\n}\n\n/** A filled stepped disc of radius `r` (smoke, gas, puddles), in the ground's 2:1 perspective when `flat`. */\nexport function blob(g: Graphics, x: number, y: number, r: number, color: number, flat = false): void {\n const ry = Math.max(1, Math.round(flat ? r * 0.5 : r));\n const tones = ramp(color);\n for (let row = -ry; row <= ry; row++) {\n const half = snap(r * Math.sqrt(Math.max(0, 1 - (row / ry) ** 2)));\n if (half <= 0) continue;\n const down = (row + ry) / (2 * ry || 1);\n hline(g, x - half, y + row, half * 2, down > 0.7 && r >= 3 ? tones.deep : color);\n // a lit cap on the upper left\n if (r >= 3 && down < 0.35 && half >= 2) hline(g, x - half + 1, y + row, snap(half * 0.6), tones.light);\n }\n if (r >= 4) dot(g, x - r * 0.4, y - ry * 0.55, tones.hi);\n}\n\n/** A droplet thrown from (x, y) with velocity (vx, vy) px/s under gravity, `ms` after it left; null once it lands. */\nexport function drop(x: number, y: number, vx: number, vy: number, ms: number, ground = y + 8): Point | null {\n const t = ms / 1000;\n const py = y + vy * t + 260 * t * t;\n return py > ground && vy * t + 260 * t * t > 0 ? null : { x: x + vx * t, y: py };\n}\n\n/** A pixel X, `r` from its centre to a tip. */\nexport function xMark(g: Graphics, x: number, y: number, r: number, color: number): void {\n stroke(g, { x: x - r, y: y - r }, { x: x + r, y: y + r }, color);\n stroke(g, { x: x - r, y: y + r }, { x: x + r, y: y - r }, color);\n}\n\n/** A dash streak from `a` to `b`: a dark body with a bright core, eaten away from the start as `t` goes 0 to 1. */\nexport function dashStreak(g: Graphics, a: Point, b: Point, t: number, edge: number, core: number): void {\n const from = { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };\n stroke(g, from, b, edge, 4);\n stroke(g, from, b, core, 2);\n}\n\n/**\n * A puff of smoke or gas: a small stepped disc whose rim is dithered (every other pixel) so it reads soft, with a\n * lighter cap on its upper left. Solid discs the same size read as boulders or bushes.\n */\nexport function puffBlob(g: Graphics, x: number, y: number, r: number, body: number, light: number, frame = 0, opacity = 0.7): void {\n r = Math.round(r);\n if (r < 2) return;\n const tones = ramp(body);\n const ry = Math.max(2, Math.round(r * 0.85));\n // smoke is translucent: overlapping puffs thicken toward the middle of a cloud and the ground shows through its edge\n const alpha = opacity * currentCoverage();\n flushBatch();\n const x0 = snap(x);\n for (let row = -ry; row <= ry; row++) {\n const half = r * Math.sqrt(Math.max(0, 1 - (row / (ry + 0.5)) ** 2));\n // the same pixels as one rect each, laid as runs of one tone and alpha\n let runAt = 0;\n let runW = 0;\n let runTone = -1;\n let runAlpha = 0;\n const end = Math.ceil(half);\n for (let dx = -end; dx <= end; dx++) {\n let tone = -1;\n let a = 0;\n if (dx < end) {\n const edge = half - Math.abs(dx + 0.5);\n const noise = ((dx * 73856093) ^ (row * 19349663) ^ (frame * 83492791)) >>> 0;\n if (!(edge < 1 && noise % 2 === 0)) {\n const lit = row < -ry * 0.3 && dx < half * 0.2;\n tone = lit ? light : row > ry * 0.4 ? tones.deep : noise % 9 === 0 ? tones.light : body;\n a = edge < 1 ? alpha * 0.6 : alpha;\n }\n }\n if (tone === runTone && a === runAlpha && tone !== -1) {\n runW++;\n continue;\n }\n if (runTone !== -1) g.fillStyle(grade(runTone), runAlpha).fillRect(x0 + runAt, snap(y + row), runW, 1);\n runAt = dx;\n runW = 1;\n runTone = tone;\n runAlpha = a;\n }\n }\n}\n\n/** An arc of dots on an ellipse from angle `a0` to `a1` (flat: in the ground's 2:1 perspective), `thick` rows deep. */\nexport function arc(g: Graphics, x: number, y: number, r: number, a0: number, a1: number, color: number, flat = true, thick = 1): void {\n const steps = Math.max(2, Math.ceil(Math.abs(a1 - a0) * r));\n const tones = ramp(color);\n // `thick` counts the old 2px rows, so an arc keeps its weight; it is built from 1px rows\n thick *= 2;\n const plot = new Plot();\n for (let t = 0; t < thick; t++) {\n const rr = r - t;\n // a thick arc is lit on its outer edge and sinks to the deep tone inside; a thin one fades in from its tail\n const row = t === 0 ? tones.light : t === thick - 1 ? tones.deep : color;\n for (let i = 0; i <= steps; i++) {\n const a = a0 + ((a1 - a0) * i) / steps;\n const tone = i >= steps - 1 ? tones.hi : thick <= 2 && steps >= 12 && i < steps * 0.2 ? tones.deep : row;\n plot.set(x + Math.cos(a) * rr, y + Math.sin(a) * rr * (flat ? 0.5 : 1), tone);\n }\n }\n plot.lay(g);\n}\n\n/** Pale stepped dust puffs kicked up around (x, y) and settling over `t` 0..1. */\nexport function dust(g: Graphics, x: number, y: number, t: number, spread = 10, color = 0xc8b89a): void {\n for (let i = 0; i < 4; i++) {\n const a = i * 1.7 + 0.3;\n const size = Math.round(4 * (1 - t));\n if (size >= 1) blob(g, x + Math.cos(a) * spread * t, y - 2 + Math.sin(a) * spread * 0.4 * t - t * 4, size, i % 2 ? color : 0xe0d4bc);\n }\n}\n\n/** Pixel chunks flung out of (x, y) under gravity (rock, splinters): `ms` after the blow. */\nexport function debris(g: Graphics, x: number, y: number, count: number, speed: number, ms: number, colors: number[]): void {\n for (let i = 0; i < count; i++) {\n const a = (i / count) * Math.PI * 2 + 0.3;\n const v = speed * (0.6 + ((i * 7) % 5) * 0.1);\n const p = drop(x, y, Math.cos(a) * v, -70 - ((i * 17) % 40), ms, y + 6);\n if (!p) continue;\n const c = colors[i % colors.length]!;\n const py = p.y + (Math.sin(a) * v * 0.3 * ms) / 1000;\n if (i % 3) dot(g, p.x, py, c);\n else {\n // a chunk: body, deep underside and a glint\n dot(g, p.x, py, c, 2);\n dot(g, p.x, py + 2, ramp(c).deep, 2);\n dot(g, p.x, py, ramp(c).hi);\n }\n }\n}\n\n"],"names":["WHITE","snap","n","dot","g","x","y","color","size","px","py","dithered","c","grade","capturing","dy","dx","record","held","batchFor","stageRun","Plot","pixelKey","k","PixelLayer","graded","fillRuns","hline","w","x0","width","outlined","outline","draw","beginOutline","endOutline","stroke","a","b","len","steps","nx","ny","r","ramp","rows","i","end","glint","off","edge","ring","phase","cy","tones","plot","seg","near","tone","diamond","row","left","half","shards","t","inward","d","blob","flat","ry","down","drop","vx","vy","ms","ground","xMark","dashStreak","core","from","puffBlob","body","light","frame","opacity","alpha","currentCoverage","flushBatch","runAt","runW","runTone","runAlpha","noise","arc","a0","a1","thick","rr","dust","spread","debris","count","speed","colors","v","p"],"mappings":";;AAaO,MAAMA,IAAQ,UACRC,IAAO,CAACC,MAAc,KAAK,MAAMA,CAAC;AAGxC,SAASC,EAAIC,GAAaC,GAAWC,GAAWC,GAAeC,IAAO,GAAS;AACpF,QAAMC,IAAKR,EAAKI,CAAC,GACXK,IAAKT,EAAKK,CAAC;AACjB,MAAIK,EAASF,GAAIC,CAAE,EAAG;AACtB,QAAME,IAAIC,EAAMN,CAAK;AACrB,MAAIO,KAAa;AACf,aAASC,IAAK,GAAGA,IAAKP,GAAMO,cAAeC,IAAK,GAAGA,IAAKR,GAAMQ,IAAM,CAAAC,EAAOR,IAAKO,GAAIN,IAAKK,GAAIH,CAAC;AAC9F;AAAA,EACF;AACA,QAAMM,IAAOC,EAASf,CAAC;AACvB,MAAIc,GAAM;AACR,aAASH,IAAK,GAAGA,IAAKP,GAAMO,IAAM,CAAAK,EAASF,GAAMT,GAAIC,IAAKK,GAAIP,GAAMI,CAAC;AACrE;AAAA,EACF;AACA,EAAAR,EAAE,UAAUQ,GAAG,CAAC,EAAE,SAASH,GAAIC,GAAIF,GAAMA,CAAI;AAC/C;AAOA,MAAMa,EAAK;AAAA,EACQ,yBAAS,IAAA;AAAA,EAE1B,IAAIhB,GAAWC,GAAWC,GAAqB;AAC7C,SAAK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GACpBT,EAAIC,GAAGqG,EAAE,GAAG/F,IAAK,GAAGkC,EAAKhC,CAAC,EAAE,MAAM,CAAC,GACnCT,EAAIC,GAAGqG,EAAE,GAAG/F,GAAIkC,EAAKhC,CAAC,EAAE,EAAE;AAAA,EAE9B;AACF;"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { PixelLayer as y } from "./PixelLayer.js";
|
|
2
|
+
const R = /* @__PURE__ */ new Map();
|
|
3
|
+
function S(t) {
|
|
4
|
+
const n = (t >> 16 & 255) / 255, e = (t >> 8 & 255) / 255, o = (t & 255) / 255, r = Math.max(n, e, o), c = Math.min(n, e, o), s = (r + c) / 2;
|
|
5
|
+
if (r === c) return [0, 0, s];
|
|
6
|
+
const i = r - c, u = s > 0.5 ? i / (2 - r - c) : i / (r + c);
|
|
7
|
+
return [(r === n ? (e - o) / i + (e < o ? 6 : 0) : r === e ? (o - n) / i + 2 : (n - e) / i + 4) / 6, u, s];
|
|
8
|
+
}
|
|
9
|
+
function M(t, n, e) {
|
|
10
|
+
const o = (i, u, h) => {
|
|
11
|
+
const m = (h + 1) % 1;
|
|
12
|
+
return m < 0.16666666666666666 ? i + (u - i) * 6 * m : m < 0.5 ? u : m < 0.6666666666666666 ? i + (u - i) * (0.6666666666666666 - m) * 6 : i;
|
|
13
|
+
}, r = e < 0.5 ? e * (1 + n) : e + n - e * n, c = 2 * e - r, s = (i) => Math.round(Math.max(0, Math.min(1, n === 0 ? e : o(c, r, i))) * 255);
|
|
14
|
+
return s(t + 1 / 3) << 16 | s(t) << 8 | s(t - 1 / 3);
|
|
15
|
+
}
|
|
16
|
+
function g(t, n, e) {
|
|
17
|
+
let o = n - t;
|
|
18
|
+
return o > 0.5 && (o -= 1), o < -0.5 && (o += 1), (t + Math.sign(o) * Math.min(Math.abs(o), e) + 1) % 1;
|
|
19
|
+
}
|
|
20
|
+
const v = /* @__PURE__ */ new Map();
|
|
21
|
+
function P(t) {
|
|
22
|
+
const n = Symbol.iterator in t ? t : Object.entries(t).map(([e, o]) => [Number(e), o]);
|
|
23
|
+
for (const [e, o] of n) v.set(e, { ...o, base: e });
|
|
24
|
+
}
|
|
25
|
+
function G(t) {
|
|
26
|
+
return v.get(t) ?? H(t);
|
|
27
|
+
}
|
|
28
|
+
function H(t) {
|
|
29
|
+
let n = R.get(t);
|
|
30
|
+
if (n) return n;
|
|
31
|
+
const [e, o, r] = S(t), c = g(e, 0.72, 0.06), s = g(e, 0.14, 0.04);
|
|
32
|
+
return n = {
|
|
33
|
+
shade: M(c, Math.min(1, o * 0.85), Math.max(0.08, r * 0.38)),
|
|
34
|
+
deep: M(g(e, 0.72, 0.03), o, Math.max(0.14, r * 0.66)),
|
|
35
|
+
base: t,
|
|
36
|
+
light: M(s, o * 0.9, Math.min(0.9, r + (1 - r) * 0.45)),
|
|
37
|
+
hi: M(s, o * 0.5, Math.min(0.97, r + (1 - r) * 0.8))
|
|
38
|
+
}, R.set(t, n), n;
|
|
39
|
+
}
|
|
40
|
+
const k = /* @__PURE__ */ new Map();
|
|
41
|
+
function C(t) {
|
|
42
|
+
let n = k.get(t);
|
|
43
|
+
if (n !== void 0) return n;
|
|
44
|
+
const [e, o, r] = S(t), c = r > 0.82 ? 0.82 + (r - 0.82) * 0.55 : r;
|
|
45
|
+
return n = M(r > 0.82 ? g(e, 0.12, 0.05) : e, o * (r > 0.82 ? 0.55 : 0.74), c * 0.97), k.set(t, n), n;
|
|
46
|
+
}
|
|
47
|
+
let d = null;
|
|
48
|
+
const b = (t, n) => t + 32768 << 16 | n + 32768 & 65535;
|
|
49
|
+
function N() {
|
|
50
|
+
return d;
|
|
51
|
+
}
|
|
52
|
+
const w = [1, 0, -1, 0, 0, 1, 0, -1];
|
|
53
|
+
function Y() {
|
|
54
|
+
d = /* @__PURE__ */ new Map();
|
|
55
|
+
}
|
|
56
|
+
function j(t, n) {
|
|
57
|
+
const e = d;
|
|
58
|
+
if (d = null, !e) return;
|
|
59
|
+
const o = /* @__PURE__ */ new Set();
|
|
60
|
+
for (const c of e.keys()) {
|
|
61
|
+
const s = (c >>> 16) - 32768, i = (c & 65535) - 32768;
|
|
62
|
+
for (let u = 0; u < 8; u += 2) {
|
|
63
|
+
const h = b(s + w[u], i + w[u + 1]);
|
|
64
|
+
e.has(h) || o.add(h);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const r = C(n);
|
|
68
|
+
x(t, new Map([...o].map((c) => [c, r]))), x(t, e);
|
|
69
|
+
}
|
|
70
|
+
function x(t, n) {
|
|
71
|
+
if (l !== null && t === l) {
|
|
72
|
+
if (a) for (const [e, o] of n) a.stage((e >>> 16) - 32768, (e & 65535) - 32768, 1, o);
|
|
73
|
+
else for (const [e, o] of n) f.set(e, o);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
B(t, n);
|
|
77
|
+
}
|
|
78
|
+
let f = null, a = null, l = null;
|
|
79
|
+
const A = [];
|
|
80
|
+
function z(t) {
|
|
81
|
+
A.push({ batch: f, direct: a, g: l }), t instanceof y ? (f = null, a = t) : (f = /* @__PURE__ */ new Map(), a = null), l = t;
|
|
82
|
+
}
|
|
83
|
+
function F() {
|
|
84
|
+
D();
|
|
85
|
+
const t = A.pop();
|
|
86
|
+
f = t?.batch ?? null, a = t?.direct ?? null, l = t?.g ?? null;
|
|
87
|
+
}
|
|
88
|
+
function I(t) {
|
|
89
|
+
return l === null || t !== l ? null : a ?? f;
|
|
90
|
+
}
|
|
91
|
+
function K(t, n, e, o, r) {
|
|
92
|
+
if (t instanceof y) {
|
|
93
|
+
t.stage(n, e, o, r);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
for (let c = 0; c < o; c++) t.set(b(n + c, e), r);
|
|
97
|
+
}
|
|
98
|
+
function D() {
|
|
99
|
+
if (a) {
|
|
100
|
+
a.commit();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!f || !l || f.size === 0) return;
|
|
104
|
+
const t = f;
|
|
105
|
+
f = /* @__PURE__ */ new Map(), B(l, t);
|
|
106
|
+
}
|
|
107
|
+
function B(t, n) {
|
|
108
|
+
if (t instanceof y) {
|
|
109
|
+
for (const [i, u] of n) t.stage((i >>> 16) - 32768, (i & 65535) - 32768, 1, u);
|
|
110
|
+
t.commit();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const e = [...n.keys()].sort((i, u) => (i & 65535) - (u & 65535) || (i >>> 16) - (u >>> 16));
|
|
114
|
+
let o = 0, r = 0, c = 0, s = -1;
|
|
115
|
+
for (const i of e) {
|
|
116
|
+
const u = (i >>> 16) - 32768, h = (i & 65535) - 32768, m = n.get(i);
|
|
117
|
+
if (c > 0 && h === r && u === o + c && m === s) {
|
|
118
|
+
c++;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
c > 0 && t.fillStyle(s, 1).fillRect(o, r, c, 1), o = u, r = h, c = 1, s = m;
|
|
122
|
+
}
|
|
123
|
+
c > 0 && t.fillStyle(s, 1).fillRect(o, r, c, 1);
|
|
124
|
+
}
|
|
125
|
+
function L(t, n) {
|
|
126
|
+
return b(t, n);
|
|
127
|
+
}
|
|
128
|
+
function T(t, n, e) {
|
|
129
|
+
d?.set(b(t, n), e);
|
|
130
|
+
}
|
|
131
|
+
const E = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5];
|
|
132
|
+
let p = 1;
|
|
133
|
+
function W(t) {
|
|
134
|
+
p = t;
|
|
135
|
+
}
|
|
136
|
+
function X() {
|
|
137
|
+
return p;
|
|
138
|
+
}
|
|
139
|
+
function _(t, n) {
|
|
140
|
+
if (p >= 1) return !1;
|
|
141
|
+
const e = (Math.round(t) & 3) >>> 0, o = (Math.round(n) & 3) >>> 0;
|
|
142
|
+
return E[o * 4 + e] / 16 >= p;
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
I as batchFor,
|
|
146
|
+
z as beginBatch,
|
|
147
|
+
Y as beginOutline,
|
|
148
|
+
N as capturing,
|
|
149
|
+
X as currentCoverage,
|
|
150
|
+
H as derivedRamp,
|
|
151
|
+
_ as dithered,
|
|
152
|
+
F as endBatch,
|
|
153
|
+
j as endOutline,
|
|
154
|
+
x as fillRuns,
|
|
155
|
+
D as flushBatch,
|
|
156
|
+
C as grade,
|
|
157
|
+
L as pixelKey,
|
|
158
|
+
G as ramp,
|
|
159
|
+
T as record,
|
|
160
|
+
P as registerHandRamps,
|
|
161
|
+
W as setCoverage,
|
|
162
|
+
K as stageRun
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=pixelTone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelTone.js","sources":["../../src/pixel/pixelTone.ts"],"sourcesContent":["import type { Graphics } from '../core/Graphics';\nimport { PixelLayer } from './PixelLayer';\n\n/*\n * Colour ramps and ordered dithering for the pixel effects. A ramp turns one colour into five tones the way pixel\n * artists shade: shadows shift toward blue-violet and lose saturation, highlights shift toward yellow. The dither fade\n * drops pixels in a 4x4 Bayer order, so an effect thins out pixel by pixel instead of vanishing in one frame.\n */\n\nexport interface Ramp {\n /** Darkest: under-shade and outline pixels. */\n shade: number;\n deep: number;\n base: number;\n light: number;\n /** Near-white glint. */\n hi: number;\n}\n\nconst RAMPS = new Map<number, Ramp>();\n\nfunction toHsl(c: number): [number, number, number] {\n const r = ((c >> 16) & 255) / 255;\n const g = ((c >> 8) & 255) / 255;\n const b = (c & 255) / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n if (max === min) return [0, 0, l];\n const d = max - min;\n const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n const h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;\n return [h / 6, s, l];\n}\n\nfunction fromHsl(h: number, s: number, l: number): number {\n const hue = (p: number, q: number, t: number) => {\n const u = (t + 1) % 1;\n if (u < 1 / 6) return p + (q - p) * 6 * u;\n if (u < 1 / 2) return q;\n if (u < 2 / 3) return p + (q - p) * (2 / 3 - u) * 6;\n return p;\n };\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n const ch = (t: number) => Math.round(Math.max(0, Math.min(1, s === 0 ? l : hue(p, q, t))) * 255);\n return (ch(h + 1 / 3) << 16) | (ch(h) << 8) | ch(h - 1 / 3);\n}\n\n/** Hue moved `amount` (turns) toward `target`, the short way round. */\nfunction drift(h: number, target: number, amount: number): number {\n let d = target - h;\n if (d > 0.5) d -= 1;\n if (d < -0.5) d += 1;\n return (h + Math.sign(d) * Math.min(Math.abs(d), amount) + 1) % 1;\n}\n\n/**\n * Ramps picked by hand for the colours a game's effects are built on (`registerHandRamps`): an effect paints its\n * crescents, rings and trails in one material colour and lets the shapes shade themselves, so a hand ramp is how a\n * game's own colours get shades better than the formula's. `ramp` of one of these colours returns its hand ramp;\n * every other colour gets `derivedRamp`. `base` is always the colour itself.\n */\nconst HAND = new Map<number, Ramp>();\n\n/** Gives these colours ramps picked by hand (darkest `shade` … brightest `hi`); a colour registered again is replaced. */\nexport function registerHandRamps(ramps: Iterable<readonly [number, Omit<Ramp, 'base'>]> | Record<number, Omit<Ramp, 'base'>>): void {\n const entries = Symbol.iterator in ramps ? ramps : Object.entries(ramps).map(([c, r]) => [Number(c), r] as const);\n for (const [c, r] of entries) HAND.set(c, { ...r, base: c });\n}\n\nexport function ramp(color: number): Ramp {\n return HAND.get(color) ?? derivedRamp(color);\n}\n\n/** The formula's five tones for any colour: shadows cool and desaturate, highlights warm. */\nexport function derivedRamp(color: number): Ramp {\n let r = RAMPS.get(color);\n if (r) return r;\n const [h, s, l] = toHsl(color);\n const cool = drift(h, 0.72, 0.06);\n const warm = drift(h, 0.14, 0.04);\n r = {\n shade: fromHsl(cool, Math.min(1, s * 0.85), Math.max(0.08, l * 0.38)),\n deep: fromHsl(drift(h, 0.72, 0.03), s, Math.max(0.14, l * 0.66)),\n base: color,\n light: fromHsl(warm, s * 0.9, Math.min(0.9, l + (1 - l) * 0.45)),\n hi: fromHsl(warm, s * 0.5, Math.min(0.97, l + (1 - l) * 0.8)),\n };\n RAMPS.set(color, r);\n return r;\n}\n\nconst GRADED = new Map<number, number>();\n\n/**\n * The colour a pixel is actually painted with: effects are authored in bright, saturated colours, and this pulls them\n * into the world's palette (muted earth, grass and wood) — saturation down by a quarter, near-whites toned down and\n * warmed, so an effect sits in the scene instead of glowing on top of it. Glints keep most of their lift.\n */\nexport function grade(color: number): number {\n let out = GRADED.get(color);\n if (out !== undefined) return out;\n const [h, s, l] = toHsl(color);\n const lift = l > 0.82 ? 0.82 + (l - 0.82) * 0.55 : l;\n out = fromHsl(l > 0.82 ? drift(h, 0.12, 0.05) : h, s * (l > 0.82 ? 0.55 : 0.74), lift * 0.97);\n GRADED.set(color, out);\n return out;\n}\n\n/*\n * Outline capture: while one is open, `dot` and `hline` record pixels instead of painting them, and `endOutline`\n * paints a dark 1px rim round the recorded silhouette before the pixels themselves — the same outline the character\n * and prop sprites carry, for effects that have a shape (a shield, a skull, a flask, a bolt).\n */\nlet capture: Map<number, number> | null = null;\nconst key = (x: number, y: number) => ((x + 32768) << 16) | ((y + 32768) & 0xffff);\n\nexport function capturing(): Map<number, number> | null {\n return capture;\n}\n\n/** The four sides a rim pixel may lie on, as dx, dy pairs. */\nconst RIM_STEPS = [1, 0, -1, 0, 0, 1, 0, -1];\n\nexport function beginOutline(): void {\n capture = new Map();\n}\n\nexport function endOutline(g: Graphics, outline: number): void {\n const pixels = capture;\n capture = null;\n if (!pixels) return;\n // each rim pixel once, however many silhouette pixels it touches\n const rim = new Set<number>();\n for (const k of pixels.keys()) {\n const x = (k >>> 16) - 32768;\n const y = (k & 0xffff) - 32768;\n for (let i = 0; i < 8; i += 2) {\n const n = key(x + RIM_STEPS[i]!, y + RIM_STEPS[i + 1]!);\n if (!pixels.has(n)) rim.add(n);\n }\n }\n const ink = grade(outline);\n fillRuns(g, new Map([...rim].map((k) => [k, ink])));\n fillRuns(g, pixels);\n}\n\n/**\n * Lays pixels (keyed by `key`, each with its colour already graded) row by row, one rect for every run of one colour:\n * the same pixels as one rect each, at a fraction of the rects (single-pixel rects ran to 5,000–9,000 a frame for one\n * big ring or smoke, enough to be felt as lag).\n */\nexport function fillRuns(g: Graphics, pixels: Map<number, number>): void {\n if (batchG !== null && g === batchG) {\n if (direct) for (const [k, c] of pixels) direct.stage((k >>> 16) - 32768, (k & 0xffff) - 32768, 1, c);\n else for (const [k, c] of pixels) batch!.set(k, c);\n return;\n }\n layRuns(g, pixels);\n}\n\n/*\n * A frame's batch (`beginBatch` / `endBatch`): while one is open every solid pixel `dot`, `hline` and `fillRuns` paint goes into it,\n * the last write of a pixel winning as it would on screen, and it is laid as runs when the frame is done — so an\n * effect that plots a pixel at a time costs a rect a run, not a rect a pixel. A translucent fill (smoke, a heat wash)\n * calls `flushBatch` first, so what was painted before it stays under it.\n *\n * On a `PixelLayer` the batch is the layer's own staging: each pixel goes\n * straight into its list in the order painted and `commit` lays them, the later winning — the same pixels the map,\n * its sort and its runs gave, without them. Any other Graphics keeps the map.\n */\nlet batch: Map<number, number> | null = null;\nlet direct: PixelLayer | null = null;\nlet batchG: Graphics | null = null;\n/** Batches opened under this one (a layer painted from inside another's paint), each laid and closed on its own. */\nconst outer: { batch: Map<number, number> | null; direct: PixelLayer | null; g: Graphics | null }[] = [];\n\nexport function beginBatch(g: Graphics): void {\n outer.push({ batch, direct, g: batchG });\n if (g instanceof PixelLayer) {\n batch = null;\n direct = g;\n } else {\n batch = new Map();\n direct = null;\n }\n batchG = g;\n}\n\nexport function endBatch(): void {\n flushBatch();\n const was = outer.pop();\n batch = was?.batch ?? null;\n direct = was?.direct ?? null;\n batchG = was?.g ?? null;\n}\n\n/**\n * Where a solid pixel painted on `g` goes while its batch is open: the layer's staging, the batch's map, or nowhere\n * (paint it now). `stagePixel` writes into whichever it is.\n */\nexport function batchFor(g: Graphics): Map<number, number> | PixelLayer | null {\n if (batchG === null || g !== batchG) return null;\n return direct ?? batch;\n}\n\n/** Writes a solid run of `w` pixels at (x, y) into what `batchFor` returned. */\nexport function stageRun(held: Map<number, number> | PixelLayer, x: number, y: number, w: number, color: number): void {\n if (held instanceof PixelLayer) {\n held.stage(x, y, w, color);\n return;\n }\n for (let i = 0; i < w; i++) held.set(key(x + i, y), color);\n}\n\n/** Lays what the batch holds now, so a translucent fill that follows lies over it. */\nexport function flushBatch(): void {\n if (direct) {\n direct.commit();\n return;\n }\n if (!batch || !batchG || batch.size === 0) return;\n const held = batch;\n batch = new Map();\n layRuns(batchG, held);\n}\n\nfunction layRuns(g: Graphics, pixels: Map<number, number>): void {\n if (g instanceof PixelLayer) {\n // the layer lays its own runs; nothing between here and its commit is drawn\n for (const [k, c] of pixels) g.stage((k >>> 16) - 32768, (k & 0xffff) - 32768, 1, c);\n g.commit();\n return;\n }\n const keys = [...pixels.keys()].sort((a, b) => (a & 0xffff) - (b & 0xffff) || (a >>> 16) - (b >>> 16));\n let runX = 0;\n let runY = 0;\n let runW = 0;\n let runC = -1;\n for (const k of keys) {\n const x = (k >>> 16) - 32768;\n const y = (k & 0xffff) - 32768;\n const c = pixels.get(k)!;\n if (runW > 0 && y === runY && x === runX + runW && c === runC) {\n runW++;\n continue;\n }\n if (runW > 0) g.fillStyle(runC, 1).fillRect(runX, runY, runW, 1);\n runX = x;\n runY = y;\n runW = 1;\n runC = c;\n }\n if (runW > 0) g.fillStyle(runC, 1).fillRect(runX, runY, runW, 1);\n}\n\n/** The key `capturing()` and `fillRuns` file a world pixel under. */\nexport function pixelKey(x: number, y: number): number {\n return key(x, y);\n}\n\nexport function record(x: number, y: number, color: number): void {\n capture?.set(key(x, y), color);\n}\n\nconst BAYER = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5];\n\n/** 1 draws every pixel, 0 none; set around each paint so every shape thins out together. */\nlet coverage = 1;\n\nexport function setCoverage(value: number): void {\n coverage = value;\n}\n\n/** The current dither fade (1 while nothing fades), for translucent fills that fade with their layer. */\nexport function currentCoverage(): number {\n return coverage;\n}\n\n/** Whether the world pixel at (x, y) is dropped by the current dither fade. */\nexport function dithered(x: number, y: number): boolean {\n if (coverage >= 1) return false;\n const cx = (Math.round(x) & 3) >>> 0;\n const cy = (Math.round(y) & 3) >>> 0;\n return BAYER[cy * 4 + cx]! / 16 >= coverage;\n}\n"],"names":["RAMPS","toHsl","c","r","g","b","max","min","l","d","s","fromHsl","h","hue","p","q","t","u","ch","drift","target","amount","HAND","registerHandRamps","ramps","entries","ramp","color","derivedRamp","cool","warm","GRADED","grade","out","lift","capture","key","x","y","capturing","RIM_STEPS","beginOutline","endOutline","outline","pixels","rim","k","i","n","ink","fillRuns","batchG","direct","batch","layRuns","outer","beginBatch","PixelLayer","endBatch","flushBatch","was","batchFor","stageRun","held","w","keys","a","runX","runY","runW","runC","pixelKey","record","BAYER","coverage","setCoverage","value","currentCoverage","dithered","cx","cy"],"mappings":";AAmBA,MAAMA,wBAAY,IAAA;AAElB,SAASC,EAAMC,GAAqC;AAClD,QAAMC,KAAMD,KAAK,KAAM,OAAO,KACxBE,KAAMF,KAAK,IAAK,OAAO,KACvBG,KAAKH,IAAI,OAAO,KAChBI,IAAM,KAAK,IAAIH,GAAGC,GAAGC,CAAC,GACtBE,IAAM,KAAK,IAAIJ,GAAGC,GAAGC,CAAC,GACtBG,KAAKF,IAAMC,KAAO;AACxB,MAAID,MAAQC,EAAK,QAAO,CAAC,GAAG,GAAGC,CAAC;AAChC,QAAMC,IAAIH,IAAMC,GACVG,IAAIF,IAAI,MAAMC,KAAK,IAAIH,IAAMC,KAAOE,KAAKH,IAAMC;AAErD,SAAO,EADGD,MAAQH,KAAKC,IAAIC,KAAKI,KAAKL,IAAIC,IAAI,IAAI,KAAKC,MAAQF,KAAKC,IAAIF,KAAKM,IAAI,KAAKN,IAAIC,KAAKK,IAAI,KACtF,GAAGC,GAAGF,CAAC;AACrB;AAEA,SAASG,EAAQC,GAAWF,GAAWF,GAAmB;AACxD,Q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AM1C,CAAC,IAAI,OAAO;AACnC,SAAOmC,EAAMO,IAAK,IAAID,CAAE,IAAK,MAAML;AACrC;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { P as d } from "./palette.js";
|
|
2
|
+
import { rgba as h } from "./pixel.js";
|
|
3
|
+
import { outlineOf as p, hueShade as m } from "./ramp.js";
|
|
4
|
+
function S(e, f, i) {
|
|
5
|
+
return { canvas: e.toCanvas(), anchorX: f, anchorY: i };
|
|
6
|
+
}
|
|
7
|
+
function b(e, f = d.outline) {
|
|
8
|
+
const { w: i, h: c } = e, a = new Uint8Array(i * c);
|
|
9
|
+
for (let t = 0; t < i * c; t++) a[t] = e.data[t] >>> 24 === 255 ? 1 : 0;
|
|
10
|
+
const r = (t, o) => t >= 0 && o >= 0 && t < i && o < c && a[o * i + t] === 1;
|
|
11
|
+
for (let t = 0; t < c; t++)
|
|
12
|
+
for (let o = 0; o < i; o++) {
|
|
13
|
+
if (a[t * i + o]) continue;
|
|
14
|
+
const n = r(o, t - 1), l = r(o - 1, t), s = r(o + 1, t), u = r(o, t + 1);
|
|
15
|
+
(n || l || s || u) && e.px(o, t, n || l ? f : p(e.get(s ? o + 1 : o, s ? t : t + 1)));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function v(e, f, i, c, a, r = w, t = M) {
|
|
19
|
+
for (let o = Math.floor(i - a); o <= Math.ceil(i + a); o++)
|
|
20
|
+
for (let n = Math.floor(f - c); n <= Math.ceil(f + c); n++) {
|
|
21
|
+
if (!e.inBounds(n, o) || e.alphaAt(n, o)) continue;
|
|
22
|
+
const l = (n + 0.5 - f) / c, s = (o + 0.5 - i) / a, u = l * l + s * s;
|
|
23
|
+
u <= 0.55 ? e.px(n, o, r) : u <= 1 && e.px(n, o, t);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const w = h(26, 22, 44, 78), M = h(26, 22, 44, 40);
|
|
27
|
+
function B(e, f, i, c, a, r, t) {
|
|
28
|
+
for (let o = i; o < i + a; o++)
|
|
29
|
+
for (let n = f; n < f + c; n++) {
|
|
30
|
+
if (!e.inBounds(n, o)) continue;
|
|
31
|
+
const l = e.get(n, o);
|
|
32
|
+
!(l >>> 24) || t && !t(n, o) || e.px(n, o, m(l, r, "shadow"));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
S as art,
|
|
37
|
+
v as groundShadow,
|
|
38
|
+
b as litOutline,
|
|
39
|
+
B as shadeBox
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=propKit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propKit.js","sources":["../../src/pixel/propKit.ts"],"sourcesContent":["import { P } from './palette';\nimport { type Color, PixelGrid, rgba } from './pixel';\nimport { hueShade, outlineOf } from './ramp';\n\n/*\n * Pieces for painting map props (trees, rocks, buildings) in code. A prop is anchored at the bottom-centre of its tile\n * footprint: `anchorX/anchorY` are pixel coordinates inside its canvas.\n */\n\nexport interface PropArt {\n canvas: HTMLCanvasElement;\n anchorX: number;\n anchorY: number;\n}\n\nexport function art(g: PixelGrid, anchorX: number, anchorY: number): PropArt {\n return { canvas: g.toCanvas(), anchorX, anchorY };\n}\n\n/**\n * The selective outline a prop takes, lit from the upper left like the map: the same ring a plain outline lays, but\n * full dark only where the silhouette meets the ground (under it) and on its shadow side (the right); along the top\n * and the left it is the darkest tone of the fill it borders (`outlineOf`), so a lit edge reads as the thing's own\n * shade rather than a sticker's line. Translucent pixels (a cast\n * shadow on the ground) are not part of the silhouette.\n */\nexport function litOutline(g: PixelGrid, dark: Color = P.outline): void {\n const { w, h } = g;\n const on = new Uint8Array(w * h);\n for (let i = 0; i < w * h; i++) on[i] = g.data[i]! >>> 24 === 255 ? 1 : 0;\n const at = (x: number, y: number) => x >= 0 && y >= 0 && x < w && y < h && on[y * w + x] === 1;\n for (let y = 0; y < h; y++)\n for (let x = 0; x < w; x++) {\n if (on[y * w + x]) continue;\n const above = at(x, y - 1);\n const left = at(x - 1, y);\n const right = at(x + 1, y);\n const below = at(x, y + 1);\n if (!(above || left || right || below)) continue;\n g.px(x, y, above || left ? dark : outlineOf(g.get(right ? x + 1 : x, right ? y : y + 1)));\n }\n}\n\n/**\n * A soft shadow thrown down and to the right onto the ground, laid only on empty pixels (call it after `litOutline`,\n * or the outline would ring the shadow): a darker `core` and a fainter `rim`, by default a translucent violet.\n */\nexport function groundShadow(g: PixelGrid, cx: number, cy: number, rx: number, ry: number, core: Color = SHADOW_CORE, rim: Color = SHADOW_RIM): void {\n for (let y = Math.floor(cy - ry); y <= Math.ceil(cy + ry); y++)\n for (let x = Math.floor(cx - rx); x <= Math.ceil(cx + rx); x++) {\n if (!g.inBounds(x, y) || g.alphaAt(x, y)) continue;\n const dx = (x + 0.5 - cx) / rx;\n const dy = (y + 0.5 - cy) / ry;\n const d = dx * dx + dy * dy;\n if (d <= 0.55) g.px(x, y, core);\n else if (d <= 1) g.px(x, y, rim);\n }\n}\n\nconst SHADOW_CORE = rgba(26, 22, 44, 78);\nconst SHADOW_RIM = rgba(26, 22, 44, 40);\n/*\n * ── Ramp-shaded pieces ──\n * `shadeBox` shades with hue-shifted ramps (`ramp.ts`) instead of `shade`; with `litOutline` above, a prop painted\n * with them looks like rig-drawn people standing next to it.\n */\n\n/**\n * Moves every opaque pixel of a box one step into shadow (or, with `f > 1`, into light) along its own hue: the eave's\n * shadow on a wall, the dark side of a chimney, a porch's shade. `mask` limits it to some pixels of the box.\n */\nexport function shadeBox(g: PixelGrid, x: number, y: number, w: number, h: number, f: number, mask?: (x: number, y: number) => boolean): void {\n for (let yy = y; yy < y + h; yy++)\n for (let xx = x; xx < x + w; xx++) {\n if (!g.inBounds(xx, yy)) continue;\n const c = g.get(xx, yy);\n if (!(c >>> 24) || (mask && !mask(xx, yy))) continue;\n g.px(xx, yy, hueShade(c, f, 'shadow'));\n }\n}\n"],"names":["art","g","anchorX","anchorY","litOutline","dark","P","w","h","on","i","at","x","y","above","left","right","below","outlineOf","groundShadow","cx","cy","rx","ry","core","SHADOW_CORE","rim","SHADOW_RIM","dx","dy","d","rgba","shadeBox","f","mask","yy","xx","c","hueShade"],"mappings":";;;AAeO,SAASA,EAAIC,GAAcC,GAAiBC,GAA0B;AAC3E,SAAO,EAAE,QAAQF,EAAE,SAAA,GAAY,SAAAC,GAAS,SAAAC,EAAA;AAC1C;AASO,SAASC,EAAWH,GAAcI,IAAcC,EAAE,SAAe;AACtE,QAAM,EAAE,GAAAC,GAAG,GAAAC,EAAA,IAAMP,GACXQ,IAAK,IAAI,WAAWF,IAAIC,CAAC;AAC/B,WAASE,IAAI,GAAGA,IAAIH,IAAIC,GAAGE,IAAK,CAAAD,EAAGC,CAAC,IAAIT,EAAE,KAAKS,CAAC,MAAO,OAAO,MAAM,IAAI;AACxE,QAAMC,IAAK,CAACC,GAAWC,MAAcD,KAAK,KAAKC,KAAK,KAAKD,IAAIL,KAAKM,IAAIL,KAAKC,EAAGI,IAAIN,IAAIK,CAAC,MAAM;AAC7F,WAASC,IAAI,GAAGA,IAAIL,GAAGK;AACrB,aAASD,IAAI,GAAGA,IAAIL,GAAGK,KAAK;AAC1B,UAAIH,EAAGI,IAAIN,IAAIK,CAAC,EAAG;AACnB,YAAME,IAAQH,EAAGC,GAAGC,IAAI,CAAC,GACnBE,IAAOJ,EAAGC,IAAI,GAAGC,CAAC,GAClBG,IAAQL,EAAGC,IAAI,GAAGC,CAAC,GACnBI,IAAQN,EAAGC,GAAGC,IAAI,CAAC;AACzB,OAAMC,KAASC,KAAQC,KAASC,MAChChB,EAAE,GAAGW,GAAGC,GAAGC,KAASC,IAAOV,IAAOa,EAAUjB,EAAE,IAAIe,IAAQJ,IAAI,IAAIA,GAAGI,IAAQH,IAAIA,IAAI,CAAC,CAAC,CAAC;AAAA,IAC1F;AACJ;AAMO,SAASM,EAAalB,GAAcmB,GAAYC,GAAYC,GAAYC,GAAYC,IAAcC,GAAaC,IAAaC,GAAkB;AACnJ,WAASd,IAAI,K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