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,52 @@
|
|
|
1
|
+
import colorBlindCorrectSource from './color-blind-fragment.glsl';
|
|
2
|
+
import { ColorBlindnessMode } from './ColorBlindnessMode';
|
|
3
|
+
import { ScreenShader } from './ScreenShader';
|
|
4
|
+
export class ColorBlindnessPostProcessor {
|
|
5
|
+
constructor(_colorBlindnessMode, simulate = false) {
|
|
6
|
+
this._colorBlindnessMode = _colorBlindnessMode;
|
|
7
|
+
this._simulate = false;
|
|
8
|
+
this._simulate = simulate;
|
|
9
|
+
}
|
|
10
|
+
initialize(gl) {
|
|
11
|
+
this._shader = new ScreenShader(gl, colorBlindCorrectSource);
|
|
12
|
+
this.simulate = this._simulate;
|
|
13
|
+
this.colorBlindnessMode = this._colorBlindnessMode;
|
|
14
|
+
}
|
|
15
|
+
getShader() {
|
|
16
|
+
return this._shader.getShader();
|
|
17
|
+
}
|
|
18
|
+
getLayout() {
|
|
19
|
+
return this._shader.getLayout();
|
|
20
|
+
}
|
|
21
|
+
set colorBlindnessMode(colorBlindMode) {
|
|
22
|
+
this._colorBlindnessMode = colorBlindMode;
|
|
23
|
+
if (this._shader) {
|
|
24
|
+
const shader = this._shader.getShader();
|
|
25
|
+
shader.use();
|
|
26
|
+
if (this._colorBlindnessMode === ColorBlindnessMode.Protanope) {
|
|
27
|
+
shader.setUniformInt('u_type', 0);
|
|
28
|
+
}
|
|
29
|
+
else if (this._colorBlindnessMode === ColorBlindnessMode.Deuteranope) {
|
|
30
|
+
shader.setUniformInt('u_type', 1);
|
|
31
|
+
}
|
|
32
|
+
else if (this._colorBlindnessMode === ColorBlindnessMode.Tritanope) {
|
|
33
|
+
shader.setUniformInt('u_type', 2);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
get colorBlindnessMode() {
|
|
38
|
+
return this._colorBlindnessMode;
|
|
39
|
+
}
|
|
40
|
+
set simulate(value) {
|
|
41
|
+
this._simulate = value;
|
|
42
|
+
if (this._shader) {
|
|
43
|
+
const shader = this._shader.getShader();
|
|
44
|
+
shader.use();
|
|
45
|
+
shader.setUniformBoolean('u_simulate', value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
get simulate() {
|
|
49
|
+
return this._simulate;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ColorBlindnessPostProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorBlindnessPostProcessor.js","sourceRoot":"","sources":["../../../../src/engine/Graphics/PostProcessor/ColorBlindnessPostProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,OAAO,2BAA2B;IAGtC,YAAoB,mBAAuC,EAAE,QAAQ,GAAG,KAAK;QAAzD,wBAAmB,GAAnB,mBAAmB,CAAoB;QADnD,cAAS,GAAG,KAAK,CAAC;QAExB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,UAAU,CAAC,EAA0B;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,EAAE,EAAE,uBAAuB,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC;IACrD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAClC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,kBAAkB,CAAC,cAAkC;QACvD,IAAI,CAAC,mBAAmB,GAAG,cAAc,CAAC;QAC1C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,mBAAmB,KAAK,kBAAkB,CAAC,SAAS,EAAE,CAAC;gBAC9D,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACpC,CAAC;iBAAM,IAAI,IAAI,CAAC,mBAAmB,KAAK,kBAAkB,CAAC,WAAW,EAAE,CAAC;gBACvE,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACpC,CAAC;iBAAM,IAAI,IAAI,CAAC,mBAAmB,KAAK,kBAAkB,CAAC,SAAS,EAAE,CAAC;gBACrE,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAEjB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,iBAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostProcessor.js","sourceRoot":"","sources":["../../../../src/engine/Graphics/PostProcessor/PostProcessor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Shader } from '../Context/shader';
|
|
2
|
+
import { VertexBuffer } from '../Context/vertex-buffer';
|
|
3
|
+
import { VertexLayout } from '../Context/vertex-layout';
|
|
4
|
+
/**
|
|
5
|
+
* Helper that defines a whole screen renderer, just provide a fragment source!
|
|
6
|
+
*
|
|
7
|
+
* Currently supports 1 varying
|
|
8
|
+
* - vec2 a_texcoord between 0-1 which corresponds to screen position
|
|
9
|
+
*/
|
|
10
|
+
export class ScreenShader {
|
|
11
|
+
constructor(gl, fragmentSource) {
|
|
12
|
+
this._shader = new Shader({
|
|
13
|
+
gl,
|
|
14
|
+
vertexSource: `#version 300 es
|
|
15
|
+
in vec2 a_position;
|
|
16
|
+
in vec2 a_texcoord;
|
|
17
|
+
out vec2 v_texcoord;
|
|
18
|
+
|
|
19
|
+
void main() {
|
|
20
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
21
|
+
// Pass the texcoord to the fragment shader.
|
|
22
|
+
v_texcoord = a_texcoord;
|
|
23
|
+
}`,
|
|
24
|
+
fragmentSource: fragmentSource
|
|
25
|
+
});
|
|
26
|
+
this._shader.compile();
|
|
27
|
+
// Setup memory layout
|
|
28
|
+
this._buffer = new VertexBuffer({
|
|
29
|
+
gl,
|
|
30
|
+
type: 'static',
|
|
31
|
+
// clip space quad + uv since we don't need a camera
|
|
32
|
+
data: new Float32Array([
|
|
33
|
+
-1, -1, 0, 0,
|
|
34
|
+
-1, 1, 0, 1,
|
|
35
|
+
1, -1, 1, 0,
|
|
36
|
+
1, -1, 1, 0,
|
|
37
|
+
-1, 1, 0, 1,
|
|
38
|
+
1, 1, 1, 1
|
|
39
|
+
])
|
|
40
|
+
});
|
|
41
|
+
this._layout = new VertexLayout({
|
|
42
|
+
gl,
|
|
43
|
+
shader: this._shader,
|
|
44
|
+
vertexBuffer: this._buffer,
|
|
45
|
+
attributes: [
|
|
46
|
+
['a_position', 2],
|
|
47
|
+
['a_texcoord', 2]
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
this._buffer.upload();
|
|
51
|
+
}
|
|
52
|
+
getShader() {
|
|
53
|
+
return this._shader;
|
|
54
|
+
}
|
|
55
|
+
getLayout() {
|
|
56
|
+
return this._layout;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ScreenShader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreenShader.js","sourceRoot":"","sources":["../../../../src/engine/Graphics/PostProcessor/ScreenShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAIvB,YAAY,EAA0B,EAAE,cAAsB;QAC5D,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC;YACxB,EAAE;YACF,YAAY,EAAE;;;;;;;;;QASZ;YACF,cAAc,EAAE,cAAc;SAC/B,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,sBAAsB;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC;YAC9B,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,oDAAoD;YACpD,IAAI,EAAE,IAAI,YAAY,CAAC;gBACrB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAW,CAAC,EAAE,CAAC;gBACrB,CAAC,CAAC,EAAE,CAAC,EAAY,CAAC,EAAE,CAAC;gBACrB,CAAC,EAAE,CAAC,CAAC,EAAY,CAAC,EAAE,CAAC;gBAErB,CAAC,EAAE,CAAC,CAAC,EAAa,CAAC,EAAE,CAAC;gBACtB,CAAC,CAAC,EAAE,CAAC,EAAY,CAAC,EAAE,CAAC;gBACrB,CAAC,EAAE,CAAC,EAAa,CAAC,EAAE,CAAC;aACtB,CAAC;SACH,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC;YAC9B,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,YAAY,EAAE,IAAI,CAAC,OAAO;YAC1B,UAAU,EAAE;gBACV,CAAC,YAAY,EAAE,CAAC,CAAC;gBACjB,CAAC,YAAY,EAAE,CAAC,CAAC;aAClB;SACF,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACM,SAAS;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
#version 300 es
|
|
2
|
-
precision mediump float;
|
|
3
|
-
// our texture
|
|
4
|
-
uniform sampler2D u_image;
|
|
5
|
-
// the texCoords passed in from the vertex shader.
|
|
6
|
-
in vec2 v_texcoord;
|
|
7
|
-
|
|
8
|
-
// color blind type
|
|
9
|
-
uniform int u_type;
|
|
10
|
-
|
|
11
|
-
// simulation?
|
|
12
|
-
uniform bool u_simulate;
|
|
13
|
-
|
|
14
|
-
out vec4 fragColor;
|
|
15
|
-
|
|
16
|
-
void main() {
|
|
17
|
-
vec4 o = texture(u_image, v_texcoord);
|
|
18
|
-
// RGB to LMS matrix conversion
|
|
19
|
-
float L = (17.8824 * o.r) + (43.5161 * o.g) + (4.11935 * o.b);
|
|
20
|
-
float M = (3.45565 * o.r) + (27.1554 * o.g) + (3.86714 * o.b);
|
|
21
|
-
float S = (0.0299566 * o.r) + (0.184309 * o.g) + (1.46709 * o.b);
|
|
22
|
-
// Simulate color blindness
|
|
23
|
-
float l;
|
|
24
|
-
float m;
|
|
25
|
-
float s;
|
|
26
|
-
//MODE CODE//
|
|
27
|
-
if (u_type == 0) {
|
|
28
|
-
// Protanope
|
|
29
|
-
l = 0.0 * L + 2.02344 * M + -2.52581 * S;
|
|
30
|
-
m = 0.0 * L + 1.0 * M + 0.0 * S;
|
|
31
|
-
s = 0.0 * L + 0.0 * M + 1.0 * S;;
|
|
32
|
-
} else if (u_type == 1) {
|
|
33
|
-
// Deuteranope
|
|
34
|
-
l = 1.0 * L + 0.0 * M + 0.0 * S;
|
|
35
|
-
m = 0.494207 * L + 0.0 * M + 1.24827 * S;
|
|
36
|
-
s = 0.0 * L + 0.0 * M + 1.0 * S;
|
|
37
|
-
} else if (u_type == 2) {
|
|
38
|
-
// Tritanope
|
|
39
|
-
l = 1.0 * L + 0.0 * M + 0.0 * S;
|
|
40
|
-
m = 0.0 * L + 1.0 * M + 0.0 * S;
|
|
41
|
-
s = -0.395913 * L + 0.801109 * M + 0.0 * S;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// LMS to RGB matrix conversion
|
|
45
|
-
vec4 error; // simulate the colors
|
|
46
|
-
error.r = (0.0809444479 * l) + (-0.130504409 * m) + (0.116721066 * s);
|
|
47
|
-
error.g = (-0.0102485335 * l) + (0.0540193266 * m) + (-0.113614708 * s);
|
|
48
|
-
error.b = (-0.000365296938 * l) + (-0.00412161469 * m) + (0.693511405 * s);
|
|
49
|
-
error.a = 1.0;
|
|
50
|
-
vec4 diff = o - error;
|
|
51
|
-
vec4 correction; // correct the colors
|
|
52
|
-
correction.r = 0.0;
|
|
53
|
-
correction.g = (diff.r * 0.7) + (diff.g * 1.0);
|
|
54
|
-
correction.b = (diff.r * 0.7) + (diff.b * 1.0);
|
|
55
|
-
correction = o + correction;
|
|
56
|
-
correction.a = o.a;
|
|
57
|
-
//SIMULATE//
|
|
58
|
-
|
|
59
|
-
// sim
|
|
60
|
-
if (u_simulate) {
|
|
61
|
-
fragColor = error.rgba;
|
|
62
|
-
} else {
|
|
63
|
-
fragColor = correction.rgba;
|
|
64
|
-
}
|
|
1
|
+
#version 300 es
|
|
2
|
+
precision mediump float;
|
|
3
|
+
// our texture
|
|
4
|
+
uniform sampler2D u_image;
|
|
5
|
+
// the texCoords passed in from the vertex shader.
|
|
6
|
+
in vec2 v_texcoord;
|
|
7
|
+
|
|
8
|
+
// color blind type
|
|
9
|
+
uniform int u_type;
|
|
10
|
+
|
|
11
|
+
// simulation?
|
|
12
|
+
uniform bool u_simulate;
|
|
13
|
+
|
|
14
|
+
out vec4 fragColor;
|
|
15
|
+
|
|
16
|
+
void main() {
|
|
17
|
+
vec4 o = texture(u_image, v_texcoord);
|
|
18
|
+
// RGB to LMS matrix conversion
|
|
19
|
+
float L = (17.8824 * o.r) + (43.5161 * o.g) + (4.11935 * o.b);
|
|
20
|
+
float M = (3.45565 * o.r) + (27.1554 * o.g) + (3.86714 * o.b);
|
|
21
|
+
float S = (0.0299566 * o.r) + (0.184309 * o.g) + (1.46709 * o.b);
|
|
22
|
+
// Simulate color blindness
|
|
23
|
+
float l;
|
|
24
|
+
float m;
|
|
25
|
+
float s;
|
|
26
|
+
//MODE CODE//
|
|
27
|
+
if (u_type == 0) {
|
|
28
|
+
// Protanope
|
|
29
|
+
l = 0.0 * L + 2.02344 * M + -2.52581 * S;
|
|
30
|
+
m = 0.0 * L + 1.0 * M + 0.0 * S;
|
|
31
|
+
s = 0.0 * L + 0.0 * M + 1.0 * S;;
|
|
32
|
+
} else if (u_type == 1) {
|
|
33
|
+
// Deuteranope
|
|
34
|
+
l = 1.0 * L + 0.0 * M + 0.0 * S;
|
|
35
|
+
m = 0.494207 * L + 0.0 * M + 1.24827 * S;
|
|
36
|
+
s = 0.0 * L + 0.0 * M + 1.0 * S;
|
|
37
|
+
} else if (u_type == 2) {
|
|
38
|
+
// Tritanope
|
|
39
|
+
l = 1.0 * L + 0.0 * M + 0.0 * S;
|
|
40
|
+
m = 0.0 * L + 1.0 * M + 0.0 * S;
|
|
41
|
+
s = -0.395913 * L + 0.801109 * M + 0.0 * S;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// LMS to RGB matrix conversion
|
|
45
|
+
vec4 error; // simulate the colors
|
|
46
|
+
error.r = (0.0809444479 * l) + (-0.130504409 * m) + (0.116721066 * s);
|
|
47
|
+
error.g = (-0.0102485335 * l) + (0.0540193266 * m) + (-0.113614708 * s);
|
|
48
|
+
error.b = (-0.000365296938 * l) + (-0.00412161469 * m) + (0.693511405 * s);
|
|
49
|
+
error.a = 1.0;
|
|
50
|
+
vec4 diff = o - error;
|
|
51
|
+
vec4 correction; // correct the colors
|
|
52
|
+
correction.r = 0.0;
|
|
53
|
+
correction.g = (diff.r * 0.7) + (diff.g * 1.0);
|
|
54
|
+
correction.b = (diff.r * 0.7) + (diff.b * 1.0);
|
|
55
|
+
correction = o + correction;
|
|
56
|
+
correction.a = o.a;
|
|
57
|
+
//SIMULATE//
|
|
58
|
+
|
|
59
|
+
// sim
|
|
60
|
+
if (u_simulate) {
|
|
61
|
+
fragColor = error.rgba;
|
|
62
|
+
} else {
|
|
63
|
+
fragColor = correction.rgba;
|
|
64
|
+
}
|
|
65
65
|
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { Graphic } from './Graphic';
|
|
2
|
+
import { Color } from '../Color';
|
|
3
|
+
import { Vector } from '../Math/vector';
|
|
4
|
+
import { BoundingBox } from '../Collision/BoundingBox';
|
|
5
|
+
import { watch } from '../Util/Watch';
|
|
6
|
+
import { omit } from '../Util/Util';
|
|
7
|
+
/**
|
|
8
|
+
* A Raster is a Graphic that needs to be first painted to a HTMLCanvasElement before it can be drawn to the
|
|
9
|
+
* [[ExcaliburGraphicsContext]]. This is useful for generating custom images using the 2D canvas api.
|
|
10
|
+
*
|
|
11
|
+
* Implementors must implement the [[Raster.execute]] method to rasterize their drawing.
|
|
12
|
+
*/
|
|
13
|
+
export class Raster extends Graphic {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
16
|
+
super(omit(options, ['width', 'height'])); // rasters do some special sauce with width/height
|
|
17
|
+
this.filtering = null;
|
|
18
|
+
this.lineCap = 'butt';
|
|
19
|
+
this.quality = 1;
|
|
20
|
+
this._dirty = true;
|
|
21
|
+
this._smoothing = false;
|
|
22
|
+
this._color = watch(Color.Black, () => this.flagDirty());
|
|
23
|
+
this._lineWidth = 1;
|
|
24
|
+
this._lineDash = [];
|
|
25
|
+
this._padding = 0;
|
|
26
|
+
if (options) {
|
|
27
|
+
this.quality = (_a = options.quality) !== null && _a !== void 0 ? _a : this.quality;
|
|
28
|
+
this.color = (_b = options.color) !== null && _b !== void 0 ? _b : Color.Black;
|
|
29
|
+
this.strokeColor = options === null || options === void 0 ? void 0 : options.strokeColor;
|
|
30
|
+
this.smoothing = (_c = options.smoothing) !== null && _c !== void 0 ? _c : this.smoothing;
|
|
31
|
+
this.lineWidth = (_d = options.lineWidth) !== null && _d !== void 0 ? _d : this.lineWidth;
|
|
32
|
+
this.lineDash = (_e = options.lineDash) !== null && _e !== void 0 ? _e : this.lineDash;
|
|
33
|
+
this.lineCap = (_f = options.lineCap) !== null && _f !== void 0 ? _f : this.lineCap;
|
|
34
|
+
this.padding = (_g = options.padding) !== null && _g !== void 0 ? _g : this.padding;
|
|
35
|
+
this.filtering = (_h = options.filtering) !== null && _h !== void 0 ? _h : this.filtering;
|
|
36
|
+
}
|
|
37
|
+
this._bitmap = document.createElement('canvas');
|
|
38
|
+
// get the default canvas width/height as a fallback
|
|
39
|
+
const bitmapWidth = (_j = options === null || options === void 0 ? void 0 : options.width) !== null && _j !== void 0 ? _j : this._bitmap.width;
|
|
40
|
+
const bitmapHeight = (_k = options === null || options === void 0 ? void 0 : options.height) !== null && _k !== void 0 ? _k : this._bitmap.height;
|
|
41
|
+
this.width = bitmapWidth;
|
|
42
|
+
this.height = bitmapHeight;
|
|
43
|
+
const maybeCtx = this._bitmap.getContext('2d');
|
|
44
|
+
if (!maybeCtx) {
|
|
45
|
+
/* istanbul ignore next */
|
|
46
|
+
throw new Error('Browser does not support 2d canvas drawing, cannot create Raster graphic');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._ctx = maybeCtx;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
cloneRasterOptions() {
|
|
53
|
+
return {
|
|
54
|
+
color: this.color ? this.color.clone() : null,
|
|
55
|
+
strokeColor: this.strokeColor ? this.strokeColor.clone() : null,
|
|
56
|
+
smoothing: this.smoothing,
|
|
57
|
+
lineWidth: this.lineWidth,
|
|
58
|
+
lineDash: this.lineDash,
|
|
59
|
+
lineCap: this.lineCap,
|
|
60
|
+
quality: this.quality,
|
|
61
|
+
padding: this.padding
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets whether the graphic is dirty, this means there are changes that haven't been re-rasterized
|
|
66
|
+
*/
|
|
67
|
+
get dirty() {
|
|
68
|
+
return this._dirty;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Flags the graphic as dirty, meaning it must be re-rasterized before draw.
|
|
72
|
+
* This should be called any time the graphics state changes such that it affects the outputted drawing
|
|
73
|
+
*/
|
|
74
|
+
flagDirty() {
|
|
75
|
+
this._dirty = true;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets or sets the current width of the Raster graphic. Setting the width will cause the raster
|
|
79
|
+
* to be flagged dirty causing a re-raster on the next draw.
|
|
80
|
+
*
|
|
81
|
+
* Any `padding`s or `quality` set will be factored into the width
|
|
82
|
+
*/
|
|
83
|
+
get width() {
|
|
84
|
+
return Math.abs(this._getTotalWidth() * this.scale.x);
|
|
85
|
+
}
|
|
86
|
+
set width(value) {
|
|
87
|
+
value /= Math.abs(this.scale.x);
|
|
88
|
+
this._bitmap.width = value;
|
|
89
|
+
this._originalWidth = value;
|
|
90
|
+
this.flagDirty();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets or sets the current height of the Raster graphic. Setting the height will cause the raster
|
|
94
|
+
* to be flagged dirty causing a re-raster on the next draw.
|
|
95
|
+
*
|
|
96
|
+
* Any `padding` or `quality` set will be factored into the height
|
|
97
|
+
*/
|
|
98
|
+
get height() {
|
|
99
|
+
return Math.abs(this._getTotalHeight() * this.scale.y);
|
|
100
|
+
}
|
|
101
|
+
set height(value) {
|
|
102
|
+
value /= Math.abs(this.scale.y);
|
|
103
|
+
this._bitmap.height = value;
|
|
104
|
+
this._originalHeight = value;
|
|
105
|
+
this.flagDirty();
|
|
106
|
+
}
|
|
107
|
+
_getTotalWidth() {
|
|
108
|
+
var _a;
|
|
109
|
+
return (((_a = this._originalWidth) !== null && _a !== void 0 ? _a : this._bitmap.width) + this.padding * 2) * 1;
|
|
110
|
+
}
|
|
111
|
+
_getTotalHeight() {
|
|
112
|
+
var _a;
|
|
113
|
+
return (((_a = this._originalHeight) !== null && _a !== void 0 ? _a : this._bitmap.height) + this.padding * 2) * 1;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns the local bounds of the Raster including the padding
|
|
117
|
+
*/
|
|
118
|
+
get localBounds() {
|
|
119
|
+
return BoundingBox.fromDimension(this._getTotalWidth() * this.scale.x, this._getTotalHeight() * this.scale.y, Vector.Zero);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets or sets the smoothing (anti-aliasing of the graphic). Setting the height will cause the raster
|
|
123
|
+
* to be flagged dirty causing a re-raster on the next draw.
|
|
124
|
+
*/
|
|
125
|
+
get smoothing() {
|
|
126
|
+
return this._smoothing;
|
|
127
|
+
}
|
|
128
|
+
set smoothing(value) {
|
|
129
|
+
this._smoothing = value;
|
|
130
|
+
this.flagDirty();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Gets or sets the fillStyle of the Raster graphic. Setting the fillStyle will cause the raster to be
|
|
134
|
+
* flagged dirty causing a re-raster on the next draw.
|
|
135
|
+
*/
|
|
136
|
+
get color() {
|
|
137
|
+
return this._color;
|
|
138
|
+
}
|
|
139
|
+
set color(value) {
|
|
140
|
+
this.flagDirty();
|
|
141
|
+
this._color = watch(value, () => this.flagDirty());
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Gets or sets the strokeStyle of the Raster graphic. Setting the strokeStyle will cause the raster to be
|
|
145
|
+
* flagged dirty causing a re-raster on the next draw.
|
|
146
|
+
*/
|
|
147
|
+
get strokeColor() {
|
|
148
|
+
return this._strokeColor;
|
|
149
|
+
}
|
|
150
|
+
set strokeColor(value) {
|
|
151
|
+
this.flagDirty();
|
|
152
|
+
this._strokeColor = watch(value, () => this.flagDirty());
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Gets or sets the line width of the Raster graphic. Setting the lineWidth will cause the raster to be
|
|
156
|
+
* flagged dirty causing a re-raster on the next draw.
|
|
157
|
+
*/
|
|
158
|
+
get lineWidth() {
|
|
159
|
+
return this._lineWidth;
|
|
160
|
+
}
|
|
161
|
+
set lineWidth(value) {
|
|
162
|
+
this._lineWidth = value;
|
|
163
|
+
this.flagDirty();
|
|
164
|
+
}
|
|
165
|
+
get lineDash() {
|
|
166
|
+
return this._lineDash;
|
|
167
|
+
}
|
|
168
|
+
set lineDash(value) {
|
|
169
|
+
this._lineDash = value;
|
|
170
|
+
this.flagDirty();
|
|
171
|
+
}
|
|
172
|
+
get padding() {
|
|
173
|
+
return this._padding;
|
|
174
|
+
}
|
|
175
|
+
set padding(value) {
|
|
176
|
+
this._padding = value;
|
|
177
|
+
this.flagDirty();
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Rasterize the graphic to a bitmap making it usable as in excalibur. Rasterize is called automatically if
|
|
181
|
+
* the graphic is [[Raster.dirty]] on the next [[Graphic.draw]] call
|
|
182
|
+
*/
|
|
183
|
+
rasterize() {
|
|
184
|
+
this._dirty = false;
|
|
185
|
+
this._ctx.clearRect(0, 0, this._getTotalWidth(), this._getTotalHeight());
|
|
186
|
+
this._ctx.save();
|
|
187
|
+
this._applyRasterProperties(this._ctx);
|
|
188
|
+
this.execute(this._ctx);
|
|
189
|
+
this._ctx.restore();
|
|
190
|
+
}
|
|
191
|
+
_applyRasterProperties(ctx) {
|
|
192
|
+
var _a, _b, _c;
|
|
193
|
+
this._bitmap.width = this._getTotalWidth() * this.quality;
|
|
194
|
+
this._bitmap.height = this._getTotalHeight() * this.quality;
|
|
195
|
+
// Do a bad thing to pass the filtering as an attribute
|
|
196
|
+
this._bitmap.setAttribute('filtering', this.filtering);
|
|
197
|
+
this._bitmap.setAttribute('forceUpload', 'true');
|
|
198
|
+
ctx.scale(this.quality, this.quality);
|
|
199
|
+
ctx.translate(this.padding, this.padding);
|
|
200
|
+
ctx.imageSmoothingEnabled = this.smoothing;
|
|
201
|
+
ctx.lineWidth = this.lineWidth;
|
|
202
|
+
ctx.setLineDash((_a = this.lineDash) !== null && _a !== void 0 ? _a : ctx.getLineDash());
|
|
203
|
+
ctx.lineCap = this.lineCap;
|
|
204
|
+
ctx.strokeStyle = (_b = this.strokeColor) === null || _b === void 0 ? void 0 : _b.toString();
|
|
205
|
+
ctx.fillStyle = (_c = this.color) === null || _c === void 0 ? void 0 : _c.toString();
|
|
206
|
+
}
|
|
207
|
+
_drawImage(ex, x, y) {
|
|
208
|
+
if (this._dirty) {
|
|
209
|
+
this.rasterize();
|
|
210
|
+
}
|
|
211
|
+
ex.scale(1 / this.quality, 1 / this.quality);
|
|
212
|
+
ex.drawImage(this._bitmap, x, y);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=Raster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Raster.js","sourceRoot":"","sources":["../../../src/engine/Graphics/Raster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAuDpC;;;;;GAKG;AACH,MAAM,OAAgB,MAAO,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YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACjD,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3C,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,GAAG,CAAC,WAAW,CAAC,MAAA,IAAI,CAAC,QAAQ,mCAAI,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QACpD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,GAAG,CAAC,WAAW,GAAG,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,EAAE,CAAC;QAC/C,GAAG,CAAC,SAAS,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAE,QAAQ,EAAE,CAAC;IACzC,CAAC;IAES,UAAU,CAAC,EAA4B,EAAE,CAAS,EAAE,CAAS;QACrE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC;QACD,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CAQF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Raster } from './Raster';
|
|
2
|
+
/**
|
|
3
|
+
* A Rectangle [[Graphic]] for drawing rectangles to the [[ExcaliburGraphicsContext]]
|
|
4
|
+
*/
|
|
5
|
+
export class Rectangle extends Raster {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
this.width = options.width;
|
|
9
|
+
this.height = options.height;
|
|
10
|
+
this.rasterize();
|
|
11
|
+
}
|
|
12
|
+
clone() {
|
|
13
|
+
return new Rectangle({
|
|
14
|
+
width: this.width,
|
|
15
|
+
height: this.height,
|
|
16
|
+
...this.cloneGraphicOptions(),
|
|
17
|
+
...this.cloneRasterOptions()
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
execute(ctx) {
|
|
21
|
+
if (this.color) {
|
|
22
|
+
ctx.fillRect(0, 0, this.width, this.height);
|
|
23
|
+
}
|
|
24
|
+
if (this.strokeColor) {
|
|
25
|
+
ctx.strokeRect(0, 0, this.width, this.height);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Rectangle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rectangle.js","sourceRoot":"","sources":["../../../src/engine/Graphics/Rectangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;AAOjD;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,YAAY,OAAyC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,SAAS,CAAC;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,IAAI,CAAC,mBAAmB,EAAE;YAC7B,GAAG,IAAI,CAAC,kBAAkB,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAA6B;QACnC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Graphic } from './Graphic';
|
|
2
|
+
import { Logger } from '../Util/Log';
|
|
3
|
+
export class Sprite extends Graphic {
|
|
4
|
+
static from(image) {
|
|
5
|
+
return new Sprite({
|
|
6
|
+
image: image
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
constructor(options) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
super(options);
|
|
12
|
+
this._logger = Logger.getInstance();
|
|
13
|
+
this._dirty = true;
|
|
14
|
+
this._logNotLoadedWarning = false;
|
|
15
|
+
this.image = options.image;
|
|
16
|
+
const { width, height } = options;
|
|
17
|
+
this.sourceView = (_a = options.sourceView) !== null && _a !== void 0 ? _a : { x: 0, y: 0, width: width !== null && width !== void 0 ? width : 0, height: height !== null && height !== void 0 ? height : 0 };
|
|
18
|
+
this.destSize = (_b = options.destSize) !== null && _b !== void 0 ? _b : { width: width !== null && width !== void 0 ? width : 0, height: height !== null && height !== void 0 ? height : 0 };
|
|
19
|
+
this._updateSpriteDimensions();
|
|
20
|
+
this.image.ready.then(() => {
|
|
21
|
+
this._updateSpriteDimensions();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
get width() {
|
|
25
|
+
return Math.abs(this.destSize.width * this.scale.x);
|
|
26
|
+
}
|
|
27
|
+
get height() {
|
|
28
|
+
return Math.abs(this.destSize.height * this.scale.y);
|
|
29
|
+
}
|
|
30
|
+
set width(newWidth) {
|
|
31
|
+
newWidth /= Math.abs(this.scale.x);
|
|
32
|
+
this.destSize.width = newWidth;
|
|
33
|
+
super.width = Math.ceil(this.destSize.width);
|
|
34
|
+
}
|
|
35
|
+
set height(newHeight) {
|
|
36
|
+
newHeight /= Math.abs(this.scale.y);
|
|
37
|
+
this.destSize.height = newHeight;
|
|
38
|
+
super.height = Math.ceil(this.destSize.height);
|
|
39
|
+
}
|
|
40
|
+
_updateSpriteDimensions() {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f;
|
|
42
|
+
const { width: nativeWidth, height: nativeHeight } = this.image;
|
|
43
|
+
// This code uses || to avoid 0's
|
|
44
|
+
// If the source is not specified, use the native dimension
|
|
45
|
+
this.sourceView.width = ((_a = this.sourceView) === null || _a === void 0 ? void 0 : _a.width) || nativeWidth;
|
|
46
|
+
this.sourceView.height = ((_b = this.sourceView) === null || _b === void 0 ? void 0 : _b.height) || nativeHeight;
|
|
47
|
+
// If the destination is not specified, use the source if specified, then native
|
|
48
|
+
this.destSize.width = ((_c = this.destSize) === null || _c === void 0 ? void 0 : _c.width) || ((_d = this.sourceView) === null || _d === void 0 ? void 0 : _d.width) || nativeWidth;
|
|
49
|
+
this.destSize.height = ((_e = this.destSize) === null || _e === void 0 ? void 0 : _e.height) || ((_f = this.sourceView) === null || _f === void 0 ? void 0 : _f.height) || nativeHeight;
|
|
50
|
+
this.width = Math.ceil(this.destSize.width) * this.scale.x;
|
|
51
|
+
this.height = Math.ceil(this.destSize.height) * this.scale.y;
|
|
52
|
+
}
|
|
53
|
+
_preDraw(ex, x, y) {
|
|
54
|
+
if (this.image.isLoaded() && this._dirty) {
|
|
55
|
+
this._dirty = false;
|
|
56
|
+
this._updateSpriteDimensions();
|
|
57
|
+
}
|
|
58
|
+
super._preDraw(ex, x, y);
|
|
59
|
+
}
|
|
60
|
+
_drawImage(ex, x, y) {
|
|
61
|
+
if (this.image.isLoaded()) {
|
|
62
|
+
ex.drawImage(this.image.image, this.sourceView.x, this.sourceView.y, this.sourceView.width, this.sourceView.height, x, y, this.destSize.width, this.destSize.height);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (!this._logNotLoadedWarning) {
|
|
66
|
+
this._logger.warn(`ImageSource ${this.image.path}` +
|
|
67
|
+
` is not yet loaded and won't be drawn. Please call .load() or include in a Loader.\n\n` +
|
|
68
|
+
`Read https://excaliburjs.com/docs/imagesource for more information.`);
|
|
69
|
+
}
|
|
70
|
+
this._logNotLoadedWarning = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
clone() {
|
|
74
|
+
return new Sprite({
|
|
75
|
+
image: this.image,
|
|
76
|
+
sourceView: { ...this.sourceView },
|
|
77
|
+
destSize: { ...this.destSize },
|
|
78
|
+
...this.cloneGraphicOptions()
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=Sprite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sprite.js","sourceRoot":"","sources":["../../../src/engine/Graphics/Sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAoBrC,MAAM,OAAO,MAAO,SAAQ,OAAO;IAO1B,MAAM,CAAC,IAAI,CAAC,KAAkB;QACnC,OAAO,IAAI,MAAM,CAAC;YAChB,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;IAED,YAAY,OAAuC;;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAbT,YAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAI/B,WAAM,GAAG,IAAI,CAAC;QA+Dd,yBAAoB,GAAG,KAAK,CAAC;QArDnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,EAAE,C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