excalibur 0.28.3 → 0.28.4
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/.gitattributes +63 -63
- package/CHANGELOG.md +2003 -1955
- package/LICENSE.md +25 -25
- package/README.md +134 -134
- package/STYLEGUIDE.md +136 -136
- package/build/dist/Actions/Action/ActionSequence.js +31 -0
- package/build/dist/Actions/Action/ActionSequence.js.map +1 -0
- package/build/dist/Actions/Action/Blink.js +54 -0
- package/build/dist/Actions/Action/Blink.js.map +1 -0
- package/build/dist/Actions/Action/CallMethod.js +21 -0
- package/build/dist/Actions/Action/CallMethod.js.map +1 -0
- package/build/dist/Actions/Action/Delay.js +26 -0
- package/build/dist/Actions/Action/Delay.js.map +1 -0
- package/build/dist/Actions/Action/Die.js +22 -0
- package/build/dist/Actions/Action/Die.js.map +1 -0
- package/build/dist/Actions/Action/EaseBy.js +70 -0
- package/build/dist/Actions/Action/EaseBy.js.map +1 -0
- package/build/dist/Actions/Action/EaseTo.js +69 -0
- package/build/dist/Actions/Action/EaseTo.js.map +1 -0
- package/build/dist/Actions/Action/Fade.js +48 -0
- package/build/dist/Actions/Action/Fade.js.map +1 -0
- package/build/dist/Actions/Action/Follow.js +56 -0
- package/build/dist/Actions/Action/Follow.js.map +1 -0
- package/build/dist/Actions/Action/Meet.js +54 -0
- package/build/dist/Actions/Action/Meet.js.map +1 -0
- package/build/dist/Actions/Action/MoveBy.js +48 -0
- package/build/dist/Actions/Action/MoveBy.js.map +1 -0
- package/build/dist/Actions/Action/MoveTo.js +41 -0
- package/build/dist/Actions/Action/MoveTo.js.map +1 -0
- package/build/dist/Actions/Action/ParallelActions.js +23 -0
- package/build/dist/Actions/Action/ParallelActions.js.map +1 -0
- package/build/dist/Actions/Action/Repeat.js +31 -0
- package/build/dist/Actions/Action/Repeat.js.map +1 -0
- package/build/dist/Actions/Action/RepeatForever.js +37 -0
- package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
- package/build/dist/Actions/Action/RotateBy.js +95 -0
- package/build/dist/Actions/Action/RotateBy.js.map +1 -0
- package/build/dist/Actions/Action/RotateTo.js +91 -0
- package/build/dist/Actions/Action/RotateTo.js.map +1 -0
- package/build/dist/Actions/Action/ScaleBy.js +46 -0
- package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
- package/build/dist/Actions/Action/ScaleTo.js +58 -0
- package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
- package/build/dist/Actions/Action.js +2 -0
- package/build/dist/Actions/Action.js.map +1 -0
- package/build/dist/Actions/ActionContext.js +322 -0
- package/build/dist/Actions/ActionContext.js.map +1 -0
- package/build/dist/Actions/ActionQueue.js +87 -0
- package/build/dist/Actions/ActionQueue.js.map +1 -0
- package/build/dist/Actions/Actionable.js +2 -0
- package/build/dist/Actions/Actionable.js.map +1 -0
- package/build/dist/Actions/ActionsComponent.js +195 -0
- package/build/dist/Actions/ActionsComponent.js.map +1 -0
- package/build/dist/Actions/ActionsSystem.js +30 -0
- package/build/dist/Actions/ActionsSystem.js.map +1 -0
- package/build/dist/Actions/Index.js +26 -0
- package/build/dist/Actions/Index.js.map +1 -0
- package/build/dist/Actions/RotationType.js +27 -0
- package/build/dist/Actions/RotationType.js.map +1 -0
- package/build/dist/Actor.js +629 -0
- package/build/dist/Actor.js.map +1 -0
- package/build/dist/Camera.js +660 -0
- package/build/dist/Camera.js.map +1 -0
- package/build/dist/Collision/BoundingBox.js +415 -0
- package/build/dist/Collision/BoundingBox.js.map +1 -0
- package/build/dist/Collision/ColliderComponent.js +202 -0
- package/build/dist/Collision/ColliderComponent.js.map +1 -0
- package/build/dist/Collision/Colliders/CircleCollider.js +226 -0
- package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/Collider.js +32 -0
- package/build/dist/Collision/Colliders/Collider.js.map +1 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js +300 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js +229 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js +556 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
- package/build/dist/Collision/Colliders/Shape.js +99 -0
- package/build/dist/Collision/Colliders/Shape.js.map +1 -0
- package/build/dist/Collision/CollisionType.js +33 -0
- package/build/dist/Collision/CollisionType.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionContact.js +51 -0
- package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
- package/build/dist/Collision/Detection/DynamicTree.js +442 -0
- package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
- package/build/dist/Collision/Detection/Pair.js +92 -0
- package/build/dist/Collision/Detection/Pair.js.map +1 -0
- package/build/dist/Collision/Detection/QuadTree.js +193 -0
- package/build/dist/Collision/Detection/QuadTree.js.map +1 -0
- package/build/dist/Collision/Group/CollisionGroup.js +3 -3
- package/build/dist/Collision/Integrator.js +25 -0
- package/build/dist/Collision/Integrator.js.map +1 -0
- package/build/dist/Collision/MotionSystem.js +35 -0
- package/build/dist/Collision/MotionSystem.js.map +1 -0
- package/build/dist/Collision/Physics.js +163 -0
- package/build/dist/Collision/Physics.js.map +1 -0
- package/build/dist/Collision/PhysicsWorld.js +10 -0
- package/build/dist/Collision/PhysicsWorld.js.map +1 -0
- package/build/dist/Collision/Side.js +51 -0
- package/build/dist/Collision/Side.js.map +1 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js +154 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js +87 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
- package/build/dist/Collision/Solver/RealisticSolver.js +293 -0
- package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
- package/build/dist/Collision/Solver/Solver.js +2 -0
- package/build/dist/Collision/Solver/Solver.js.map +1 -0
- package/build/dist/Color.js +417 -0
- package/build/dist/Color.js.map +1 -0
- package/build/dist/Configurable.js +32 -0
- package/build/dist/Configurable.js.map +1 -0
- package/build/dist/Debug/Debug.d.ts +11 -0
- package/build/dist/Debug/Debug.js +385 -0
- package/build/dist/Debug/Debug.js.map +1 -0
- package/build/dist/Debug/DebugFlags.js +40 -0
- package/build/dist/Debug/DebugFlags.js.map +1 -0
- package/build/dist/Debug/DebugSystem.js +263 -0
- package/build/dist/Debug/DebugSystem.js.map +1 -0
- package/build/dist/Debug/index.js +4 -0
- package/build/dist/Debug/index.js.map +1 -0
- package/build/dist/Deprecated.js +2 -0
- package/build/dist/Deprecated.js.map +1 -0
- package/build/dist/Engine.js +986 -0
- package/build/dist/Engine.js.map +1 -0
- package/build/dist/EntityComponentSystem/Component.js +65 -0
- package/build/dist/EntityComponentSystem/Component.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js +107 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Entity.js +487 -0
- package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
- package/build/dist/EntityComponentSystem/EntityManager.js +137 -0
- package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Query.js +90 -0
- package/build/dist/EntityComponentSystem/Query.js.map +1 -0
- package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
- package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/System.js +76 -0
- package/build/dist/EntityComponentSystem/System.js.map +1 -0
- package/build/dist/EntityComponentSystem/SystemManager.js +104 -0
- package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Util.js +5 -0
- package/build/dist/EntityComponentSystem/Util.js.map +1 -0
- package/build/dist/EntityComponentSystem/World.js +55 -0
- package/build/dist/EntityComponentSystem/World.js.map +1 -0
- package/build/dist/EntityComponentSystem/index.js +11 -0
- package/build/dist/EntityComponentSystem/index.js.map +1 -0
- package/build/dist/EventDispatcher.js +122 -0
- package/build/dist/EventDispatcher.js.map +1 -0
- package/build/dist/EventEmitter.js +86 -0
- package/build/dist/EventEmitter.js.map +1 -0
- package/build/dist/Events/ExEvent.js +12 -0
- package/build/dist/Events/ExEvent.js.map +1 -0
- package/build/dist/Events/MediaEvents.js +75 -0
- package/build/dist/Events/MediaEvents.js.map +1 -0
- package/build/dist/Events/PointerEvents.js +52 -0
- package/build/dist/Events/PointerEvents.js.map +1 -0
- package/build/dist/Events.js +473 -0
- package/build/dist/Events.js.map +1 -0
- package/build/dist/Flags.js +67 -0
- package/build/dist/Flags.js.map +1 -0
- package/build/dist/Graphics/Animation.js +344 -0
- package/build/dist/Graphics/Animation.js.map +1 -0
- package/build/dist/Graphics/Canvas.js +38 -0
- package/build/dist/Graphics/Canvas.js.map +1 -0
- package/build/dist/Graphics/Circle.js +48 -0
- package/build/dist/Graphics/Circle.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +237 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +481 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +52 -52
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +174 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -37
- package/build/dist/Graphics/Context/debug-text.js +47 -0
- package/build/dist/Graphics/Context/debug-text.js.map +1 -0
- package/build/dist/Graphics/Context/draw-call.js +16 -0
- package/build/dist/Graphics/Context/draw-call.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +32 -32
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js +246 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.vert.glsl +32 -32
- package/build/dist/Graphics/Context/line-renderer/line-fragment.glsl +10 -10
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js +90 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/line-renderer/line-vertex.glsl +14 -14
- package/build/dist/Graphics/Context/material-renderer/material-renderer.js +23 -2
- package/build/dist/Graphics/Context/material-renderer/material-renderer.js.map +1 -1
- package/build/dist/Graphics/Context/material.d.ts +2 -0
- package/build/dist/Graphics/Context/material.js +72 -0
- package/build/dist/Graphics/Context/material.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-fragment.glsl +19 -19
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js +91 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-vertex.glsl +11 -11
- package/build/dist/Graphics/Context/quad-index-buffer.js +67 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -85
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +305 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -42
- package/build/dist/Graphics/Context/render-source.js +16 -0
- package/build/dist/Graphics/Context/render-source.js.map +1 -0
- package/build/dist/Graphics/Context/render-target.js +65 -0
- package/build/dist/Graphics/Context/render-target.js.map +1 -0
- package/build/dist/Graphics/Context/renderer.js +2 -0
- package/build/dist/Graphics/Context/renderer.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +13 -13
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +56 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -11
- package/build/dist/Graphics/Context/state-stack.js +37 -0
- package/build/dist/Graphics/Context/state-stack.js.map +1 -0
- package/build/dist/Graphics/Context/texture-loader.js +109 -0
- package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
- package/build/dist/Graphics/Context/transform-stack.js +30 -0
- package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
- package/build/dist/Graphics/Context/vertex-buffer.js +53 -0
- package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-util.js +79 -0
- package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
- package/build/dist/Graphics/DebugGraphicsComponent.d.ts +3 -2
- package/build/dist/Graphics/DebugGraphicsComponent.js +16 -0
- package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/Filtering.js +17 -0
- package/build/dist/Graphics/Filtering.js.map +1 -0
- package/build/dist/Graphics/Font.js +148 -0
- package/build/dist/Graphics/Font.js.map +1 -0
- package/build/dist/Graphics/FontCache.d.ts +1 -0
- package/build/dist/Graphics/FontCache.js +80 -0
- package/build/dist/Graphics/FontCache.js.map +1 -0
- package/build/dist/Graphics/FontCommon.js +109 -0
- package/build/dist/Graphics/FontCommon.js.map +1 -0
- package/build/dist/Graphics/FontTextInstance.js +230 -0
- package/build/dist/Graphics/FontTextInstance.js.map +1 -0
- package/build/dist/Graphics/Graphic.js +208 -0
- package/build/dist/Graphics/Graphic.js.map +1 -0
- package/build/dist/Graphics/GraphicsComponent.js +336 -0
- package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
- package/build/dist/Graphics/GraphicsGroup.js +69 -0
- package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
- package/build/dist/Graphics/GraphicsSystem.js +210 -0
- package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
- package/build/dist/Graphics/ImageSource.js +124 -0
- package/build/dist/Graphics/ImageSource.js.map +1 -0
- package/build/dist/Graphics/Line.js +45 -0
- package/build/dist/Graphics/Line.js.map +1 -0
- package/build/dist/Graphics/OffscreenSystem.js +64 -0
- package/build/dist/Graphics/OffscreenSystem.js.map +1 -0
- package/build/dist/Graphics/ParallaxComponent.js +11 -0
- package/build/dist/Graphics/ParallaxComponent.js.map +1 -0
- package/build/dist/Graphics/Polygon.js +59 -0
- package/build/dist/Graphics/Polygon.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js +59 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +64 -64
- package/build/dist/Graphics/Raster.js +215 -0
- package/build/dist/Graphics/Raster.js.map +1 -0
- package/build/dist/Graphics/Rectangle.js +29 -0
- package/build/dist/Graphics/Rectangle.js.map +1 -0
- package/build/dist/Graphics/Sprite.js +82 -0
- package/build/dist/Graphics/Sprite.js.map +1 -0
- package/build/dist/Graphics/SpriteFont.js +139 -0
- package/build/dist/Graphics/SpriteFont.js.map +1 -0
- package/build/dist/Graphics/SpriteSheet.js +116 -0
- package/build/dist/Graphics/SpriteSheet.js.map +1 -0
- package/build/dist/Graphics/Text.js +103 -0
- package/build/dist/Graphics/Text.js.map +1 -0
- package/build/dist/Graphics/index.js +46 -0
- package/build/dist/Graphics/index.js.map +1 -0
- package/build/dist/Id.js +8 -0
- package/build/dist/Id.js.map +1 -0
- package/build/dist/Input/CapturePointerConfig.js +5 -0
- package/build/dist/Input/CapturePointerConfig.js.map +1 -0
- package/build/dist/Input/EngineInput.js +2 -0
- package/build/dist/Input/EngineInput.js.map +1 -0
- package/build/dist/Input/Gamepad.js +422 -0
- package/build/dist/Input/Gamepad.js.map +1 -0
- package/build/dist/Input/Index.js +88 -0
- package/build/dist/Input/Index.js.map +1 -0
- package/build/dist/Input/InputMapper.js +45 -0
- package/build/dist/Input/InputMapper.js.map +1 -0
- package/build/dist/Input/Keyboard.js +348 -0
- package/build/dist/Input/Keyboard.js.map +1 -0
- package/build/dist/Input/NativePointerButton.js +12 -0
- package/build/dist/Input/NativePointerButton.js.map +1 -0
- package/build/dist/Input/PointerAbstraction.js +44 -0
- package/build/dist/Input/PointerAbstraction.js.map +1 -0
- package/build/dist/Input/PointerButton.js +12 -0
- package/build/dist/Input/PointerButton.js.map +1 -0
- package/build/dist/Input/PointerComponent.js +28 -0
- package/build/dist/Input/PointerComponent.js.map +1 -0
- package/build/dist/Input/PointerEvent.js +25 -0
- package/build/dist/Input/PointerEvent.js.map +1 -0
- package/build/dist/Input/PointerEventReceiver.js +456 -0
- package/build/dist/Input/PointerEventReceiver.js.map +1 -0
- package/build/dist/Input/PointerScope.js +16 -0
- package/build/dist/Input/PointerScope.js.map +1 -0
- package/build/dist/Input/PointerSystem.js +249 -0
- package/build/dist/Input/PointerSystem.js.map +1 -0
- package/build/dist/Input/PointerType.js +11 -0
- package/build/dist/Input/PointerType.js.map +1 -0
- package/build/dist/Input/WheelDeltaMode.js +7 -0
- package/build/dist/Input/WheelDeltaMode.js.map +1 -0
- package/build/dist/Input/WheelEvent.js +21 -0
- package/build/dist/Input/WheelEvent.js.map +1 -0
- package/build/dist/Interfaces/Audio.js +2 -0
- package/build/dist/Interfaces/Audio.js.map +1 -0
- package/build/dist/Interfaces/AudioImplementation.js +11 -0
- package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
- package/build/dist/Interfaces/Clonable.js +2 -0
- package/build/dist/Interfaces/Clonable.js.map +1 -0
- package/build/dist/Interfaces/Evented.js +2 -0
- package/build/dist/Interfaces/Evented.js.map +1 -0
- package/build/dist/Interfaces/Index.js +8 -0
- package/build/dist/Interfaces/Index.js.map +1 -0
- package/build/dist/Interfaces/LifecycleEvents.js +51 -0
- package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
- package/build/dist/Interfaces/Loadable.js +2 -0
- package/build/dist/Interfaces/Loadable.js.map +1 -0
- package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
- package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
- package/build/dist/Label.js +81 -0
- package/build/dist/Label.js.map +1 -0
- package/build/dist/Loader.js +416 -0
- package/build/dist/Loader.js.map +1 -0
- package/build/dist/Math/Index.js +13 -0
- package/build/dist/Math/Index.js.map +1 -0
- package/build/dist/Math/Random.js +239 -0
- package/build/dist/Math/Random.js.map +1 -0
- package/build/dist/Math/affine-matrix.js +331 -0
- package/build/dist/Math/affine-matrix.js.map +1 -0
- package/build/dist/Math/coord-plane.js +17 -0
- package/build/dist/Math/coord-plane.js.map +1 -0
- package/build/dist/Math/global-coordinates.js +30 -0
- package/build/dist/Math/global-coordinates.js.map +1 -0
- package/build/dist/Math/line-segment.js +205 -0
- package/build/dist/Math/line-segment.js.map +1 -0
- package/build/dist/Math/matrix.js +457 -0
- package/build/dist/Math/matrix.js.map +1 -0
- package/build/dist/Math/projection.js +24 -0
- package/build/dist/Math/projection.js.map +1 -0
- package/build/dist/Math/ray.js +52 -0
- package/build/dist/Math/ray.js.map +1 -0
- package/build/dist/Math/transform.js +219 -0
- package/build/dist/Math/transform.js.map +1 -0
- package/build/dist/Math/util.js +82 -0
- package/build/dist/Math/util.js.map +1 -0
- package/build/dist/Math/vector-view.js +25 -0
- package/build/dist/Math/vector-view.js.map +1 -0
- package/build/dist/Math/vector.js +340 -0
- package/build/dist/Math/vector.js.map +1 -0
- package/build/dist/Math/watch-vector.js +26 -0
- package/build/dist/Math/watch-vector.js.map +1 -0
- package/build/dist/Particles.js +430 -0
- package/build/dist/Particles.js.map +1 -0
- package/build/dist/Polyfill.js +56 -0
- package/build/dist/Polyfill.js.map +1 -0
- package/build/dist/Resources/Gif.js +464 -0
- package/build/dist/Resources/Gif.js.map +1 -0
- package/build/dist/Resources/Index.js +4 -0
- package/build/dist/Resources/Index.js.map +1 -0
- package/build/dist/Resources/Resource.js +81 -0
- package/build/dist/Resources/Resource.js.map +1 -0
- package/build/dist/Resources/Sound/AudioContext.js +16 -0
- package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
- package/build/dist/Resources/Sound/Index.js +4 -0
- package/build/dist/Resources/Sound/Index.js.map +1 -0
- package/build/dist/Resources/Sound/Sound.js +326 -0
- package/build/dist/Resources/Sound/Sound.js.map +1 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js +190 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
- package/build/dist/Scene.js +444 -0
- package/build/dist/Scene.js.map +1 -0
- package/build/dist/Screen.js +782 -0
- package/build/dist/Screen.js.map +1 -0
- package/build/dist/ScreenElement.js +43 -0
- package/build/dist/ScreenElement.js.map +1 -0
- package/build/dist/TileMap/IsometricEntityComponent.js +17 -0
- package/build/dist/TileMap/IsometricEntityComponent.js.map +1 -0
- package/build/dist/TileMap/IsometricEntitySystem.js +23 -0
- package/build/dist/TileMap/IsometricEntitySystem.js.map +1 -0
- package/build/dist/TileMap/IsometricMap.js +311 -0
- package/build/dist/TileMap/IsometricMap.js.map +1 -0
- package/build/dist/TileMap/TileMap.d.ts +2 -1
- package/build/dist/TileMap/TileMap.js +630 -0
- package/build/dist/TileMap/TileMap.js.map +1 -0
- package/build/dist/TileMap/index.js +5 -0
- package/build/dist/TileMap/index.js.map +1 -0
- package/build/dist/Timer.js +202 -0
- package/build/dist/Timer.js.map +1 -0
- package/build/dist/Trigger.js +94 -0
- package/build/dist/Trigger.js.map +1 -0
- package/build/dist/Util/Browser.js +66 -0
- package/build/dist/Util/Browser.js.map +1 -0
- package/build/dist/Util/Clock.js +219 -0
- package/build/dist/Util/Clock.js.map +1 -0
- package/build/dist/Util/Decorators.js +78 -0
- package/build/dist/Util/Decorators.js.map +1 -0
- package/build/dist/Util/Detector.js +167 -0
- package/build/dist/Util/Detector.js.map +1 -0
- package/build/dist/Util/DrawUtil.js +115 -0
- package/build/dist/Util/DrawUtil.js.map +1 -0
- package/build/dist/Util/EasingFunctions.js +102 -0
- package/build/dist/Util/EasingFunctions.js.map +1 -0
- package/build/dist/Util/Fps.js +47 -0
- package/build/dist/Util/Fps.js.map +1 -0
- package/build/dist/Util/Future.js +30 -0
- package/build/dist/Util/Future.js.map +1 -0
- package/build/dist/Util/IFrame.js +23 -0
- package/build/dist/Util/IFrame.js.map +1 -0
- package/build/dist/Util/Index.js +7 -0
- package/build/dist/Util/Index.js.map +1 -0
- package/build/dist/Util/Log.js +195 -0
- package/build/dist/Util/Log.js.map +1 -0
- package/build/dist/Util/Observable.js +66 -0
- package/build/dist/Util/Observable.js.map +1 -0
- package/build/dist/Util/Pool.js +74 -0
- package/build/dist/Util/Pool.js.map +1 -0
- package/build/dist/Util/Semaphore.js +55 -0
- package/build/dist/Util/Semaphore.js.map +1 -0
- package/build/dist/Util/Sound.js +22 -0
- package/build/dist/Util/Sound.js.map +1 -0
- package/build/dist/Util/StateMachine.js +79 -0
- package/build/dist/Util/StateMachine.js.map +1 -0
- package/build/dist/Util/Toaster.css +28 -28
- package/build/dist/Util/Toaster.js +84 -0
- package/build/dist/Util/Toaster.js.map +1 -0
- package/build/dist/Util/Util.d.ts +6 -0
- package/build/dist/Util/Util.js +95 -0
- package/build/dist/Util/Util.js.map +1 -0
- package/build/dist/Util/Watch.js +67 -0
- package/build/dist/Util/Watch.js.map +1 -0
- package/build/dist/Util/WebAudio.js +62 -0
- package/build/dist/Util/WebAudio.js.map +1 -0
- package/build/dist/excalibur.d.ts +2 -2
- package/build/dist/excalibur.js +389 -258
- package/build/dist/excalibur.js.map +1 -1
- package/build/dist/excalibur.min.js +1 -1
- package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
- package/build/dist/excalibur.min.js.map +1 -1
- package/build/dist/index.js +81 -0
- package/build/dist/index.js.map +1 -0
- package/build/esm/Debug/Debug.d.ts +11 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
- package/build/esm/Graphics/Context/material.d.ts +2 -0
- package/build/esm/Graphics/DebugGraphicsComponent.d.ts +3 -2
- package/build/esm/Graphics/FontCache.d.ts +1 -0
- package/build/esm/TileMap/TileMap.d.ts +2 -1
- package/build/esm/Util/Util.d.ts +6 -0
- package/build/esm/excalibur.d.ts +2 -2
- package/build/esm/excalibur.js +389 -258
- package/build/esm/excalibur.js.map +1 -1
- package/build/esm/excalibur.min.js +1 -1
- package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
- package/build/esm/excalibur.min.js.map +1 -1
- package/docker-compose.yml +11 -11
- package/package.json +131 -131
- package/build/dist/Loader.css +0 -122
- package/build/nuget/Excalibur.0.28.3.nupkg +0 -0
- package/build/v0.28.3.zip +0 -0
- package/excalibur-0.28.3.tgz +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component } from '../EntityComponentSystem/Component';
|
|
2
|
+
/**
|
|
3
|
+
* Provide arbitrary drawing for the purposes of debugging your game
|
|
4
|
+
*
|
|
5
|
+
* Will only show when the Engine is set to debug mode [[Engine.showDebug]] or [[Engine.toggleDebug]]
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export class DebugGraphicsComponent extends Component {
|
|
9
|
+
constructor(draw, useTransform = true) {
|
|
10
|
+
super();
|
|
11
|
+
this.draw = draw;
|
|
12
|
+
this.useTransform = useTransform;
|
|
13
|
+
this.type = 'ex.debuggraphics';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=DebugGraphicsComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugGraphicsComponent.js","sourceRoot":"","sources":["../../../src/engine/Graphics/DebugGraphicsComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAA6B;IAEvE,YAAmB,IAAgE,EAAS,eAAe,IAAI;QAC7G,KAAK,EAAE,CAAC;QADS,SAAI,GAAJ,IAAI,CAA4D;QAAS,iBAAY,GAAZ,YAAY,CAAO;QADtG,SAAI,GAAG,kBAAkB,CAAC;IAGnC,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the different image filtering modes
|
|
3
|
+
*/
|
|
4
|
+
export var ImageFiltering;
|
|
5
|
+
(function (ImageFiltering) {
|
|
6
|
+
/**
|
|
7
|
+
* Pixel is useful when you do not want smoothing aka antialiasing applied to your graphics.
|
|
8
|
+
*
|
|
9
|
+
* Useful for Pixel art aesthetics.
|
|
10
|
+
*/
|
|
11
|
+
ImageFiltering["Pixel"] = "Pixel";
|
|
12
|
+
/**
|
|
13
|
+
* Blended is useful when you have high resolution artwork and would like it blended and smoothed
|
|
14
|
+
*/
|
|
15
|
+
ImageFiltering["Blended"] = "Blended";
|
|
16
|
+
})(ImageFiltering || (ImageFiltering = {}));
|
|
17
|
+
//# sourceMappingURL=Filtering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filtering.js","sourceRoot":"","sources":["../../../src/engine/Graphics/Filtering.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IAExB;;;;OAIG;IACH,iCAAe,CAAA;IAEf;;OAEG;IACH,qCAAmB,CAAA;AACrB,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { BoundingBox } from '../Collision/Index';
|
|
2
|
+
import { Color } from '../Color';
|
|
3
|
+
import { BaseAlign, Direction, FontStyle, FontUnit, TextAlign } from './FontCommon';
|
|
4
|
+
import { Graphic } from './Graphic';
|
|
5
|
+
import { ImageFiltering } from './Filtering';
|
|
6
|
+
import { FontTextInstance } from './FontTextInstance';
|
|
7
|
+
import { FontCache } from './FontCache';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a system or web font in Excalibur
|
|
10
|
+
*
|
|
11
|
+
* If no options specified, the system sans-serif 10 pixel is used
|
|
12
|
+
*
|
|
13
|
+
* If loading a custom web font be sure to have the font loaded before you use it https://erikonarheim.com/posts/dont-test-fonts/
|
|
14
|
+
*/
|
|
15
|
+
export class Font extends Graphic {
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
18
|
+
super(options); // <- Graphics properties
|
|
19
|
+
/**
|
|
20
|
+
* Set the font filtering mode, by default set to [[ImageFiltering.Blended]] regardless of the engine default smoothing
|
|
21
|
+
*
|
|
22
|
+
* If you have a pixel style font that may be a reason to switch this to [[ImageFiltering.Pixel]]
|
|
23
|
+
*/
|
|
24
|
+
this.filtering = ImageFiltering.Blended;
|
|
25
|
+
/**
|
|
26
|
+
* Font quality determines the size of the underlying raster text, higher quality means less jagged edges.
|
|
27
|
+
* If quality is set to 1, then just enough raster bitmap is generated to render the text.
|
|
28
|
+
*
|
|
29
|
+
* You can think of quality as how zoomed in to the text you can get before seeing jagged edges.
|
|
30
|
+
*
|
|
31
|
+
* (Default 2)
|
|
32
|
+
*/
|
|
33
|
+
this.quality = 2;
|
|
34
|
+
// Raster properties for fonts
|
|
35
|
+
this.padding = 2;
|
|
36
|
+
this.smoothing = false;
|
|
37
|
+
this.lineWidth = 1;
|
|
38
|
+
this.lineDash = [];
|
|
39
|
+
this.color = Color.Black;
|
|
40
|
+
this.family = 'sans-serif';
|
|
41
|
+
this.style = FontStyle.Normal;
|
|
42
|
+
this.bold = false;
|
|
43
|
+
this.unit = FontUnit.Px;
|
|
44
|
+
this.textAlign = TextAlign.Left;
|
|
45
|
+
this.baseAlign = BaseAlign.Alphabetic;
|
|
46
|
+
this.direction = Direction.LeftToRight;
|
|
47
|
+
this.size = 10;
|
|
48
|
+
this.shadow = null;
|
|
49
|
+
this._textBounds = new BoundingBox();
|
|
50
|
+
this._textMeasurement = new FontTextInstance(this, '', Color.Black);
|
|
51
|
+
// Raster properties
|
|
52
|
+
this.smoothing = (_a = options === null || options === void 0 ? void 0 : options.smoothing) !== null && _a !== void 0 ? _a : this.smoothing;
|
|
53
|
+
this.padding = (_b = options === null || options === void 0 ? void 0 : options.padding) !== null && _b !== void 0 ? _b : this.padding;
|
|
54
|
+
this.color = (_c = options === null || options === void 0 ? void 0 : options.color) !== null && _c !== void 0 ? _c : this.color;
|
|
55
|
+
this.strokeColor = (_d = options === null || options === void 0 ? void 0 : options.strokeColor) !== null && _d !== void 0 ? _d : this.strokeColor;
|
|
56
|
+
this.lineDash = (_e = options === null || options === void 0 ? void 0 : options.lineDash) !== null && _e !== void 0 ? _e : this.lineDash;
|
|
57
|
+
this.lineWidth = (_f = options === null || options === void 0 ? void 0 : options.lineWidth) !== null && _f !== void 0 ? _f : this.lineWidth;
|
|
58
|
+
this.filtering = (_g = options === null || options === void 0 ? void 0 : options.filtering) !== null && _g !== void 0 ? _g : this.filtering;
|
|
59
|
+
// Font specific properties
|
|
60
|
+
this.family = (_h = options === null || options === void 0 ? void 0 : options.family) !== null && _h !== void 0 ? _h : this.family;
|
|
61
|
+
this.style = (_j = options === null || options === void 0 ? void 0 : options.style) !== null && _j !== void 0 ? _j : this.style;
|
|
62
|
+
this.bold = (_k = options === null || options === void 0 ? void 0 : options.bold) !== null && _k !== void 0 ? _k : this.bold;
|
|
63
|
+
this.size = (_l = options === null || options === void 0 ? void 0 : options.size) !== null && _l !== void 0 ? _l : this.size;
|
|
64
|
+
this.unit = (_m = options === null || options === void 0 ? void 0 : options.unit) !== null && _m !== void 0 ? _m : this.unit;
|
|
65
|
+
this.textAlign = (_o = options === null || options === void 0 ? void 0 : options.textAlign) !== null && _o !== void 0 ? _o : this.textAlign;
|
|
66
|
+
this.baseAlign = (_p = options === null || options === void 0 ? void 0 : options.baseAlign) !== null && _p !== void 0 ? _p : this.baseAlign;
|
|
67
|
+
this.direction = (_q = options === null || options === void 0 ? void 0 : options.direction) !== null && _q !== void 0 ? _q : this.direction;
|
|
68
|
+
this.quality = (_r = options === null || options === void 0 ? void 0 : options.quality) !== null && _r !== void 0 ? _r : this.quality;
|
|
69
|
+
if (options === null || options === void 0 ? void 0 : options.shadow) {
|
|
70
|
+
this.shadow = {};
|
|
71
|
+
this.shadow.blur = (_s = options.shadow.blur) !== null && _s !== void 0 ? _s : this.shadow.blur;
|
|
72
|
+
this.shadow.offset = (_t = options.shadow.offset) !== null && _t !== void 0 ? _t : this.shadow.offset;
|
|
73
|
+
this.shadow.color = (_u = options.shadow.color) !== null && _u !== void 0 ? _u : this.shadow.color;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
clone() {
|
|
77
|
+
return new Font({
|
|
78
|
+
...this.cloneGraphicOptions(),
|
|
79
|
+
size: this.size,
|
|
80
|
+
unit: this.unit,
|
|
81
|
+
family: this.family,
|
|
82
|
+
style: this.style,
|
|
83
|
+
bold: this.bold,
|
|
84
|
+
textAlign: this.textAlign,
|
|
85
|
+
baseAlign: this.baseAlign,
|
|
86
|
+
direction: this.direction,
|
|
87
|
+
shadow: this.shadow
|
|
88
|
+
? {
|
|
89
|
+
blur: this.shadow.blur,
|
|
90
|
+
offset: this.shadow.offset,
|
|
91
|
+
color: this.shadow.color
|
|
92
|
+
}
|
|
93
|
+
: null
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
get fontString() {
|
|
97
|
+
return `${this.style} ${this.bold ? 'bold' : ''} ${this.size}${this.unit} ${this.family}`;
|
|
98
|
+
}
|
|
99
|
+
get localBounds() {
|
|
100
|
+
return this._textBounds;
|
|
101
|
+
}
|
|
102
|
+
_drawImage(_ex, _x, _y) {
|
|
103
|
+
// TODO weird vestigial drawimage
|
|
104
|
+
}
|
|
105
|
+
_rotate(ex) {
|
|
106
|
+
var _a;
|
|
107
|
+
// TODO this needs to change depending on the bounding box...
|
|
108
|
+
const origin = (_a = this.origin) !== null && _a !== void 0 ? _a : this._textBounds.center;
|
|
109
|
+
ex.translate(origin.x, origin.y);
|
|
110
|
+
ex.rotate(this.rotation);
|
|
111
|
+
ex.translate(-origin.x, -origin.y);
|
|
112
|
+
}
|
|
113
|
+
_flip(ex) {
|
|
114
|
+
if (this.flipHorizontal) {
|
|
115
|
+
ex.translate(this._textBounds.width / this.scale.x, 0);
|
|
116
|
+
ex.scale(-1, 1);
|
|
117
|
+
}
|
|
118
|
+
if (this.flipVertical) {
|
|
119
|
+
ex.translate(0, -this._textBounds.height / 2 / this.scale.y);
|
|
120
|
+
ex.scale(1, -1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
measureTextWithoutCache(text, maxWidth) {
|
|
124
|
+
return this._textMeasurement.measureText(text, maxWidth);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns a BoundingBox that is the total size of the text including multiple lines
|
|
128
|
+
*
|
|
129
|
+
* Does not include any padding or adjustment
|
|
130
|
+
* @param text
|
|
131
|
+
* @returns BoundingBox
|
|
132
|
+
*/
|
|
133
|
+
measureText(text, maxWidth) {
|
|
134
|
+
return FontCache.measureText(text, this, maxWidth);
|
|
135
|
+
}
|
|
136
|
+
_postDraw(ex) {
|
|
137
|
+
ex.restore();
|
|
138
|
+
}
|
|
139
|
+
render(ex, text, colorOverride, x, y, maxWidth) {
|
|
140
|
+
const textInstance = FontCache.getTextInstance(text, this, colorOverride);
|
|
141
|
+
// Apply affine transformations
|
|
142
|
+
this._textBounds = textInstance.dimensions;
|
|
143
|
+
this._preDraw(ex, x, y);
|
|
144
|
+
textInstance.render(ex, x, y, maxWidth);
|
|
145
|
+
this._postDraw(ex);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=Font.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Font.js","sourceRoot":"","sources":["../../../src/engine/Graphics/Font.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAe,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;;;;GAMG;AACH,MAAM,OAAO,IAAK,SAAQ,OAAO;IAO/B,YAAY,UAAwD,EAAE;;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC,C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AAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAIM,uBAAuB,CAAC,IAAY,EAAE,QAAiB;QAC5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACI,WAAW,CAAC,IAAY,EAAE,QAAiB;QAChD,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAES,SAAS,CAAC,EAA4B;QAC9C,EAAE,CAAC,OAAO,EAAE,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,EAA4B,EAAE,IAAY,EAAE,aAAoB,EAAE,CAAS,EAAE,CAAS,EAAE,QAAiB;QACrH,MAAM,YAAY,GAAG,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAE1E,+BAA+B;QAC/B,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,UAAU,CAAC;QAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAExB,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;QAExC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -3,6 +3,7 @@ import { Color } from '../Color';
|
|
|
3
3
|
import { Font } from './Font';
|
|
4
4
|
import { FontTextInstance } from './FontTextInstance';
|
|
5
5
|
export declare class FontCache {
|
|
6
|
+
static FONT_TIMEOUT: number;
|
|
6
7
|
private static _LOGGER;
|
|
7
8
|
private static _TEXT_USAGE;
|
|
8
9
|
private static _TEXT_CACHE;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Logger } from '../Util/Log';
|
|
2
|
+
import { FontTextInstance } from './FontTextInstance';
|
|
3
|
+
export class FontCache {
|
|
4
|
+
static measureText(text, font, maxWidth) {
|
|
5
|
+
const hash = FontTextInstance.getHashCode(font, text);
|
|
6
|
+
if (FontCache._MEASURE_CACHE.has(hash)) {
|
|
7
|
+
return FontCache._MEASURE_CACHE.get(hash);
|
|
8
|
+
}
|
|
9
|
+
FontCache._LOGGER.debug('Font text measurement cache miss');
|
|
10
|
+
const measurement = font.measureTextWithoutCache(text, maxWidth);
|
|
11
|
+
FontCache._MEASURE_CACHE.set(hash, measurement);
|
|
12
|
+
return measurement;
|
|
13
|
+
}
|
|
14
|
+
static getTextInstance(text, font, color) {
|
|
15
|
+
const hash = FontTextInstance.getHashCode(font, text, color);
|
|
16
|
+
let textInstance = FontCache._TEXT_CACHE.get(hash);
|
|
17
|
+
if (!textInstance) {
|
|
18
|
+
textInstance = new FontTextInstance(font, text, color);
|
|
19
|
+
FontCache._TEXT_CACHE.set(hash, textInstance);
|
|
20
|
+
FontCache._LOGGER.debug('Font text instance cache miss');
|
|
21
|
+
}
|
|
22
|
+
// Cache the bitmap for certain amount of time
|
|
23
|
+
FontCache._TEXT_USAGE.set(textInstance, performance.now());
|
|
24
|
+
return textInstance;
|
|
25
|
+
}
|
|
26
|
+
static checkAndClearCache() {
|
|
27
|
+
const deferred = [];
|
|
28
|
+
const currentHashCodes = new Set();
|
|
29
|
+
for (const [textInstance, time] of FontCache._TEXT_USAGE.entries()) {
|
|
30
|
+
// if bitmap hasn't been used in 100 ms clear it
|
|
31
|
+
if (time + FontCache.FONT_TIMEOUT < performance.now()) {
|
|
32
|
+
FontCache._LOGGER.debug(`Text cache entry timed out ${textInstance.text}`);
|
|
33
|
+
deferred.push(textInstance);
|
|
34
|
+
textInstance.dispose();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const hash = textInstance.getHashCode(false);
|
|
38
|
+
currentHashCodes.add(hash);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Deferred removal of text instances
|
|
42
|
+
deferred.forEach((t) => {
|
|
43
|
+
FontCache._TEXT_USAGE.delete(t);
|
|
44
|
+
});
|
|
45
|
+
// Regenerate text instance cache
|
|
46
|
+
this._TEXT_CACHE.clear();
|
|
47
|
+
for (const [textInstance] of this._TEXT_USAGE.entries()) {
|
|
48
|
+
this._TEXT_CACHE.set(textInstance.getHashCode(), textInstance);
|
|
49
|
+
}
|
|
50
|
+
// Regenerated measurement cache
|
|
51
|
+
const newTextMeasurementCache = new Map();
|
|
52
|
+
for (const current of currentHashCodes) {
|
|
53
|
+
if (FontCache._MEASURE_CACHE.has(current)) {
|
|
54
|
+
newTextMeasurementCache.set(current, FontCache._MEASURE_CACHE.get(current));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this._MEASURE_CACHE.clear();
|
|
58
|
+
this._MEASURE_CACHE = newTextMeasurementCache;
|
|
59
|
+
}
|
|
60
|
+
static get cacheSize() {
|
|
61
|
+
return FontCache._TEXT_USAGE.size;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Force clear all cached text bitmaps
|
|
65
|
+
*/
|
|
66
|
+
static clearCache() {
|
|
67
|
+
for (const [textInstance] of FontCache._TEXT_USAGE.entries()) {
|
|
68
|
+
textInstance.dispose();
|
|
69
|
+
}
|
|
70
|
+
FontCache._TEXT_USAGE.clear();
|
|
71
|
+
FontCache._TEXT_CACHE.clear();
|
|
72
|
+
FontCache._MEASURE_CACHE.clear();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
FontCache.FONT_TIMEOUT = 500;
|
|
76
|
+
FontCache._LOGGER = Logger.getInstance();
|
|
77
|
+
FontCache._TEXT_USAGE = new Map();
|
|
78
|
+
FontCache._TEXT_CACHE = new Map();
|
|
79
|
+
FontCache._MEASURE_CACHE = new Map();
|
|
80
|
+
//# sourceMappingURL=FontCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontCache.js","sourceRoot":"","sources":["../../../src/engine/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AG,EAAuB,CAAC;QAC/D,KAAK,MAAM,OAAO,IAAI,gBAAgB,EAAE,CAAC;YACvC,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1C,uBAAuB,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,uBAAuB,CAAC;IAChD,CAAC;IAEM,MAAM,KAAK,SAAS;QACzB,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU;QACtB,KAAK,MAAM,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7D,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;QACD,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC9B,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC9B,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;;AAlFa,sBAAY,GAAG,GAAG,CAAC;AAClB,iBAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;AAC/B,qBAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;AAClD,qBAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;AAClD,wBAAc,GAAG,IAAI,GAAG,EAAuB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing the different font size units
|
|
3
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
|
|
4
|
+
*/
|
|
5
|
+
export var FontUnit;
|
|
6
|
+
(function (FontUnit) {
|
|
7
|
+
/**
|
|
8
|
+
* Em is a scalable unit, 1 em is equal to the current font size of the current element, parent elements can effect em values
|
|
9
|
+
*/
|
|
10
|
+
FontUnit["Em"] = "em";
|
|
11
|
+
/**
|
|
12
|
+
* Rem is similar to the Em, it is a scalable unit. 1 rem is equal to the font size of the root element
|
|
13
|
+
*/
|
|
14
|
+
FontUnit["Rem"] = "rem";
|
|
15
|
+
/**
|
|
16
|
+
* Pixel is a unit of length in screen pixels
|
|
17
|
+
*/
|
|
18
|
+
FontUnit["Px"] = "px";
|
|
19
|
+
/**
|
|
20
|
+
* Point is a physical unit length (1/72 of an inch)
|
|
21
|
+
*/
|
|
22
|
+
FontUnit["Pt"] = "pt";
|
|
23
|
+
/**
|
|
24
|
+
* Percent is a scalable unit similar to Em, the only difference is the Em units scale faster when Text-Size stuff
|
|
25
|
+
*/
|
|
26
|
+
FontUnit["Percent"] = "%";
|
|
27
|
+
})(FontUnit || (FontUnit = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Enum representing the different horizontal text alignments
|
|
30
|
+
*/
|
|
31
|
+
export var TextAlign;
|
|
32
|
+
(function (TextAlign) {
|
|
33
|
+
/**
|
|
34
|
+
* The text is left-aligned.
|
|
35
|
+
*/
|
|
36
|
+
TextAlign["Left"] = "left";
|
|
37
|
+
/**
|
|
38
|
+
* The text is right-aligned.
|
|
39
|
+
*/
|
|
40
|
+
TextAlign["Right"] = "right";
|
|
41
|
+
/**
|
|
42
|
+
* The text is centered.
|
|
43
|
+
*/
|
|
44
|
+
TextAlign["Center"] = "center";
|
|
45
|
+
/**
|
|
46
|
+
* The text is aligned at the normal start of the line (left-aligned for left-to-right locales,
|
|
47
|
+
* right-aligned for right-to-left locales).
|
|
48
|
+
*/
|
|
49
|
+
TextAlign["Start"] = "start";
|
|
50
|
+
/**
|
|
51
|
+
* The text is aligned at the normal end of the line (right-aligned for left-to-right locales,
|
|
52
|
+
* left-aligned for right-to-left locales).
|
|
53
|
+
*/
|
|
54
|
+
TextAlign["End"] = "end";
|
|
55
|
+
})(TextAlign || (TextAlign = {}));
|
|
56
|
+
/**
|
|
57
|
+
* Enum representing the different baseline text alignments
|
|
58
|
+
*/
|
|
59
|
+
export var BaseAlign;
|
|
60
|
+
(function (BaseAlign) {
|
|
61
|
+
/**
|
|
62
|
+
* The text baseline is the top of the em square.
|
|
63
|
+
*/
|
|
64
|
+
BaseAlign["Top"] = "top";
|
|
65
|
+
/**
|
|
66
|
+
* The text baseline is the hanging baseline. Currently unsupported; this will act like
|
|
67
|
+
* alphabetic.
|
|
68
|
+
*/
|
|
69
|
+
BaseAlign["Hanging"] = "hanging";
|
|
70
|
+
/**
|
|
71
|
+
* The text baseline is the middle of the em square.
|
|
72
|
+
*/
|
|
73
|
+
BaseAlign["Middle"] = "middle";
|
|
74
|
+
/**
|
|
75
|
+
* The text baseline is the normal alphabetic baseline.
|
|
76
|
+
*/
|
|
77
|
+
BaseAlign["Alphabetic"] = "alphabetic";
|
|
78
|
+
/**
|
|
79
|
+
* The text baseline is the ideographic baseline; this is the bottom of
|
|
80
|
+
* the body of the characters, if the main body of characters protrudes
|
|
81
|
+
* beneath the alphabetic baseline. Currently unsupported; this will
|
|
82
|
+
* act like alphabetic.
|
|
83
|
+
*/
|
|
84
|
+
BaseAlign["Ideographic"] = "ideographic";
|
|
85
|
+
/**
|
|
86
|
+
* The text baseline is the bottom of the bounding box. This differs
|
|
87
|
+
* from the ideographic baseline in that the ideographic baseline
|
|
88
|
+
* doesn't consider descenders.
|
|
89
|
+
*/
|
|
90
|
+
BaseAlign["Bottom"] = "bottom";
|
|
91
|
+
})(BaseAlign || (BaseAlign = {}));
|
|
92
|
+
/**
|
|
93
|
+
* Enum representing the different possible font styles
|
|
94
|
+
*/
|
|
95
|
+
export var FontStyle;
|
|
96
|
+
(function (FontStyle) {
|
|
97
|
+
FontStyle["Normal"] = "normal";
|
|
98
|
+
FontStyle["Italic"] = "italic";
|
|
99
|
+
FontStyle["Oblique"] = "oblique";
|
|
100
|
+
})(FontStyle || (FontStyle = {}));
|
|
101
|
+
/**
|
|
102
|
+
* Enum representing the text direction, useful for other languages, or writing text in reverse
|
|
103
|
+
*/
|
|
104
|
+
export var Direction;
|
|
105
|
+
(function (Direction) {
|
|
106
|
+
Direction["LeftToRight"] = "ltr";
|
|
107
|
+
Direction["RightToLeft"] = "rtl";
|
|
108
|
+
})(Direction || (Direction = {}));
|
|
109
|
+
//# sourceMappingURL=FontCommon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontCommon.js","sourceRoot":"","sources":["../../../src/engine/Graphics/FontCommon.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,CAAN,IAAY,QAqBX;AArBD,WAAY,QAAQ;IAClB;;OAEG;IACH,qBAAS,CAAA;IACT;;OAEG;IACH,uBAAW,CAAA;IACX;;OAEG;IACH,qBAAS,CAAA;IACT;;OAEG;IACH,qBAAS,CAAA;IACT;;OAEG;IACH,yBAAa,CAAA;AACf,CAAC,EArBW,QAAQ,KAAR,QAAQ,QAqBnB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAuBX;AAvBD,WAAY,SAAS;IACnB;;OAEG;IACH,0BAAa,CAAA;IACb;;OAEG;IACH,4BAAe,CAAA;IACf;;OAEG;IACH,8BAAiB,CAAA;IACjB;;;OAGG;IACH,4BAAe,CAAA;IACf;;;OAGG;IACH,wBAAW,CAAA;AACb,CAAC,EAvBW,SAAS,KAAT,SAAS,QAuBpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SA+BX;AA/BD,WAAY,SAAS;IACnB;;OAEG;IACH,wBAAW,CAAA;IACX;;;OAGG;IACH,gCAAmB,CAAA;IACnB;;OAEG;IACH,8BAAiB,CAAA;IACjB;;OAEG;IACH,sCAAyB,CAAA;IACzB;;;;;OAKG;IACH,wCAA2B,CAAA;IAC3B;;;;OAIG;IACH,8BAAiB,CAAA;AACnB,CAAC,EA/BW,SAAS,KAAT,SAAS,QA+BpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;AACrB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;AACrB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { BoundingBox } from '../Collision/BoundingBox';
|
|
2
|
+
import { Color } from '../Color';
|
|
3
|
+
import { line } from '../Util/DrawUtil';
|
|
4
|
+
import { ExcaliburGraphicsContextWebGL } from './Context/ExcaliburGraphicsContextWebGL';
|
|
5
|
+
export class FontTextInstance {
|
|
6
|
+
constructor(font, text, color, maxWidth) {
|
|
7
|
+
this.font = font;
|
|
8
|
+
this.text = text;
|
|
9
|
+
this.color = color;
|
|
10
|
+
this.maxWidth = maxWidth;
|
|
11
|
+
this._textFragments = [];
|
|
12
|
+
this.disposed = false;
|
|
13
|
+
this._dirty = true;
|
|
14
|
+
this.canvas = document.createElement('canvas');
|
|
15
|
+
this.ctx = this.canvas.getContext('2d');
|
|
16
|
+
this.dimensions = this.measureText(text);
|
|
17
|
+
this._setDimension(this.dimensions, this.ctx);
|
|
18
|
+
this._lastHashCode = this.getHashCode();
|
|
19
|
+
}
|
|
20
|
+
measureText(text, maxWidth) {
|
|
21
|
+
if (this.disposed) {
|
|
22
|
+
throw Error('Accessing disposed text instance! ' + this.text);
|
|
23
|
+
}
|
|
24
|
+
let lines = null;
|
|
25
|
+
if (maxWidth != null) {
|
|
26
|
+
lines = this._getLinesFromText(text, maxWidth);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
lines = text.split('\n');
|
|
30
|
+
}
|
|
31
|
+
const maxWidthLine = lines.reduce((a, b) => {
|
|
32
|
+
return a.length > b.length ? a : b;
|
|
33
|
+
});
|
|
34
|
+
this._applyFont(this.ctx); // font must be applied to the context to measure it
|
|
35
|
+
const metrics = this.ctx.measureText(maxWidthLine);
|
|
36
|
+
let textHeight = Math.abs(metrics.actualBoundingBoxAscent) + Math.abs(metrics.actualBoundingBoxDescent);
|
|
37
|
+
// TODO lineheight makes the text bounds wonky
|
|
38
|
+
const lineAdjustedHeight = textHeight * lines.length;
|
|
39
|
+
textHeight = lineAdjustedHeight;
|
|
40
|
+
const bottomBounds = lineAdjustedHeight - Math.abs(metrics.actualBoundingBoxAscent);
|
|
41
|
+
const x = 0;
|
|
42
|
+
const y = 0;
|
|
43
|
+
const measurement = new BoundingBox({
|
|
44
|
+
left: x - Math.abs(metrics.actualBoundingBoxLeft) - this.font.padding,
|
|
45
|
+
top: y - Math.abs(metrics.actualBoundingBoxAscent) - this.font.padding,
|
|
46
|
+
bottom: y + bottomBounds + this.font.padding,
|
|
47
|
+
right: x + Math.abs(metrics.actualBoundingBoxRight) + this.font.padding
|
|
48
|
+
});
|
|
49
|
+
return measurement;
|
|
50
|
+
}
|
|
51
|
+
_setDimension(textBounds, bitmap) {
|
|
52
|
+
// Changing the width and height clears the context properties
|
|
53
|
+
// We double the bitmap width to account for all possible alignment
|
|
54
|
+
// We scale by "quality" so we render text without jaggies
|
|
55
|
+
bitmap.canvas.width = (textBounds.width + this.font.padding * 2) * 2 * this.font.quality;
|
|
56
|
+
bitmap.canvas.height = (textBounds.height + this.font.padding * 2) * 2 * this.font.quality;
|
|
57
|
+
}
|
|
58
|
+
static getHashCode(font, text, color) {
|
|
59
|
+
var _a;
|
|
60
|
+
const hash = text +
|
|
61
|
+
'__hashcode__' +
|
|
62
|
+
font.fontString +
|
|
63
|
+
font.showDebug +
|
|
64
|
+
font.textAlign +
|
|
65
|
+
font.baseAlign +
|
|
66
|
+
font.direction +
|
|
67
|
+
JSON.stringify(font.shadow) +
|
|
68
|
+
(font.padding.toString() +
|
|
69
|
+
font.smoothing.toString() +
|
|
70
|
+
font.lineWidth.toString() +
|
|
71
|
+
font.lineDash.toString() +
|
|
72
|
+
((_a = font.strokeColor) === null || _a === void 0 ? void 0 : _a.toString()) +
|
|
73
|
+
(color ? color.toString() : font.color.toString()));
|
|
74
|
+
return hash;
|
|
75
|
+
}
|
|
76
|
+
getHashCode(includeColor = true) {
|
|
77
|
+
return FontTextInstance.getHashCode(this.font, this.text, includeColor ? this.color : undefined);
|
|
78
|
+
}
|
|
79
|
+
_applyRasterProperties(ctx) {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
ctx.translate(this.font.padding, this.font.padding);
|
|
82
|
+
ctx.imageSmoothingEnabled = this.font.smoothing;
|
|
83
|
+
ctx.lineWidth = this.font.lineWidth;
|
|
84
|
+
ctx.setLineDash((_a = this.font.lineDash) !== null && _a !== void 0 ? _a : ctx.getLineDash());
|
|
85
|
+
ctx.strokeStyle = (_b = this.font.strokeColor) === null || _b === void 0 ? void 0 : _b.toString();
|
|
86
|
+
ctx.fillStyle = this.color.toString();
|
|
87
|
+
}
|
|
88
|
+
_applyFont(ctx) {
|
|
89
|
+
ctx.resetTransform();
|
|
90
|
+
ctx.translate(this.font.padding + ctx.canvas.width / 2, this.font.padding + ctx.canvas.height / 2);
|
|
91
|
+
ctx.scale(this.font.quality, this.font.quality);
|
|
92
|
+
ctx.textAlign = this.font.textAlign;
|
|
93
|
+
ctx.textBaseline = this.font.baseAlign;
|
|
94
|
+
ctx.font = this.font.fontString;
|
|
95
|
+
ctx.direction = this.font.direction;
|
|
96
|
+
if (this.font.shadow) {
|
|
97
|
+
ctx.shadowColor = this.font.shadow.color.toString();
|
|
98
|
+
ctx.shadowBlur = this.font.shadow.blur;
|
|
99
|
+
ctx.shadowOffsetX = this.font.shadow.offset.x;
|
|
100
|
+
ctx.shadowOffsetY = this.font.shadow.offset.y;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
_drawText(ctx, lines, lineHeight) {
|
|
104
|
+
this._applyRasterProperties(ctx);
|
|
105
|
+
this._applyFont(ctx);
|
|
106
|
+
for (let i = 0; i < lines.length; i++) {
|
|
107
|
+
const line = lines[i];
|
|
108
|
+
if (this.color) {
|
|
109
|
+
ctx.fillText(line, 0, i * lineHeight);
|
|
110
|
+
}
|
|
111
|
+
if (this.font.strokeColor) {
|
|
112
|
+
ctx.strokeText(line, 0, i * lineHeight);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (this.font.showDebug) {
|
|
116
|
+
// Horizontal line
|
|
117
|
+
/* istanbul ignore next */
|
|
118
|
+
line(ctx, Color.Green, -ctx.canvas.width / 2, 0, ctx.canvas.width / 2, 0, 2);
|
|
119
|
+
// Vertical line
|
|
120
|
+
/* istanbul ignore next */
|
|
121
|
+
line(ctx, Color.Red, 0, -ctx.canvas.height / 2, 0, ctx.canvas.height / 2, 2);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
_splitTextBitmap(bitmap) {
|
|
125
|
+
const textImages = [];
|
|
126
|
+
let currentX = 0;
|
|
127
|
+
let currentY = 0;
|
|
128
|
+
// 4k is the max for mobile devices
|
|
129
|
+
const width = Math.min(4096, bitmap.canvas.width);
|
|
130
|
+
const height = Math.min(4096, bitmap.canvas.height);
|
|
131
|
+
// Splits the original bitmap into 4k max chunks
|
|
132
|
+
while (currentX < bitmap.canvas.width) {
|
|
133
|
+
while (currentY < bitmap.canvas.height) {
|
|
134
|
+
// create new bitmap
|
|
135
|
+
const canvas = document.createElement('canvas');
|
|
136
|
+
canvas.width = width;
|
|
137
|
+
canvas.height = height;
|
|
138
|
+
const ctx = canvas.getContext('2d');
|
|
139
|
+
// draw current slice to new bitmap in < 4k chunks
|
|
140
|
+
ctx.drawImage(bitmap.canvas, currentX, currentY, width, height, 0, 0, width, height);
|
|
141
|
+
textImages.push({ x: currentX, y: currentY, canvas });
|
|
142
|
+
currentY += height;
|
|
143
|
+
}
|
|
144
|
+
currentX += width;
|
|
145
|
+
currentY = 0;
|
|
146
|
+
}
|
|
147
|
+
return textImages;
|
|
148
|
+
}
|
|
149
|
+
flagDirty() {
|
|
150
|
+
this._dirty = true;
|
|
151
|
+
}
|
|
152
|
+
render(ex, x, y, maxWidth) {
|
|
153
|
+
if (this.disposed) {
|
|
154
|
+
throw Error('Accessing disposed text instance! ' + this.text);
|
|
155
|
+
}
|
|
156
|
+
this._ex = ex;
|
|
157
|
+
const hashCode = this.getHashCode();
|
|
158
|
+
if (this._lastHashCode !== hashCode) {
|
|
159
|
+
this._dirty = true;
|
|
160
|
+
}
|
|
161
|
+
// Calculate image chunks
|
|
162
|
+
if (this._dirty) {
|
|
163
|
+
this.dimensions = this.measureText(this.text, maxWidth);
|
|
164
|
+
this._setDimension(this.dimensions, this.ctx);
|
|
165
|
+
const lines = this._getLinesFromText(this.text, maxWidth);
|
|
166
|
+
const lineHeight = this.dimensions.height / lines.length;
|
|
167
|
+
// draws the text to the main bitmap
|
|
168
|
+
this._drawText(this.ctx, lines, lineHeight);
|
|
169
|
+
// clear any out old fragments
|
|
170
|
+
if (ex instanceof ExcaliburGraphicsContextWebGL) {
|
|
171
|
+
for (const frag of this._textFragments) {
|
|
172
|
+
ex.textureLoader.delete(frag.canvas);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// splits to < 4k fragments for large text
|
|
176
|
+
this._textFragments = this._splitTextBitmap(this.ctx);
|
|
177
|
+
if (ex instanceof ExcaliburGraphicsContextWebGL) {
|
|
178
|
+
for (const frag of this._textFragments) {
|
|
179
|
+
ex.textureLoader.load(frag.canvas, this.font.filtering, true);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
this._lastHashCode = hashCode;
|
|
183
|
+
this._dirty = false;
|
|
184
|
+
}
|
|
185
|
+
// draws the bitmap fragments to excalibur graphics context
|
|
186
|
+
for (const frag of this._textFragments) {
|
|
187
|
+
ex.drawImage(frag.canvas, 0, 0, frag.canvas.width, frag.canvas.height, frag.x / this.font.quality + x - this.ctx.canvas.width / this.font.quality / 2, frag.y / this.font.quality + y - this.ctx.canvas.height / this.font.quality / 2, frag.canvas.width / this.font.quality, frag.canvas.height / this.font.quality);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
dispose() {
|
|
191
|
+
this.disposed = true;
|
|
192
|
+
this.dimensions = undefined;
|
|
193
|
+
this.canvas = undefined;
|
|
194
|
+
this.ctx = undefined;
|
|
195
|
+
if (this._ex instanceof ExcaliburGraphicsContextWebGL) {
|
|
196
|
+
for (const frag of this._textFragments) {
|
|
197
|
+
this._ex.textureLoader.delete(frag.canvas);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
this._textFragments.length = 0;
|
|
201
|
+
}
|
|
202
|
+
_getLinesFromText(text, maxWidth) {
|
|
203
|
+
if (this._chachedText === text && this._cachedRenderWidth === maxWidth) {
|
|
204
|
+
return this._chachedLines;
|
|
205
|
+
}
|
|
206
|
+
const lines = text.split('\n');
|
|
207
|
+
if (maxWidth == null) {
|
|
208
|
+
return lines;
|
|
209
|
+
}
|
|
210
|
+
// If the current line goes past the maxWidth, append a new line without modifying the underlying text.
|
|
211
|
+
for (let i = 0; i < lines.length; i++) {
|
|
212
|
+
let line = lines[i];
|
|
213
|
+
let newLine = '';
|
|
214
|
+
if (this.measureText(line).width > maxWidth) {
|
|
215
|
+
while (this.measureText(line).width > maxWidth) {
|
|
216
|
+
newLine = line[line.length - 1] + newLine;
|
|
217
|
+
line = line.slice(0, -1); // Remove last character from line
|
|
218
|
+
}
|
|
219
|
+
// Update the array with our new values
|
|
220
|
+
lines[i] = line;
|
|
221
|
+
lines[i + 1] = newLine;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
this._chachedText = text;
|
|
225
|
+
this._chachedLines = lines;
|
|
226
|
+
this._cachedRenderWidth = maxWidth;
|
|
227
|
+
return lines;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=FontTextInstance.js.map
|