phaser/docs/Phaser.Math.html
2015-08-24 15:43:45 +01:00

10878 lines
No EOL
166 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Phaser Class: Math</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/default.css">
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
<div style="position: absolute; width: 143px; height: 31px; right: 10px; top: 10px; z-index: 1050"><a href="http://phaser.io"><img src="img/phaser.png" border="0" /></a></div>
<div class="navbar-inner">
<a class="brand" href="index.html">Phaser API</a>
<ul class="nav">
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-0">
<a href="Phaser.html">Phaser</a>
</li>
<li class="class-depth-0">
<a href="PIXI.html">PIXI</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1">
<a href="Phaser.Animation.html">Animation</a>
</li>
<li class="class-depth-1">
<a href="Phaser.AnimationManager.html">AnimationManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.AnimationParser.html">AnimationParser</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ArraySet.html">ArraySet</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ArrayUtils.html">ArrayUtils</a>
</li>
<li class="class-depth-1">
<a href="Phaser.AudioSprite.html">AudioSprite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.BitmapData.html">BitmapData</a>
</li>
<li class="class-depth-1">
<a href="Phaser.BitmapText.html">BitmapText</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Button.html">Button</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Cache.html">Cache</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Camera.html">Camera</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Canvas.html">Canvas</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Circle.html">Circle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Color.html">Color</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Angle.html">Angle</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Animation.html">Animation</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.AutoCull.html">AutoCull</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Bounds.html">Bounds</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.BringToTop.html">BringToTop</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Core.html">Core</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Crop.html">Crop</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Delta.html">Delta</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Destroy.html">Destroy</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.FixedToCamera.html">FixedToCamera</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Health.html">Health</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.InCamera.html">InCamera</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.InputEnabled.html">InputEnabled</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.InWorld.html">InWorld</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.LifeSpan.html">LifeSpan</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.LoadTexture.html">LoadTexture</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Overlap.html">Overlap</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.PhysicsBody.html">PhysicsBody</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Reset.html">Reset</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.ScaleMinMax.html">ScaleMinMax</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Component.Smoothed.html">Smoothed</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Create.html">Create</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Creature.html">Creature</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Device.html">Device</a>
</li>
<li class="class-depth-1">
<a href="Phaser.DeviceButton.html">DeviceButton</a>
</li>
<li class="class-depth-1">
<a href="Phaser.DOM.html">DOM</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Easing.html">Easing</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Back.html">Back</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Bounce.html">Bounce</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Circular.html">Circular</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Cubic.html">Cubic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Elastic.html">Elastic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Exponential.html">Exponential</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Linear.html">Linear</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Quartic.html">Quartic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Quintic.html">Quintic</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Ellipse.html">Ellipse</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Events.html">Events</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Filter.html">Filter</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FlexGrid.html">FlexGrid</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FlexLayer.html">FlexLayer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Frame.html">Frame</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FrameData.html">FrameData</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Game.html">Game</a>
</li>
<li class="class-depth-1">
<a href="Phaser.GameObjectCreator.html">GameObjectCreator</a>
</li>
<li class="class-depth-1">
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Gamepad.html">Gamepad</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Graphics.html">Graphics</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Group.html">Group</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Image.html">Image</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ImageCollection.html">ImageCollection</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Input.html">Input</a>
</li>
<li class="class-depth-1">
<a href="Phaser.InputHandler.html">InputHandler</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Key.html">Key</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Keyboard.html">Keyboard</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Line.html">Line</a>
</li>
<li class="class-depth-1">
<a href="Phaser.LinkedList.html">LinkedList</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Loader.html">Loader</a>
</li>
<li class="class-depth-1">
<a href="Phaser.LoaderParser.html">LoaderParser</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Math.html">Math</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Matrix.html">Matrix</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Mouse.html">Mouse</a>
</li>
<li class="class-depth-1">
<a href="Phaser.MSPointer.html">MSPointer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Net.html">Net</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Particle.html">Particle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Particles.html">Particles</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Particles.Arcade.html">Arcade</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Physics.html">Physics</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Physics.Arcade.html">Arcade</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Arcade.TilemapCollision.html">TilemapCollision</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Physics.Ninja.html">Ninja</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.AABB.html">AABB</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Body.html">Body</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Circle.html">Circle</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Tile.html">Tile</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Physics.P2.html">P2</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Body.html">Body</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.BodyDebug.html">BodyDebug</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.DistanceConstraint.html">DistanceConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.FixtureList.html">FixtureList</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.GearConstraint.html">GearConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.InversePointProxy.html">InversePointProxy</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.LockConstraint.html">LockConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Material.html">Material</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PointProxy.html">PointProxy</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PrismaticConstraint.html">PrismaticConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RevoluteConstraint.html">RevoluteConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RotationalSpring.html">RotationalSpring</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Spring.html">Spring</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Plugin.html">Plugin</a>
</li>
<li class="class-depth-1">
<a href="Phaser.PluginManager.html">PluginManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Point.html">Point</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Pointer.html">Pointer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Polygon.html">Polygon</a>
</li>
<li class="class-depth-1">
<a href="Phaser.QuadTree.html">QuadTree</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Rectangle.html">Rectangle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RenderTexture.html">RenderTexture</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RetroFont.html">RetroFont</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Rope.html">Rope</a>
</li>
<li class="class-depth-1">
<a href="Phaser.RoundedRectangle.html">RoundedRectangle</a>
</li>
<li class="class-depth-1">
<a href="Phaser.ScaleManager.html">ScaleManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Signal.html">Signal</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SignalBinding.html">SignalBinding</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SinglePad.html">SinglePad</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Sound.html">Sound</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SoundManager.html">SoundManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Sprite.html">Sprite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SpriteBatch.html">SpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Stage.html">Stage</a>
</li>
<li class="class-depth-1">
<a href="Phaser.State.html">State</a>
</li>
<li class="class-depth-1">
<a href="Phaser.StateManager.html">StateManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Text.html">Text</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tile.html">Tile</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tilemap.html">Tilemap</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TilemapParser.html">TilemapParser</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tileset.html">Tileset</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TileSprite.html">TileSprite</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Time.html">Time</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Timer.html">Timer</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TimerEvent.html">TimerEvent</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Touch.html">Touch</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Tween.html">Tween</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TweenData.html">TweenData</a>
</li>
<li class="class-depth-1">
<a href="Phaser.TweenManager.html">TweenManager</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Utils.html">Utils</a>
</li>
<li class="class-depth-2">
<a href="Phaser.Utils.Debug.html">Debug</a>
</li>
<li class="class-depth-1">
<a href="Phaser.Video.html">Video</a>
</li>
<li class="class-depth-1">
<a href="Phaser.World.html">World</a>
</li>
<li class="class-depth-1">
<a href="PIXI.AbstractFilter.html">AbstractFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BaseTexture.html">BaseTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasBuffer.html">CanvasBuffer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasGraphics.html">CanvasGraphics</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasMaskManager.html">CanvasMaskManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasPool.html">CanvasPool</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasRenderer.html">CanvasRenderer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasTinter.html">CanvasTinter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ComplexPrimitiveShader.html">ComplexPrimitiveShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplayObject.html">DisplayObject</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplayObjectContainer.html">DisplayObjectContainer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Event.html">Event</a>
</li>
<li class="class-depth-1">
<a href="PIXI.EventTarget.html">EventTarget</a>
</li>
<li class="class-depth-1">
<a href="PIXI.FilterTexture.html">FilterTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Graphics.html">Graphics</a>
</li>
<li class="class-depth-1">
<a href="PIXI.GraphicsData.html">GraphicsData</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PIXI.html">PIXI</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixiFastShader.html">PixiFastShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixiShader.html">PixiShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PolyK.html">PolyK</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PrimitiveShader.html">PrimitiveShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.RenderTexture.html">RenderTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Rope.html">Rope</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Sprite.html">Sprite</a>
</li>
<li class="class-depth-1">
<a href="PIXI.SpriteBatch.html">SpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Stage.html">Stage</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Strip.html">Strip</a>
</li>
<li class="class-depth-1">
<a href="PIXI.StripShader.html">StripShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Texture.html">Texture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.TilingSprite.html">TilingSprite</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLBlendModeManager.html">WebGLBlendModeManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLFastSpriteBatch.html">WebGLFastSpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLFilterManager.html">WebGLFilterManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLRenderer.html">WebGLRenderer</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-0">
<a href="global.html#AUTO">AUTO</a>
</li>
<li class="class-depth-0">
<a href="global.html#BITMAPDATA">BITMAPDATA</a>
</li>
<li class="class-depth-0">
<a href="global.html#BITMAPTEXT">BITMAPTEXT</a>
</li>
<li class="class-depth-0">
<a href="global.html#blendModes">blendModes</a>
</li>
<li class="class-depth-0">
<a href="global.html#BUTTON">BUTTON</a>
</li>
<li class="class-depth-0">
<a href="global.html#CANVAS">CANVAS</a>
</li>
<li class="class-depth-0">
<a href="global.html#CANVAS_FILTER">CANVAS_FILTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#CIRCLE">CIRCLE</a>
</li>
<li class="class-depth-0">
<a href="global.html#CREATURE">CREATURE</a>
</li>
<li class="class-depth-0">
<a href="global.html#DOWN">DOWN</a>
</li>
<li class="class-depth-0">
<a href="global.html#ELLIPSE">ELLIPSE</a>
</li>
<li class="class-depth-0">
<a href="global.html#EMITTER">EMITTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#GAMES">GAMES</a>
</li>
<li class="class-depth-0">
<a href="global.html#GRAPHICS">GRAPHICS</a>
</li>
<li class="class-depth-0">
<a href="global.html#GROUP">GROUP</a>
</li>
<li class="class-depth-0">
<a href="global.html#HEADLESS">HEADLESS</a>
</li>
<li class="class-depth-0">
<a href="global.html#IMAGE">IMAGE</a>
</li>
<li class="class-depth-0">
<a href="global.html#LEFT">LEFT</a>
</li>
<li class="class-depth-0">
<a href="global.html#LINE">LINE</a>
</li>
<li class="class-depth-0">
<a href="global.html#MATRIX">MATRIX</a>
</li>
<li class="class-depth-0">
<a href="global.html#NONE">NONE</a>
</li>
<li class="class-depth-0">
<a href="global.html#POINT">POINT</a>
</li>
<li class="class-depth-0">
<a href="global.html#POINTER">POINTER</a>
</li>
<li class="class-depth-0">
<a href="global.html#POLYGON">POLYGON</a>
</li>
<li class="class-depth-0">
<a href="global.html#RECTANGLE">RECTANGLE</a>
</li>
<li class="class-depth-0">
<a href="global.html#RENDERTEXTURE">RENDERTEXTURE</a>
</li>
<li class="class-depth-0">
<a href="global.html#RETROFONT">RETROFONT</a>
</li>
<li class="class-depth-0">
<a href="global.html#RIGHT">RIGHT</a>
</li>
<li class="class-depth-0">
<a href="global.html#ROPE">ROPE</a>
</li>
<li class="class-depth-0">
<a href="global.html#ROUNDEDRECTANGLE">ROUNDEDRECTANGLE</a>
</li>
<li class="class-depth-0">
<a href="global.html#scaleModes">scaleModes</a>
</li>
<li class="class-depth-0">
<a href="global.html#SPRITE">SPRITE</a>
</li>
<li class="class-depth-0">
<a href="global.html#SPRITEBATCH">SPRITEBATCH</a>
</li>
<li class="class-depth-0">
<a href="global.html#TEXT">TEXT</a>
</li>
<li class="class-depth-0">
<a href="global.html#TILEMAP">TILEMAP</a>
</li>
<li class="class-depth-0">
<a href="global.html#TILEMAPLAYER">TILEMAPLAYER</a>
</li>
<li class="class-depth-0">
<a href="global.html#TILESPRITE">TILESPRITE</a>
</li>
<li class="class-depth-0">
<a href="global.html#UP">UP</a>
</li>
<li class="class-depth-0">
<a href="global.html#VERSION">VERSION</a>
</li>
<li class="class-depth-0">
<a href="global.html#VIDEO">VIDEO</a>
</li>
<li class="class-depth-0">
<a href="global.html#WEBGL">WEBGL</a>
</li>
<li class="class-depth-0">
<a href="global.html#WEBGL_FILTER">WEBGL_FILTER</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Core<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Game.html">Game</a></li>
<li class="class-depth-1"><a href="Phaser.Group.html">Group</a></li>
<li class="class-depth-1"><a href="Phaser.World.html">World</a></li>
<li class="class-depth-1"><a href="Phaser.Loader.html">Loader</a></li>
<li class="class-depth-1"><a href="Phaser.Cache.html">Cache</a></li>
<li class="class-depth-1"><a href="Phaser.Time.html">Time</a></li>
<li class="class-depth-1"><a href="Phaser.Camera.html">Camera</a></li>
<li class="class-depth-1"><a href="Phaser.StateManager.html">State Manager</a></li>
<li class="class-depth-1"><a href="Phaser.TweenManager.html">Tween Manager</a></li>
<li class="class-depth-1"><a href="Phaser.SoundManager.html">Sound Manager</a></li>
<li class="class-depth-1"><a href="Phaser.Input.html">Input Manager</a></li>
<li class="class-depth-1"><a href="Phaser.ScaleManager.html">Scale Manager</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Game Objects<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.GameObjectFactory.html">Factory (game.add)</a></li>
<li class="class-depth-1"><a href="Phaser.GameObjectCreator.html">Creator (game.make)</a></li>
<li class="class-depth-1"><a href="Phaser.Sprite.html">Sprite</a></li>
<li class="class-depth-1"><a href="Phaser.Image.html">Image</a></li>
<li class="class-depth-1"><a href="Phaser.Sound.html">Sound</a></li>
<li class="class-depth-1"><a href="Phaser.Video.html">Video</a></li>
<li class="class-depth-1"><a href="Phaser.Particles.Arcade.Emitter.html">Particle Emitter</a></li>
<li class="class-depth-1"><a href="Phaser.Particle.html">Particle</a></li>
<li class="class-depth-1"><a href="Phaser.Text.html">Text</a></li>
<li class="class-depth-1"><a href="Phaser.Tween.html">Tween</a></li>
<li class="class-depth-1"><a href="Phaser.BitmapText.html">BitmapText</a></li>
<li class="class-depth-1"><a href="Phaser.Tilemap.html">Tilemap</a></li>
<li class="class-depth-1"><a href="Phaser.BitmapData.html">BitmapData</a></li>
<li class="class-depth-1"><a href="Phaser.RetroFont.html">RetroFont</a></li>
<li class="class-depth-1"><a href="Phaser.Button.html">Button</a></li>
<li class="class-depth-1"><a href="Phaser.Animation.html">Animation</a></li>
<li class="class-depth-1"><a href="Phaser.Graphics.html">Graphics</a></li>
<li class="class-depth-1"><a href="Phaser.RenderTexture.html">RenderTexture</a></li>
<li class="class-depth-1"><a href="Phaser.TileSprite.html">TileSprite</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Geometry<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Circle.html">Circle</a></li>
<li class="class-depth-1"><a href="Phaser.Ellipse.html">Ellipse</a></li>
<li class="class-depth-1"><a href="Phaser.Line.html">Line</a></li>
<li class="class-depth-1"><a href="Phaser.Matrix.html">Matrix</a></li>
<li class="class-depth-1"><a href="Phaser.Point.html">Point</a></li>
<li class="class-depth-1"><a href="Phaser.Polygon.html">Polygon</a></li>
<li class="class-depth-1"><a href="Phaser.Rectangle.html">Rectangle</a></li>
<li class="class-depth-1"><a href="Phaser.RoundedRectangle.html">Rounded Rectangle</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Physics<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Physics.Arcade.html">Arcade Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.Arcade.Body.html">Body</a></li>
<li class="class-depth-1"><a href="Phaser.Physics.P2.html">P2 Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.Body.html">Body</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.Spring.html">Spring</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a></li>
<li class="class-depth-1"><a href="Phaser.Physics.Ninja.html">Ninja Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.Body.html">Body</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Input<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.InputHandler.html">Input Handler</a></li>
<li class="class-depth-1"><a href="Phaser.Pointer.html">Pointer</a></li>
<li class="class-depth-1"><a href="Phaser.DeviceButton.html">Device Button</a></li>
<li class="class-depth-1"><a href="Phaser.Mouse.html">Mouse</a></li>
<li class="class-depth-1"><a href="Phaser.Keyboard.html">Keyboard</a></li>
<li class="class-depth-1"><a href="Phaser.Key.html">Key</a></li>
<li class="class-depth-1"><a href="Phaser.Gamepad.html">Gamepad</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Community<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="http://phaser.io">Phaser Web Site</a></li>
<li class="class-depth-1"><a href="https://github.com/photonstorm/phaser">Phaser Github</a></li>
<li class="class-depth-1"><a href="http://phaser.io/examples">Phaser Examples</a></li>
<li class="class-depth-1"><a href="https://github.com/photonstorm/phaser-plugins">Phaser Plugins</a></li>
<li class="class-depth-1"><a href="http://www.html5gamedevs.com/forum/14-phaser/">Forum</a></li>
<li class="class-depth-1"><a href="http://stackoverflow.com/questions/tagged/phaser-framework">Stack Overflow</a></li>
<li class="class-depth-1"><a href="http://phaser.io/learn">Tutorials</a></li>
<li class="class-depth-1"><a href="https://confirmsubscription.com/h/r/369DE48E3E86AF1E">Newsletter</a></li>
<li class="class-depth-1"><a href="http://phaser.io/community/twitter">Twitter</a></li>
<li class="class-depth-1"><a href="http://phaser.io/community/irc">IRC</a></li>
<li class="class-depth-1"><a href="https://www.codeandweb.com/texturepacker/phaser">Texture Packer</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span8">
<div id="main">
<!--<h1 class="page-title">Class: Math</h1>-->
<section>
<header>
<h2>
<span class="ancestors"><a href="Phaser.html">Phaser</a>.</span>
Math
</h2>
</header>
<article>
<div class="container-overview">
<dt>
<h4 class="name "
id="Math"><span class="type-signature"></span>new Math<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>A collection of useful mathematical functions.</p>
<p>These are normally accessed through <code>game.math</code>.</p>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-17">line 17</a>
</dt>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="Phaser.Utils.html">Phaser.Utils</a></li>
<li><a href="Phaser.ArrayUtils.html">Phaser.ArrayUtils</a></li>
</ul>
</dd>
</dl>
</dd>
</div>
<h3 class="subsection-title">Members</h3>
<dl>
<dt>
<h4 class="name "
id=".PI2"><span class="type-signature">&lt;static> </span>PI2<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Twice PI.</p>
</div>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>Phaser.Math#PI2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-default">Default Value:</dt>
<dd class="tag-default"><ul class="dummy"><li>~6.283</li></ul></dd>
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-24">line 24</a>
</dt>
</dl>
</dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name "
id="angleBetween"><span class="type-signature"></span>angleBetween<span class="signature">(x1, y1, x2, y2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Find the angle of a segment from (x1, y1) -&gt; (x2, y2).</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>x2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The angle, in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-282">line 282</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="angleBetweenPoints"><span class="type-signature"></span>angleBetweenPoints<span class="signature">(point1, point2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Find the angle of a segment from (point1.x, point1.y) -&gt; (point2.x, point2.y).</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>point1</code></td>
<td class="type">
<span class="param-type"><a href="Phaser.Point.html">Phaser.Point</a></span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>point2</code></td>
<td class="type">
<span class="param-type"><a href="Phaser.Point.html">Phaser.Point</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The angle, in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-311">line 311</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="angleBetweenPointsY"><span class="type-signature"></span>angleBetweenPointsY<span class="signature">(point1, point2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Find the angle of a segment from (point1.x, point1.y) -&gt; (point2.x, point2.y).</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>point1</code></td>
<td class="type">
<span class="param-type"><a href="Phaser.Point.html">Phaser.Point</a></span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>point2</code></td>
<td class="type">
<span class="param-type"><a href="Phaser.Point.html">Phaser.Point</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The angle, in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-322">line 322</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="angleBetweenY"><span class="type-signature"></span>angleBetweenY<span class="signature">(x1, y1, x2, y2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Find the angle of a segment from (x1, y1) -&gt; (x2, y2).
Note that the difference between this method and Math.angleBetween is that this assumes the y coordinate travels
down the screen.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>x2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The angle, in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-295">line 295</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="average"><span class="type-signature"></span>average<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Averages all values passed to the function and returns the result.</p>
</div>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The average of all given values.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-92">line 92</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="bernstein"><span class="type-signature">&lt;internal> </span>bernstein<span class="signature">(n, i)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>i</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="important tag-deprecated">Internal:</dt>
<dd class="tag-deprecated"><ul>
<li>This member is <em>internal (protected)</em> and may be modified or removed in the future.</li>
</ul></dd>
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-701">line 701</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="bezierInterpolation"><span class="type-signature"></span>bezierInterpolation<span class="signature">(v, k)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>A Bezier Interpolation Method, mostly used by Phaser.Tween.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>v</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>The input array of values to interpolate between.</p></td>
</tr>
<tr>
<td class="name"><code>k</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The percentage of interpolation, between 0 and 1.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The interpolated value</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-626">line 626</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="catmullRom"><span class="type-signature">&lt;internal> </span>catmullRom<span class="signature">(p0, p1, p2, p3, t)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Calculates a catmum rom value.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>p0</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>p1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>p2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>p3</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>t</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="important tag-deprecated">Internal:</dt>
<dd class="tag-deprecated"><ul>
<li>This member is <em>internal (protected)</em> and may be modified or removed in the future.</li>
</ul></dd>
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-735">line 735</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="catmullRomInterpolation"><span class="type-signature"></span>catmullRomInterpolation<span class="signature">(v, k)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>v</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>The input array of values to interpolate between.</p></td>
</tr>
<tr>
<td class="name"><code>k</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The percentage of interpolation, between 0 and 1.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The interpolated value</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-648">line 648</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="ceilTo"><span class="type-signature"></span>ceilTo<span class="signature">(value, place, base)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The value to round.</p></td>
</tr>
<tr>
<td class="name"><code>place</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The place to round to.</p></td>
</tr>
<tr>
<td class="name"><code>base</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The base to round in... default is 10 for decimal.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-264">line 264</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="chanceRoll"><span class="type-signature"></span>chanceRoll<span class="signature">(chance)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Generate a random bool result based on the chance value.</p>
<p>Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>chance</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if the roll passed, or false otherwise.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_utils_Utils.js.html">utils/Utils.js</a>, <a href="src_utils_Utils.js.html#sunlight-1-line-77">line 77</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="clamp"><span class="type-signature"></span>clamp<span class="signature">(x, a, b)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Force a value within the boundaries by clamping <code>x</code> to the range <code>[a, b]</code>.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-879">line 879</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="clampBottom"><span class="type-signature"></span>clampBottom<span class="signature">(x, a)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Clamp <code>x</code> to the range <code>[a, Infinity)</code>.
Roughly the same as <code>Math.max(x, a)</code>, except for NaN handling.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-892">line 892</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="degToRad"><span class="type-signature"></span>degToRad<span class="signature">(degrees)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Convert degrees to radians.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>degrees</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Angle in degrees.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>Angle in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-1008">line 1008</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="difference"><span class="type-signature"></span>difference<span class="signature">(a, b)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>The (absolute) difference between two values.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-755">line 755</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="distance"><span class="type-signature"></span>distance<span class="signature">(x1, y1, x2, y2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns the euclidian distance between the two given set of coordinates.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>x2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The distance between the two sets of coordinates.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-821">line 821</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="distancePow"><span class="type-signature"></span>distancePow<span class="signature">(x1, y1, x2, y2, <span class="optional">pow</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns the distance between the two given set of coordinates at the power given.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>x2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>pow</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
2
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The distance between the two sets of coordinates.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-860">line 860</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="distanceSq"><span class="type-signature"></span>distanceSq<span class="signature">(x1, y1, x2, y2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns the euclidean distance squared between the two given set of
coordinates (cuts out a square root operation before returning).</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>x2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>y2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The distance squared between the two sets of coordinates.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-840">line 840</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="factorial"><span class="type-signature"></span>factorial<span class="signature">(value)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the number you want to evaluate</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-712">line 712</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="floorTo"><span class="type-signature"></span>floorTo<span class="signature">(value, place, base)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The value to round.</p></td>
</tr>
<tr>
<td class="name"><code>place</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The place to round to.</p></td>
</tr>
<tr>
<td class="name"><code>base</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The base to round in... default is 10 for decimal.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-246">line 246</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="fuzzyCeil"><span class="type-signature"></span>fuzzyCeil<span class="signature">(val, <span class="optional">epsilon</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>epsilon</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
(small value)
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>ceiling(val-epsilon)</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-68">line 68</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="fuzzyEqual"><span class="type-signature"></span>fuzzyEqual<span class="signature">(a, b, <span class="optional">epsilon</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Two number are fuzzyEqual if their difference is less than epsilon.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>epsilon</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
(small value)
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if |a-b|&lt;epsilon</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-26">line 26</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="fuzzyFloor"><span class="type-signature"></span>fuzzyFloor<span class="signature">(val, <span class="optional">epsilon</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>val</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>epsilon</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
(small value)
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>floor(val-epsilon)</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-80">line 80</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="fuzzyGreaterThan"><span class="type-signature"></span>fuzzyGreaterThan<span class="signature">(a, b, <span class="optional">epsilon</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p><code>a</code> is fuzzyGreaterThan <code>b</code> if it is more than b - epsilon.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>epsilon</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
(small value)
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if a&gt;b+epsilon</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-54">line 54</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="fuzzyLessThan"><span class="type-signature"></span>fuzzyLessThan<span class="signature">(a, b, <span class="optional">epsilon</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p><code>a</code> is fuzzyLessThan <code>b</code> if it is less than b + epsilon.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>epsilon</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
(small value)
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if a&lt;b+epsilon</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-40">line 40</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="isEven"><span class="type-signature"></span>isEven<span class="signature">(n)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns true if the number given is even.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="description last"><p>The number to check.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if the given number is even. False if the given number is odd.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-448">line 448</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="isOdd"><span class="type-signature"></span>isOdd<span class="signature">(n)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns true if the number given is odd.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="description last"><p>The number to check.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if the given number is odd. False if the given number is even.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-436">line 436</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="linear"><span class="type-signature"></span>linear<span class="signature">(p0, p1, t)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Calculates a linear (interpolation) value over t.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>p0</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>p1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>t</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-688">line 688</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="linearInterpolation"><span class="type-signature"></span>linearInterpolation<span class="signature">(v, k)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>A Linear Interpolation Method, mostly used by Phaser.Tween.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>v</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>The input array of values to interpolate between.</p></td>
</tr>
<tr>
<td class="name"><code>k</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The percentage of interpolation, between 0 and 1.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The interpolated value</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-598">line 598</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="mapLinear"><span class="type-signature"></span>mapLinear<span class="signature">(x, a1, a2, b1, b2)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Linear mapping from range <a1, a2> to range <b1, b2></p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>the value to map</p></td>
</tr>
<tr>
<td class="name"><code>a1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>first endpoint of the range <a1, a2></p></td>
</tr>
<tr>
<td class="name"><code>a2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>final endpoint of the range <a1, a2></p></td>
</tr>
<tr>
<td class="name"><code>b1</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>first endpoint of the range <b1, b2></p></td>
</tr>
<tr>
<td class="name"><code>b2</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>final endpoint of the range <b1, b2></p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-919">line 919</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="max"><span class="type-signature"></span>max<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Variation of Math.max that can be passed either an array of numbers or the numbers as parameters.</p>
<p>Prefer the standard <code>Math.max</code> function when appropriate.</p>
</div>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The largest value from those given.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-492">line 492</a>
</dt>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="http://jsperf.com/math-s-min-max-vs-homemade">http://jsperf.com/math-s-min-max-vs-homemade</a></li>
</ul>
</dd>
</dl>
</dd>
<dt>
<h4 class="name "
id="maxAdd"><span class="type-signature"></span>maxAdd<span class="signature">(value, amount, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Adds the given amount to the value, but never lets the value go over the specified maximum.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The value to add the amount to.</p></td>
</tr>
<tr>
<td class="name"><code>amount</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The amount to add to the value.</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The maximum the value is allowed to be.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-356">line 356</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="maxProperty"><span class="type-signature"></span>maxProperty<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Variation of Math.max that can be passed a property and either an array of objects or the objects as parameters.
It will find the largest matching property value from the given objects.</p>
</div>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The largest value from those given.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-554">line 554</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="min"><span class="type-signature"></span>min<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Variation of Math.min that can be passed either an array of numbers or the numbers as parameters.</p>
<p>Prefer the standard <code>Math.min</code> function when appropriate.</p>
</div>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The lowest value from those given.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-460">line 460</a>
</dt>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="http://jsperf.com/math-s-min-max-vs-homemade">http://jsperf.com/math-s-min-max-vs-homemade</a></li>
</ul>
</dd>
</dl>
</dd>
<dt>
<h4 class="name "
id="minProperty"><span class="type-signature"></span>minProperty<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Variation of Math.min that can be passed a property and either an array of objects or the objects as parameters.
It will find the lowest matching property value from the given objects.</p>
</div>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The lowest value from those given.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-524">line 524</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="minSub"><span class="type-signature"></span>minSub<span class="signature">(value, amount, min)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Subtracts the given amount from the value, but never lets the value go below the specified minimum.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The base value.</p></td>
</tr>
<tr>
<td class="name"><code>amount</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The amount to subtract from the base value.</p></td>
</tr>
<tr>
<td class="name"><code>min</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The minimum the value is allowed to be.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The new value.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-369">line 369</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="normalizeAngle"><span class="type-signature"></span>normalizeAngle<span class="signature">(angleRad)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Normalizes an angle to the [0,2pi) range.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>angleRad</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The angle to normalize, in radians.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>Returns the angle, fit within the [0,2pi] range, in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-343">line 343</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="percent"><span class="type-signature"></span>percent<span class="signature">(a, b, <span class="optional">base</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Work out what percentage value <code>a</code> is of value <code>b</code> using the given base.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The value to work out the percentage for.</p></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The value you wish to get the percentage of.</p></td>
</tr>
<tr>
<td class="name"><code>base</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
0
</td>
<td class="description last"><p>The base value.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The percentage a is of b, between 0 and 1.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-975">line 975</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="radToDeg"><span class="type-signature"></span>radToDeg<span class="signature">(radians)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Convert degrees to radians.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>radians</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Angle in radians.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>Angle in degrees</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-1019">line 1019</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="reverseAngle"><span class="type-signature"></span>reverseAngle<span class="signature">(angleRad)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Reverses an angle.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>angleRad</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The angle to reverse, in radians.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>Returns the reverse angle, in radians.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-333">line 333</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="roundAwayFromZero"><span class="type-signature"></span>roundAwayFromZero<span class="signature">(value)</span><span class="type-signature"> &rarr; {integer}</span></h4>
</dt>
<dd>
<div class="description">
<p>Round to the next whole number <em>away</em> from zero.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Any number.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">integer</span>
-
</div>
<div class="returns-desc param-desc">
<p>The rounded value of that number.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-767">line 767</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="roundTo"><span class="type-signature"></span>roundTo<span class="signature">(value, place, base)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Round to some place comparative to a <code>base</code>, default is 10 for decimal place.
The <code>place</code> is represented by the power applied to <code>base</code> to get that place.</p>
<pre class="prettyprint source"><code>e.g. 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011
roundTo(2000/7,3) === 0
roundTo(2000/7,2) == 300
roundTo(2000/7,1) == 290
roundTo(2000/7,0) == 286
roundTo(2000/7,-1) == 285.7
roundTo(2000/7,-2) == 285.71
roundTo(2000/7,-3) == 285.714
roundTo(2000/7,-4) == 285.7143
roundTo(2000/7,-5) == 285.71429
roundTo(2000/7,3,2) == 288 -- 100100000
roundTo(2000/7,2,2) == 284 -- 100011100
roundTo(2000/7,1,2) == 286 -- 100011110
roundTo(2000/7,0,2) == 286 -- 100011110
roundTo(2000/7,-1,2) == 285.5 -- 100011101.1
roundTo(2000/7,-2,2) == 285.75 -- 100011101.11
roundTo(2000/7,-3,2) == 285.75 -- 100011101.11
roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011
roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111</code></pre><p>Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
because we are rounding 100011.1011011011011011 which rounds up.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The value to round.</p></td>
</tr>
<tr>
<td class="name"><code>place</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The place to round to.</p></td>
</tr>
<tr>
<td class="name"><code>base</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The base to round in... default is 10 for decimal.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-200">line 200</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="shear"><span class="type-signature"></span>shear<span class="signature">(n)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>n mod 1</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-111">line 111</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="sign"><span class="type-signature"></span>sign<span class="signature">(x)</span><span class="type-signature"> &rarr; {integer}</span></h4>
</dt>
<dd>
<div class="description">
<p>A value representing the sign of the value: -1 for negative, +1 for positive, 0 if value is 0.</p>
<p>This works differently from <code>Math.sign</code> for values of NaN and -0, etc.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">integer</span>
-
</div>
<div class="returns-desc param-desc">
<p>An integer in {-1, 0, 1}</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-962">line 962</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="sinCosGenerator"><span class="type-signature"></span>sinCosGenerator<span class="signature">(length, sinAmplitude, cosAmplitude, frequency)</span><span class="type-signature"> &rarr; {Object}</span></h4>
</dt>
<dd>
<div class="description">
<p>Generate a sine and cosine table simultaneously and extremely quickly.
The parameters allow you to specify the length, amplitude and frequency of the wave.
This generator is fast enough to be used in real-time.
Code based on research by Franky of scene.at</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>length</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The length of the wave</p></td>
</tr>
<tr>
<td class="name"><code>sinAmplitude</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value</p></td>
</tr>
<tr>
<td class="name"><code>cosAmplitude</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value</p></td>
</tr>
<tr>
<td class="name"><code>frequency</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The frequency of the sine and cosine table data</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">Object</span>
-
</div>
<div class="returns-desc param-desc">
<p>Returns the table data.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-781">line 781</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="smootherstep"><span class="type-signature"></span>smootherstep<span class="signature">(x, min, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>min</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-948">line 948</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="smoothstep"><span class="type-signature"></span>smoothstep<span class="signature">(x, min, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>x</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>min</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-934">line 934</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="snapTo"><span class="type-signature"></span>snapTo<span class="signature">(input, gap, <span class="optional">start</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Snap a value to nearest grid slice, using rounding.</p>
<p>Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The value to snap.</p></td>
</tr>
<tr>
<td class="name"><code>gap</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The interval gap of the grid.</p></td>
</tr>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>Optional starting offset for gap.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-120">line 120</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="snapToCeil"><span class="type-signature"></span>snapToCeil<span class="signature">(input, gap, <span class="optional">start</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Snap a value to nearest grid slice, using ceil.</p>
<p>Example: if you have an interval gap of 5 and a position of 12... you will snap to 15.
As will 14 will snap to 15... but 16 will snap to 20.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The value to snap.</p></td>
</tr>
<tr>
<td class="name"><code>gap</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The interval gap of the grid.</p></td>
</tr>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>Optional starting offset for gap.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-173">line 173</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="snapToFloor"><span class="type-signature"></span>snapToFloor<span class="signature">(input, gap, <span class="optional">start</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Snap a value to nearest grid slice, using floor.</p>
<p>Example: if you have an interval gap of 5 and a position of 12... you will snap to 10.
As will 14 snap to 10... but 16 will snap to 15.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>input</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The value to snap.</p></td>
</tr>
<tr>
<td class="name"><code>gap</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The interval gap of the grid.</p></td>
</tr>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>Optional starting offset for gap.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-146">line 146</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="within"><span class="type-signature"></span>within<span class="signature">(a, b, tolerance)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
</dt>
<dd>
<div class="description">
<p>Checks if two values are within the given tolerance of each other.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>a</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The first number to check</p></td>
</tr>
<tr>
<td class="name"><code>b</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The second number to check</p></td>
</tr>
<tr>
<td class="name"><code>tolerance</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The tolerance. Anything equal to or less than this is considered within the range.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">boolean</span>
-
</div>
<div class="returns-desc param-desc">
<p>True if a is &lt;= tolerance of b.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-905">line 905</a>
</dt>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li>Phaser.Math.fuzzyEqual</li>
</ul>
</dd>
</dl>
</dd>
<dt>
<h4 class="name "
id="wrap"><span class="type-signature"></span>wrap<span class="signature">(value, min, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Ensures that the value always stays between min and max, by wrapping the value around.</p>
<p>If <code>max</code> is not larger than <code>min</code> the result is 0.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The value to wrap.</p></td>
</tr>
<tr>
<td class="name"><code>min</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The minimum the value is allowed to be.</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The maximum the value is allowed to be, should be larger than <code>min</code>.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The wrapped value.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-382">line 382</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="wrapAngle"><span class="type-signature"></span>wrapAngle<span class="signature">(angle, <span class="optional">radians</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Keeps an angle value between -180 and +180; or -PI and PI if radians.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>angle</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The angle value to wrap</p></td>
</tr>
<tr>
<td class="name"><code>radians</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last"><p>Set to <code>true</code> if the angle is given in radians, otherwise degrees is expected.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The new angle value; will be the same as the input angle if it was within bounds.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-584">line 584</a>
</dt>
</dl>
</dd>
<dt>
<h4 class="name "
id="wrapValue"><span class="type-signature"></span>wrapValue<span class="signature">(value, amount, max)</span><span class="type-signature"> &rarr; {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.</p>
<p>Values <em>must</em> be positive integers, and are passed through Math.abs. See <a href="Phaser.Math.html#wrap">Phaser.Math#wrap</a> for an alternative.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The value to add the amount to.</p></td>
</tr>
<tr>
<td class="name"><code>amount</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The amount to add to the value.</p></td>
</tr>
<tr>
<td class="name"><code>max</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The maximum the value is allowed to be.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="returns">
<div class="returns-type">
<span class="param-type">number</span>
-
</div>
<div class="returns-desc param-desc">
<p>The wrapped value.</p>
</div>
</div>
<dl class="details">
<dt class="tag-source">Source -
<a href="src_math_Math.js.html">math/Math.js</a>, <a href="src_math_Math.js.html#sunlight-1-line-413">line 413</a>
</dt>
</dl>
</dd>
</dl>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
Phaser Copyright © 2012-2015 Photon Storm Ltd.
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
on Mon Aug 24 2015 15:36:51 GMT+0100 (GMT Daylight Time) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
<div class="span3">
<div id="toc"></div>
</div>
<br clear="both">
</div>
</div>
<script src="scripts/sunlight.js"></script>
<script src="scripts/sunlight.javascript.js"></script>
<script src="scripts/sunlight-plugin.doclinks.js"></script>
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
<script src="scripts/sunlight-plugin.menu.js"></script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/jquery.scrollTo.js"></script>
<script src="scripts/jquery.localScroll.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
<script>
$( function () {
$( "#toc" ).toc( {
anchorName : function(i, heading, prefix) {
return $(heading).attr("id") || ( prefix + i );
},
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : 60
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
} );
</script>
</body>
</html>