2013-10-03 01:38:35 +00:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "utf-8" >
2014-11-15 20:01:46 +00:00
< title > Phaser Source: D:/wamp/www/phaser/src/utils/Color.js< / title >
2013-10-03 01:38:35 +00:00
<!-- [if lt IE 9]>
< script src = "//html5shiv.googlecode.com/svn/trunk/html5.js" > < / script >
<![endif]-->
2014-11-15 20:01:46 +00:00
< link type = "text/css" rel = "stylesheet" href = "styles/default.css" >
2013-10-03 01:38:35 +00:00
< link type = "text/css" rel = "stylesheet" href = "styles/sunlight.default.css" >
< link type = "text/css" rel = "stylesheet" href = "styles/site.cerulean.css" >
< / head >
< body >
2014-11-25 00:23:44 +00:00
2013-10-03 01:38:35 +00:00
< div class = "container-fluid" >
< div class = "navbar navbar-fixed-top navbar-inverse" >
2014-11-25 00:23:44 +00:00
< 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 >
2013-10-03 01:38:35 +00:00
< div class = "navbar-inner" >
2014-11-25 00:23:44 +00:00
< a class = "brand" href = "index.html" > Phaser API< / a >
2013-10-03 01:38:35 +00:00
< ul class = "nav" >
2014-11-25 00:23:44 +00:00
2013-10-03 01:38:35 +00:00
< li class = "dropdown" >
< a href = "namespaces.list.html" class = "dropdown-toggle" data-toggle = "dropdown" > Namespaces< b
class="caret">< / b > < / a >
< ul class = "dropdown-menu " >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-0" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.html" > Phaser< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-0" >
< a href = "PIXI.html" > PIXI< / a >
< / li >
2013-10-03 01:38:35 +00:00
< / 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 " >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Animation.html" > Animation< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.AnimationManager.html" > AnimationManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.AnimationParser.html" > AnimationParser< / a >
< / li >
2014-04-29 14:39:02 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ArrayList.html" > ArrayList< / a >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ArraySet.html" > ArraySet< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.ArrayUtils.html" > ArrayUtils< / a >
< / li >
2014-10-09 15:12:53 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.AudioSprite.html" > AudioSprite< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.BitmapData.html" > BitmapData< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.BitmapText.html" > BitmapText< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Button.html" > Button< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Cache.html" > Cache< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Camera.html" > Camera< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Canvas.html" > Canvas< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Circle.html" > Circle< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Color.html" > Color< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Device.html" > Device< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.DOM.html" > DOM< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Easing.html" > Easing< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-18 03:01:51 +00:00
< a href = "Phaser.Ellipse.html" > Ellipse< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Events.html" > Events< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Filter.html" > Filter< / a >
< / li >
2014-09-09 14:36:56 +00:00
< 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 >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Frame.html" > Frame< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.FrameData.html" > FrameData< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Game.html" > Game< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-21 15:37:26 +00:00
< a href = "Phaser.GameObjectCreator.html" > GameObjectCreator< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.GameObjectFactory.html" > GameObjectFactory< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.Gamepad.html" > Gamepad< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.GamepadButton.html" > GamepadButton< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Graphics.html" > Graphics< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Group.html" > Group< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-08 07:24:22 +00:00
< a href = "Phaser.Image.html" > Image< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Input.html" > Input< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.InputHandler.html" > InputHandler< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Key.html" > Key< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Keyboard.html" > Keyboard< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.Line.html" > Line< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.LinkedList.html" > LinkedList< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Loader.html" > Loader< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.LoaderParser.html" > LoaderParser< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Math.html" > Math< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Mouse.html" > Mouse< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.MSPointer.html" > MSPointer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Net.html" > Net< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.Particle.html" > Particle< / a >
< / li >
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Particles.html" > Particles< / a >
< / li >
2014-10-09 15:12:53 +00:00
< li class = "class-depth-2" >
< a href = "Phaser.Particles.Arcade.html" > Arcade< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Particles.Arcade.Emitter.html" > Emitter< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Physics.html" > Physics< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Physics.Arcade.html" > Arcade< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Arcade.Body.html" > Body< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.html" > Ninja< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.AABB.html" > AABB< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.Body.html" > Body< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.Circle.html" > Circle< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.Ninja.Tile.html" > Tile< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.html" > P2< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.Body.html" > Body< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.BodyDebug.html" > BodyDebug< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.CollisionGroup.html" > CollisionGroup< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.ContactMaterial.html" > ContactMaterial< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.DistanceConstraint.html" > DistanceConstraint< / a >
< / li >
2014-04-11 12:09:28 +00:00
< li class = "class-depth-3" >
< a href = "Phaser.Physics.P2.FixtureList.html" > FixtureList< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.GearConstraint.html" > GearConstraint< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.InversePointProxy.html" > InversePointProxy< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.LockConstraint.html" > LockConstraint< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.Material.html" > Material< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.PointProxy.html" > PointProxy< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.PrismaticConstraint.html" > PrismaticConstraint< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.RevoluteConstraint.html" > RevoluteConstraint< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-09-09 14:36:56 +00:00
< li class = "class-depth-3" >
< a href = "Phaser.Physics.P2.RotationalSpring.html" > RotationalSpring< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-3" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.Physics.P2.Spring.html" > Spring< / a >
2014-02-21 15:37:26 +00:00
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Plugin.html" > Plugin< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.PluginManager.html" > PluginManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Point.html" > Point< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Pointer.html" > Pointer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-07 06:10:15 +00:00
< a href = "Phaser.Polygon.html" > Polygon< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.QuadTree.html" > QuadTree< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.RandomDataGenerator.html" > RandomDataGenerator< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Rectangle.html" > Rectangle< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.RenderTexture.html" > RenderTexture< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.RequestAnimationFrame.html" > RequestAnimationFrame< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.RetroFont.html" > RetroFont< / a >
< / li >
2014-09-09 14:36:56 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.Rope.html" > Rope< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-03-14 06:36:05 +00:00
< a href = "Phaser.ScaleManager.html" > ScaleManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Signal.html" > Signal< / a >
< / li >
2014-04-11 12:09:28 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.SignalBinding.html" > SignalBinding< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.SinglePad.html" > SinglePad< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Sound.html" > Sound< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.SoundManager.html" > SoundManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Sprite.html" > Sprite< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-18 03:01:51 +00:00
< a href = "Phaser.SpriteBatch.html" > SpriteBatch< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Stage.html" > Stage< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.State.html" > State< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.StateManager.html" > StateManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.Text.html" > Text< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Tile.html" > Tile< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Tilemap.html" > Tilemap< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.TilemapLayer.html" > TilemapLayer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.TilemapParser.html" > TilemapParser< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Tileset.html" > Tileset< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-25 15:54:40 +00:00
< a href = "Phaser.TileSprite.html" > TileSprite< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Time.html" > Time< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-11-28 15:57:09 +00:00
< a href = "Phaser.Timer.html" > Timer< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2014-02-05 06:29:17 +00:00
< a href = "Phaser.TimerEvent.html" > TimerEvent< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Touch.html" > Touch< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Tween.html" > Tween< / a >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" >
< a href = "Phaser.TweenData.html" > TweenData< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.TweenManager.html" > TweenManager< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Utils.html" > Utils< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-2" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.Utils.Debug.html" > Debug< / a >
< / li >
2014-04-10 22:13:43 +00:00
< li class = "class-depth-1" >
2013-10-03 01:38:35 +00:00
< a href = "Phaser.World.html" > World< / a >
< / li >
2014-11-15 20:01:46 +00:00
< li class = "class-depth-1" >
< a href = "PIXI.AbstractFilter.html" > AbstractFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AjaxRequest.html" > AjaxRequest< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AlphaMaskFilter.html" > AlphaMaskFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AsciiFilter.html" > AsciiFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AssetLoader.html" > AssetLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.AtlasLoader.html" > AtlasLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BaseTexture.html" > BaseTexture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BitmapFontLoader.html" > BitmapFontLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BitmapText.html" > BitmapText< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BlurFilter.html" > BlurFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BlurXFilter.html" > BlurXFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.BlurYFilter.html" > BlurYFilter< / 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.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.Circle.html" > Circle< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ColorMatrixFilter.html" > ColorMatrixFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ColorStepFilter.html" > ColorStepFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ComplexPrimitiveShader.html" > ComplexPrimitiveShader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ConvolutionFilter.html" > ConvolutionFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.CrossHatchFilter.html" > CrossHatchFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.DisplacementFilter.html" > DisplacementFilter< / 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.DotScreenFilter.html" > DotScreenFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Ellipse.html" > Ellipse< / 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.FilterBlock.html" > FilterBlock< / 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.GrayFilter.html" > GrayFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.ImageLoader.html" > ImageLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.InteractionData.html" > InteractionData< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.InteractionManager.html" > InteractionManager< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.InvertFilter.html" > InvertFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.JsonLoader.html" > JsonLoader< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Matrix.html" > Matrix< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.MovieClip.html" > MovieClip< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.NoiseFilter.html" > NoiseFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.NormalMapFilter.html" > NormalMapFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.PixelateFilter.html" > PixelateFilter< / 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.Point.html" > Point< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Polygon.html" > Polygon< / 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.Rectangle.html" > Rectangle< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.RenderTexture.html" > RenderTexture< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.RGBSplitFilter.html" > RGBSplitFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Rope.html" > Rope< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.RoundedRectangle.html" > RoundedRectangle< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SepiaFilter.html" > SepiaFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SmartBlurFilter.html" > SmartBlurFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.Spine.html" > Spine< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.SpineLoader.html" > SpineLoader< / a >
< / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" >
< a href = "PIXI.SpineTextureLoader.html" > SpineTextureLoader< / a >
< / li >
2014-11-15 20:01:46 +00:00
< 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.SpriteSheetLoader.html" > SpriteSheetLoader< / 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.Text.html" > Text< / 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.TiltShiftFilter.html" > TiltShiftFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TiltShiftXFilter.html" > TiltShiftXFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TiltShiftYFilter.html" > TiltShiftYFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.TwistFilter.html" > TwistFilter< / a >
< / li >
< li class = "class-depth-1" >
< a href = "PIXI.VideoTexture.html" > VideoTexture< / 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 >
2013-10-03 01:38:35 +00:00
< / ul >
< / li >
2014-11-25 00:23:44 +00:00
2014-11-15 20:01:46 +00:00
< li class = "dropdown" >
2014-11-25 00:23:44 +00:00
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Core< b class = "caret" > < / b > < / a >
< ul class = "dropdown-menu " >
2014-12-03 10:39:11 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Game.html" > Game< / a > < / li >
2014-11-25 00:23:44 +00:00
< 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.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.InputManager.html" > Input Manager< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.ScaleManager.html" > Scale Manager< / a > < / li >
< / ul >
< / li >
2014-11-15 20:01:46 +00:00
2014-11-25 00:23:44 +00:00
< li class = "dropdown" >
< a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" > Game Objects< b class = "caret" > < / b > < / a >
2014-11-15 20:01:46 +00:00
< ul class = "dropdown-menu " >
2014-11-25 00:23:44 +00:00
< 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.Emitter.html" > Emitter< / a > < / li >
2014-12-03 10:39:11 +00:00
< li class = "class-depth-1" > < a href = "Phaser.Particle.html" > Particle< / a > < / li >
2014-11-25 00:23:44 +00:00
< 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.Rectangle.html" > Rectangle< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Point.html" > Point< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Line.html" > Line< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Ellipse.html" > Ellipse< / a > < / li >
< li class = "class-depth-1" > < a href = "Phaser.Polygon.html" > Polygon< / a > < / li >
< / ul >
< / li >
2014-11-15 20:01:46 +00:00
2014-11-25 00:23:44 +00:00
< 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 >
2014-11-15 20:01:46 +00:00
< / ul >
< / li >
2014-11-25 00:23:44 +00:00
< 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.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 = "https://github.com/photonstorm/phaser" > Phaser Github< / a > < / li >
< li class = "class-depth-1" > < a href = "http://examples.phaser.io" > 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 = "https://confirmsubscription.com/h/r/369DE48E3E86AF1E" > Newsletter< / a > < / li >
< li class = "class-depth-1" > < a href = "https://twitter.com/photonstorm" > Twitter< / a > < / li >
< li class = "class-depth-1" > < a href = "http://www.html5gamedevs.com/topic/4470-official-phaserio-irc-channel-phaserio-on-freenode/" > IRC< / a > < / li >
2014-12-03 10:39:11 +00:00
< li class = "class-depth-1" > < a href = "https://leanpub.com/u/photonstorm" > Phaser Books< / a > < / li >
2014-11-25 00:23:44 +00:00
< li class = "class-depth-1" > < a href = "https://www.gittip.com/photonstorm/" > GitTip< / a > < / li >
< / ul >
< / li >
2013-10-03 01:38:35 +00:00
< / ul >
< / div >
< / div >
< div class = "row-fluid" >
< div class = "span12" >
< div id = "main" >
2014-11-15 20:01:46 +00:00
< h1 class = "page-title" > Source: D:/wamp/www/phaser/src/utils/Color.js< / h1 >
2013-10-03 01:38:35 +00:00
< section >
< article >
< pre class = "sunlight-highlight-javascript linenums" > /**
* @author Richard Davey < rich@photonstorm.com>
2014-02-05 06:29:17 +00:00
* @copyright 2014 Photon Storm Ltd.
2013-10-03 01:38:35 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
2014-04-29 14:39:02 +00:00
* The Phaser.Color class is a set of static methods that assist in color manipulation and conversion.
2013-10-03 01:38:35 +00:00
*
* @class Phaser.Color
*/
Phaser.Color = {
2014-04-29 14:39:02 +00:00
/**
* Packs the r, g, b, a components into a single integer, for use with Int32Array.
* If device is little endian then ABGR order is used. Otherwise RGBA order is used.
*
* @author Matt DesLauriers (@mattdesl)
* @method Phaser.Color.packPixel
* @static
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
* @param {number} a - The alpha color component, in the range 0 - 255.
2014-07-10 19:31:11 +00:00
* @return {number} The packed color as uint32
2014-04-29 14:39:02 +00:00
*/
packPixel: function (r, g, b, a) {
if (Phaser.Device.LITTLE_ENDIAN)
{
2014-07-10 19:31:11 +00:00
return ( (a < < 24) | (b < < 16) | (g < < 8) | r ) >>> 0;
2014-04-29 14:39:02 +00:00
}
else
{
2014-07-10 19:31:11 +00:00
return ( (r < < 24) | (g < < 16) | (b < < 8) | a ) >>> 0;
2014-04-29 14:39:02 +00:00
}
},
/**
* Unpacks the r, g, b, a components into the specified color object, or a new
2014-07-10 19:31:11 +00:00
* object, for use with Int32Array. If little endian, then ABGR order is used when
2014-04-29 14:39:02 +00:00
* unpacking, otherwise, RGBA order is used. The resulting color object has the
* `r, g, b, a` properties which are unrelated to endianness.
*
* Note that the integer is assumed to be packed in the correct endianness. On little-endian
* the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA. If you want a
* endian-independent method, use fromRGBA(rgba) and toRGBA(r, g, b, a).
2014-07-10 19:31:11 +00:00
*
2014-04-29 14:39:02 +00:00
* @author Matt DesLauriers (@mattdesl)
* @method Phaser.Color.unpackPixel
* @static
* @param {number} rgba - The integer, packed in endian order by packPixel.
* @param {object} [out] - An object into which 3 properties will be created: r, g and b. If not provided a new object will be created.
* @param {boolean} [hsl=false] - Also convert the rgb values into hsl?
* @param {boolean} [hsv=false] - Also convert the rgb values into hsv?
* @return {object} An object with the red, green and blue values set in the r, g and b properties.
*/
unpackPixel: function (rgba, out, hsl, hsv) {
if (typeof out === 'undefined' || out === null) { out = Phaser.Color.createColor(); }
if (typeof hsl === 'undefined' || hsl === null) { hsl = false; }
if (typeof hsv === 'undefined' || hsv === null) { hsv = false; }
if (Phaser.Device.LITTLE_ENDIAN)
{
out.a = ((rgba & 0xff000000) >>> 24);
out.b = ((rgba & 0x00ff0000) >>> 16);
out.g = ((rgba & 0x0000ff00) >>> 8);
out.r = ((rgba & 0x000000ff));
}
else
{
out.r = ((rgba & 0xff000000) >>> 24);
out.g = ((rgba & 0x00ff0000) >>> 16);
out.b = ((rgba & 0x0000ff00) >>> 8);
out.a = ((rgba & 0x000000ff));
}
2014-07-10 19:31:11 +00:00
2014-04-29 14:39:02 +00:00
out.color = rgba;
out.rgba = 'rgba(' + out.r + ',' + out.g + ',' + out.b + ',' + (out.a / 255) + ')';
if (hsl)
{
Phaser.Color.RGBtoHSL(out.r, out.g, out.b, out);
}
if (hsv)
{
Phaser.Color.RGBtoHSV(out.r, out.g, out.b, out);
}
return out;
},
/**
* A utility to convert an integer in 0xRRGGBBAA format to a color object.
* This does not rely on endianness.
*
* @author Matt DesLauriers (@mattdesl)
* @method Phaser.Color.fromRGBA
* @static
* @param {number} rgba - An RGBA hex
* @param {object} [out] - The object to use, optional.
* @return {object} A color object.
*/
fromRGBA: function (rgba, out) {
if (!out)
{
out = Phaser.Color.createColor();
}
out.r = ((rgba & 0xff000000) >>> 24);
out.g = ((rgba & 0x00ff0000) >>> 16);
out.b = ((rgba & 0x0000ff00) >>> 8);
out.a = ((rgba & 0x000000ff));
out.rgba = 'rgba(' + out.r + ',' + out.g + ',' + out.b + ',' + out.a + ')';
return out;
},
/**
* A utility to convert RGBA components to a 32 bit integer in RRGGBBAA format.
*
* @author Matt DesLauriers (@mattdesl)
* @method Phaser.Color.toRGBA
* @static
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
* @param {number} a - The alpha color component, in the range 0 - 255.
* @return {number} A RGBA-packed 32 bit integer
*/
toRGBA: function (r, g, b, a) {
return (r < < 24) | (g < < 16) | (b < < 8) | a;
},
/**
* Converts an RGB color value to HSL (hue, saturation and lightness).
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes RGB values are contained in the set [0, 255] and returns h, s and l in the set [0, 1].
* Based on code by Michael Jackson (https://github.com/mjijackson)
*
* @method Phaser.Color.RGBtoHSL
* @static
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
* @param {object} [out] - An object into which 3 properties will be created, h, s and l. If not provided a new object will be created.
* @return {object} An object with the hue, saturation and lightness values set in the h, s and l properties.
*/
RGBtoHSL: function (r, g, b, out) {
if (!out)
{
out = Phaser.Color.createColor(r, g, b, 1);
}
r /= 255;
g /= 255;
b /= 255;
var min = Math.min(r, g, b);
var max = Math.max(r, g, b);
// achromatic by default
out.h = 0;
out.s = 0;
out.l = (max + min) / 2;
if (max !== min)
{
var d = max - min;
out.s = out.l > 0.5 ? d / (2 - max - min) : d / (max + min);
if (max === r)
{
out.h = (g - b) / d + (g < b ? 6 : 0);
}
else if (max === g)
{
out.h = (b - r) / d + 2;
}
else if (max === b)
{
out.h = (r - g) / d + 4;
}
out.h /= 6;
}
return out;
},
/**
* Converts an HSL (hue, saturation and lightness) color value to RGB.
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes HSL values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255].
* Based on code by Michael Jackson (https://github.com/mjijackson)
*
* @method Phaser.Color.HSLtoRGB
* @static
* @param {number} h - The hue, in the range 0 - 1.
* @param {number} s - The saturation, in the range 0 - 1.
* @param {number} l - The lightness, in the range 0 - 1.
* @param {object} [out] - An object into which 3 properties will be created: r, g and b. If not provided a new object will be created.
* @return {object} An object with the red, green and blue values set in the r, g and b properties.
*/
HSLtoRGB: function (h, s, l, out) {
if (!out)
{
out = Phaser.Color.createColor(l, l, l);
}
else
{
// achromatic by default
out.r = l;
out.g = l;
out.b = l;
}
if (s !== 0)
{
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
out.r = Phaser.Color.hueToColor(p, q, h + 1 / 3);
out.g = Phaser.Color.hueToColor(p, q, h);
out.b = Phaser.Color.hueToColor(p, q, h - 1 / 3);
}
// out.r = (out.r * 255 | 0);
// out.g = (out.g * 255 | 0);
// out.b = (out.b * 255 | 0);
out.r = Math.floor((out.r * 255 | 0));
out.g = Math.floor((out.g * 255 | 0));
out.b = Math.floor((out.b * 255 | 0));
Phaser.Color.updateColor(out);
return out;
},
/**
* Converts an RGB color value to HSV (hue, saturation and value).
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1].
* Based on code by Michael Jackson (https://github.com/mjijackson)
*
* @method Phaser.Color.RGBtoHSV
* @static
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
* @param {object} [out] - An object into which 3 properties will be created, h, s and v. If not provided a new object will be created.
* @return {object} An object with the hue, saturation and value set in the h, s and v properties.
*/
RGBtoHSV: function (r, g, b, out) {
if (!out)
{
out = Phaser.Color.createColor(r, g, b, 255);
}
r /= 255;
g /= 255;
b /= 255;
var min = Math.min(r, g, b);
var max = Math.max(r, g, b);
var d = max - min;
// achromatic by default
out.h = 0;
out.s = max === 0 ? 0 : d / max;
out.v = max;
if (max !== min)
{
if (max === r)
{
out.h = (g - b) / d + (g < b ? 6 : 0);
}
else if (max === g)
{
out.h = (b - r) / d + 2;
}
else if (max === b)
{
out.h = (r - g) / d + 4;
}
out.h /= 6;
}
return out;
},
/**
* Converts an HSV (hue, saturation and value) color value to RGB.
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes HSV values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255].
* Based on code by Michael Jackson (https://github.com/mjijackson)
*
* @method Phaser.Color.HSVtoRGB
* @static
* @param {number} h - The hue, in the range 0 - 1.
* @param {number} s - The saturation, in the range 0 - 1.
* @param {number} v - The value, in the range 0 - 1.
* @param {object} [out] - An object into which 3 properties will be created: r, g and b. If not provided a new object will be created.
* @return {object} An object with the red, green and blue values set in the r, g and b properties.
*/
HSVtoRGB: function (h, s, v, out) {
if (typeof out === 'undefined') { out = Phaser.Color.createColor(0, 0, 0, 1, h, s, 0, v); }
var r, g, b;
var i = Math.floor(h * 6);
var f = h * 6 - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
switch (i % 6)
{
case 0:
r = v;
g = t;
b = p;
break;
case 1:
r = q;
g = v;
b = p;
break;
case 2:
r = p;
g = v;
b = t;
break;
case 3:
r = p;
g = q;
b = v;
break;
case 4:
r = t;
g = p;
b = v;
break;
case 5:
r = v;
g = p;
b = q;
break;
}
out.r = Math.floor(r * 255);
out.g = Math.floor(g * 255);
out.b = Math.floor(b * 255);
Phaser.Color.updateColor(out);
return out;
},
/**
* Converts a hue to an RGB color.
* Based on code by Michael Jackson (https://github.com/mjijackson)
*
* @method Phaser.Color.hueToColor
* @static
* @param {number} p
* @param {number} q
* @param {number} t
* @return {number} The color component value.
*/
hueToColor: function (p, q, t) {
if (t < 0)
{
t += 1;
}
if (t > 1)
{
t -= 1;
}
if (t < 1 / 6)
{
return p + (q - p) * 6 * t;
}
if (t < 1 / 2)
{
return q;
}
if (t < 2 / 3)
{
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
},
/**
* A utility function to create a lightweight 'color' object with the default components.
* Any components that are not specified will default to zero.
*
* This is useful when you want to use a shared color object for the getPixel and getPixelAt methods.
*
* @author Matt DesLauriers (@mattdesl)
* @method Phaser.Color.createColor
* @static
* @param {number} [r=0] - The red color component, in the range 0 - 255.
* @param {number} [g=0] - The green color component, in the range 0 - 255.
* @param {number} [b=0] - The blue color component, in the range 0 - 255.
* @param {number} [a=1] - The alpha color component, in the range 0 - 1.
* @param {number} [h=0] - The hue, in the range 0 - 1.
* @param {number} [s=0] - The saturation, in the range 0 - 1.
* @param {number} [l=0] - The lightness, in the range 0 - 1.
* @param {number} [v=0] - The value, in the range 0 - 1.
* @return {object} The resulting object with r, g, b, a properties and h, s, l and v.
*/
createColor: function (r, g, b, a, h, s, l, v) {
2014-10-09 15:12:53 +00:00
var out = { r: r || 0, g: g || 0, b: b || 0, a: a || 1, h: h || 0, s: s || 0, l: l || 0, v: v || 0, color: 0, color32: 0, rgba: '' };
2014-04-29 14:39:02 +00:00
2014-10-09 15:12:53 +00:00
out.color = Phaser.Color.getColor(out.r, out.g, out.b);
out.color32 = Phaser.Color.getColor32(out.a, out.r, out.g, out.b);
2014-04-29 14:39:02 +00:00
2014-10-09 15:12:53 +00:00
return Phaser.Color.updateColor(out);
2014-04-29 14:39:02 +00:00
},
/**
* Takes a color object and updates the rgba property.
*
* @method Phaser.Color.updateColor
* @static
* @param {object} out - The color object to update.
* @returns {number} A native color value integer (format: 0xAARRGGBB).
*/
updateColor: function (out) {
2014-10-09 15:12:53 +00:00
out.rgba = 'rgba(' + out.r.toString() + ',' + out.g.toString() + ',' + out.b.toString() + ',' + out.a.toString() + ')';
2014-04-29 14:39:02 +00:00
return out;
},
2013-10-03 01:38:35 +00:00
/**
* Given an alpha and 3 color values this will return an integer representation of it.
*
* @method Phaser.Color.getColor32
2013-11-28 15:57:09 +00:00
* @static
2014-04-29 14:39:02 +00:00
* @param {number} a - The alpha color component, in the range 0 - 255.
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
2013-10-03 01:38:35 +00:00
* @returns {number} A native color value integer (format: 0xAARRGGBB).
*/
2014-04-29 14:39:02 +00:00
getColor32: function (a, r, g, b) {
return a < < 24 | r < < 16 | g < < 8 | b;
2013-10-03 01:38:35 +00:00
},
/**
* Given 3 color values this will return an integer representation of it.
*
* @method Phaser.Color.getColor
2013-11-28 15:57:09 +00:00
* @static
2014-04-29 14:39:02 +00:00
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
2013-10-03 01:38:35 +00:00
* @returns {number} A native color value integer (format: 0xRRGGBB).
*/
2014-04-29 14:39:02 +00:00
getColor: function (r, g, b) {
return r < < 16 | g < < 8 | b;
2013-10-03 01:38:35 +00:00
},
/**
2014-04-29 14:39:02 +00:00
* Converts the given color values into a string.
* If prefix was '#' it will be in the format `#RRGGBB` otherwise `0xAARRGGBB`.
2013-10-03 01:38:35 +00:00
*
2014-04-29 14:39:02 +00:00
* @method Phaser.Color.RGBtoString
2013-11-28 15:57:09 +00:00
* @static
2014-04-29 14:39:02 +00:00
* @param {number} r - The red color component, in the range 0 - 255.
* @param {number} g - The green color component, in the range 0 - 255.
* @param {number} b - The blue color component, in the range 0 - 255.
* @param {number} [a=255] - The alpha color component, in the range 0 - 255.
* @param {string} [prefix='#'] - The prefix used in the return string. If '#' it will return `#RRGGBB`, else `0xAARRGGBB`.
* @return {string} A string containing the color values. If prefix was '#' it will be in the format `#RRGGBB` otherwise `0xAARRGGBB`.
2013-10-03 01:38:35 +00:00
*/
2014-04-29 14:39:02 +00:00
RGBtoString: function (r, g, b, a, prefix) {
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
if (typeof a === 'undefined') { a = 255; }
if (typeof prefix === 'undefined') { prefix = '#'; }
2013-11-01 18:16:52 +00:00
2014-04-29 14:39:02 +00:00
if (prefix === '#')
{
return '#' + ((1 < < 24) + (r < < 16) + (g < < 8) + b).toString(16).slice(1);
}
else
2013-11-28 15:57:09 +00:00
{
2014-04-29 14:39:02 +00:00
return '0x' + Phaser.Color.componentToHex(a) + Phaser.Color.componentToHex(r) + Phaser.Color.componentToHex(g) + Phaser.Color.componentToHex(b);
2013-11-01 18:16:52 +00:00
}
2014-04-29 14:39:02 +00:00
},
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
/**
* Converts a hex string into an integer color value.
*
* @method Phaser.Color.hexToRGB
* @static
* @param {string} hex - The hex string to convert. Can be in the short-hand format `#03f` or `#0033ff`.
* @return {number} The rgb color value in the format 0xAARRGGBB.
*/
hexToRGB: function (hex) {
var rgb = Phaser.Color.hexToColor(hex);
if (rgb)
{
return Phaser.Color.getColor32(rgb.a, rgb.r, rgb.g, rgb.b);
}
2014-03-28 01:42:49 +00:00
2013-10-03 01:38:35 +00:00
},
/**
2014-04-29 14:39:02 +00:00
* Converts a hex string into a Phaser Color object.
2013-10-03 01:38:35 +00:00
*
2014-11-15 20:01:46 +00:00
* The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed.
*
* An alpha channel is _not_ supported.
*
2014-04-29 14:39:02 +00:00
* @method Phaser.Color.hexToColor
2013-11-28 15:57:09 +00:00
* @static
2014-11-15 20:01:46 +00:00
* @param {string} hex - The color string in a hex format.
2014-10-09 15:12:53 +00:00
* @param {object} [out] - An object into which 3 properties will be created or set: r, g and b. If not provided a new object will be created.
2014-04-29 14:39:02 +00:00
* @return {object} An object with the red, green and blue values set in the r, g and b properties.
2013-10-03 01:38:35 +00:00
*/
2014-04-29 14:39:02 +00:00
hexToColor: function (hex, out) {
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
2014-11-15 20:01:46 +00:00
hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function(m, r, g, b) {
2014-04-29 14:39:02 +00:00
return r + r + g + g + b + b;
});
2014-03-28 01:42:49 +00:00
2014-11-15 20:01:46 +00:00
var result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
if (result)
{
2014-10-09 15:12:53 +00:00
var r = parseInt(result[1], 16);
var g = parseInt(result[2], 16);
var b = parseInt(result[3], 16);
if (!out)
{
out = Phaser.Color.createColor(r, g, b);
}
else
{
out.r = r;
out.g = g;
out.b = b;
}
2014-04-29 14:39:02 +00:00
}
return out;
2013-10-03 01:38:35 +00:00
},
2014-10-09 15:12:53 +00:00
/**
* Converts a CSS 'web' string into a Phaser Color object.
*
2014-11-15 20:01:46 +00:00
* The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1].
*
2014-10-09 15:12:53 +00:00
* @method Phaser.Color.webToColor
* @static
2014-11-15 20:01:46 +00:00
* @param {string} web - The color string in CSS 'web' format.
* @param {object} [out] - An object into which 4 properties will be created: r, g, b and a. If not provided a new object will be created.
* @return {object} An object with the red, green, blue and alpha values set in the r, g, b and a properties.
2014-10-09 15:12:53 +00:00
*/
webToColor: function (web, out) {
if (!out)
{
out = Phaser.Color.createColor();
}
2014-11-15 20:01:46 +00:00
var result = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(web);
2014-10-09 15:12:53 +00:00
if (result)
{
out.r = parseInt(result[1], 10);
out.g = parseInt(result[2], 10);
out.b = parseInt(result[3], 10);
2014-11-15 20:01:46 +00:00
out.a = result[4] !== undefined ? parseFloat(result[4]) : 1;
2014-10-09 15:12:53 +00:00
}
return out;
},
2014-11-15 20:01:46 +00:00
/**
* Converts a value - a "hex" string, a "CSS 'web' string", or a number - into red, green, blue, and alpha components.
*
* The value can be a string (see `hexToColor` and `webToColor` for the supported formats) or a packed integer (see `getRGB`).
*
* An alpha channel is _not_ supported when specifying a hex string.
*
* @method Phaser.Color.valueToColor
* @static
* @param {string|number} value - The color expressed as a recognized string format or a packed integer.
* @param {object} [out] - The object to use for the output. If not provided a new object will be created.
* @return {object} The (`out`) object with the red, green, blue, and alpha values set as the r/g/b/a properties.
*/
valueToColor: function (value, out) {
// The behavior is not consistent between hexToColor/webToColor on invalid input.
// This unifies both by returning a new object, but returning null may be better.
if (!out)
{
out = Phaser.Color.createColor();
}
if (typeof value === 'string')
{
if (value.indexOf('rgb') === 0)
{
return Phaser.Color.webToColor(value, out);
}
else
{
// `hexToColor` does not support alpha; match `createColor`.
out.a = 1;
return Phaser.Color.hexToColor(value, out);
}
}
else if (typeof value === 'number')
{
// `getRGB` does not take optional object to modify;
// alpha is also adjusted to match `createColor`.
var tempColor = Phaser.Color.getRGB(value);
out.r = tempColor.r;
out.g = tempColor.g;
out.b = tempColor.b;
out.a = tempColor.a / 255;
return out;
}
else
{
return out;
}
},
2014-10-09 15:12:53 +00:00
2013-10-03 01:38:35 +00:00
/**
2014-04-29 14:39:02 +00:00
* Return a string containing a hex representation of the given color component.
2013-10-03 01:38:35 +00:00
*
2014-04-29 14:39:02 +00:00
* @method Phaser.Color.componentToHex
2013-11-28 15:57:09 +00:00
* @static
2014-04-29 14:39:02 +00:00
* @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255.
* @returns {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64.
2013-10-03 01:38:35 +00:00
*/
2014-04-29 14:39:02 +00:00
componentToHex: function (color) {
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
var hex = color.toString(16);
return hex.length == 1 ? "0" + hex : hex;
2013-10-03 01:38:35 +00:00
},
/**
2014-04-29 14:39:02 +00:00
* Get HSV color wheel values in an array which will be 360 elements in size.
2013-10-03 01:38:35 +00:00
*
2014-04-29 14:39:02 +00:00
* @method Phaser.Color.HSVColorWheel
2013-11-28 15:57:09 +00:00
* @static
2014-04-29 14:39:02 +00:00
* @param {number} [s=1] - The saturation, in the range 0 - 1.
* @param {number} [v=1] - The value, in the range 0 - 1.
* @return {array} An array containing 360 elements corresponding to the HSV color wheel.
2013-10-03 01:38:35 +00:00
*/
2014-04-29 14:39:02 +00:00
HSVColorWheel: function (s, v) {
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
if (typeof s === 'undefined') { s = 1.0; }
if (typeof v === 'undefined') { v = 1.0; }
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
var colors = [];
for (var c = 0; c < = 359; c++)
{
colors.push(Phaser.Color.HSVtoRGB(c / 359, s, v));
}
return colors;
2013-10-03 01:38:35 +00:00
},
/**
2014-04-29 14:39:02 +00:00
* Get HSL color wheel values in an array which will be 360 elements in size.
2013-10-03 01:38:35 +00:00
*
2014-04-29 14:39:02 +00:00
* @method Phaser.Color.HSLColorWheel
2013-11-28 15:57:09 +00:00
* @static
2014-04-29 14:39:02 +00:00
* @param {number} [s=0.5] - The saturation, in the range 0 - 1.
* @param {number} [l=0.5] - The lightness, in the range 0 - 1.
* @return {array} An array containing 360 elements corresponding to the HSL color wheel.
2013-10-03 01:38:35 +00:00
*/
2014-04-29 14:39:02 +00:00
HSLColorWheel: function (s, l) {
2013-10-03 01:38:35 +00:00
2014-04-29 14:39:02 +00:00
if (typeof s === 'undefined') { s = 0.5; }
if (typeof l === 'undefined') { l = 0.5; }
var colors = [];
for (var c = 0; c < = 359; c++)
{
colors.push(Phaser.Color.HSLtoRGB(c / 359, s, l));
}
return colors;
2013-10-03 01:38:35 +00:00
},
/**
* Interpolates the two given colours based on the supplied step and currentStep properties.
2014-04-29 14:39:02 +00:00
*
2013-10-03 01:38:35 +00:00
* @method Phaser.Color.interpolateColor
2013-11-28 15:57:09 +00:00
* @static
* @param {number} color1 - The first color value.
* @param {number} color2 - The second color value.
* @param {number} steps - The number of steps to run the interpolation over.
* @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two.
* @param {number} alpha - The alpha of the returned color.
2013-10-03 01:38:35 +00:00
* @returns {number} The interpolated color value.
*/
interpolateColor: function (color1, color2, steps, currentStep, alpha) {
if (typeof alpha === "undefined") { alpha = 255; }
var src1 = Phaser.Color.getRGB(color1);
var src2 = Phaser.Color.getRGB(color2);
var r = (((src2.red - src1.red) * currentStep) / steps) + src1.red;
var g = (((src2.green - src1.green) * currentStep) / steps) + src1.green;
var b = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;
return Phaser.Color.getColor32(alpha, r, g, b);
},
/**
* Interpolates the two given colours based on the supplied step and currentStep properties.
2014-07-10 19:31:11 +00:00
*
2013-10-03 01:38:35 +00:00
* @method Phaser.Color.interpolateColorWithRGB
2013-11-28 15:57:09 +00:00
* @static
* @param {number} color - The first color value.
* @param {number} r - The red color value, between 0 and 0xFF (255).
* @param {number} g - The green color value, between 0 and 0xFF (255).
* @param {number} b - The blue color value, between 0 and 0xFF (255).
* @param {number} steps - The number of steps to run the interpolation over.
* @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two.
2013-10-03 01:38:35 +00:00
* @returns {number} The interpolated color value.
*/
interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) {
var src = Phaser.Color.getRGB(color);
var or = (((r - src.red) * currentStep) / steps) + src.red;
var og = (((g - src.green) * currentStep) / steps) + src.green;
var ob = (((b - src.blue) * currentStep) / steps) + src.blue;
return Phaser.Color.getColor(or, og, ob);
},
/**
* Interpolates the two given colours based on the supplied step and currentStep properties.
* @method Phaser.Color.interpolateRGB
2013-11-28 15:57:09 +00:00
* @static
* @param {number} r1 - The red color value, between 0 and 0xFF (255).
* @param {number} g1 - The green color value, between 0 and 0xFF (255).
* @param {number} b1 - The blue color value, between 0 and 0xFF (255).
* @param {number} r2 - The red color value, between 0 and 0xFF (255).
* @param {number} g2 - The green color value, between 0 and 0xFF (255).
* @param {number} b2 - The blue color value, between 0 and 0xFF (255).
* @param {number} steps - The number of steps to run the interpolation over.
* @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two.
2013-10-03 01:38:35 +00:00
* @returns {number} The interpolated color value.
*/
interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) {
var r = (((r2 - r1) * currentStep) / steps) + r1;
var g = (((g2 - g1) * currentStep) / steps) + g1;
var b = (((b2 - b1) * currentStep) / steps) + b1;
return Phaser.Color.getColor(r, g, b);
},
/**
* Returns a random color value between black and white
2013-11-28 15:57:09 +00:00
* Set the min value to start each channel from the given offset.
* Set the max value to restrict the maximum color used per channel.
2013-10-03 01:38:35 +00:00
*
* @method Phaser.Color.getRandomColor
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} min - The lowest value to use for the color.
* @param {number} max - The highest value to use for the color.
* @param {number} alpha - The alpha value of the returning color (default 255 = fully opaque).
* @returns {number} 32-bit color value with alpha.
*/
getRandomColor: function (min, max, alpha) {
if (typeof min === "undefined") { min = 0; }
if (typeof max === "undefined") { max = 255; }
if (typeof alpha === "undefined") { alpha = 255; }
2013-11-28 15:57:09 +00:00
// Sanity checks
2014-04-29 14:39:02 +00:00
if (max > 255 || min > max)
{
2013-10-03 01:38:35 +00:00
return Phaser.Color.getColor(255, 255, 255);
}
var red = min + Math.round(Math.random() * (max - min));
var green = min + Math.round(Math.random() * (max - min));
var blue = min + Math.round(Math.random() * (max - min));
return Phaser.Color.getColor32(alpha, red, green, blue);
},
/**
2014-05-20 09:12:48 +00:00
* Return the component parts of a color as an Object with the properties alpha, red, green, blue.
2013-10-03 01:38:35 +00:00
*
2013-11-28 15:57:09 +00:00
* Alpha will only be set if it exist in the given color (0xAARRGGBB)
2013-10-03 01:38:35 +00:00
*
* @method Phaser.Color.getRGB
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
2014-05-20 09:12:48 +00:00
* @returns {object} An Object with properties: alpha, red, green, blue (also r, g, b and a). Alpha will only be present if a color value > 16777215 was given.
2013-10-03 01:38:35 +00:00
*/
getRGB: function (color) {
2014-05-20 09:12:48 +00:00
if (color > 16777215)
{
// The color value has an alpha component
return {
alpha: color >>> 24,
red: color >> 16 & 0xFF,
green: color >> 8 & 0xFF,
blue: color & 0xFF,
a: color >>> 24,
r: color >> 16 & 0xFF,
g: color >> 8 & 0xFF,
b: color & 0xFF
};
}
else
{
return {
alpha: 255,
red: color >> 16 & 0xFF,
green: color >> 8 & 0xFF,
blue: color & 0xFF,
a: 255,
r: color >> 16 & 0xFF,
g: color >> 8 & 0xFF,
b: color & 0xFF
};
}
2013-10-03 01:38:35 +00:00
},
/**
* Returns a CSS friendly string value from the given color.
2014-05-20 09:12:48 +00:00
*
2013-10-03 01:38:35 +00:00
* @method Phaser.Color.getWebRGB
2013-11-28 15:57:09 +00:00
* @static
2014-07-10 19:31:11 +00:00
* @param {number|Object} color - Color in RGB (0xRRGGBB), ARGB format (0xAARRGGBB) or an Object with r, g, b, a properties.
2014-05-20 09:12:48 +00:00
* @returns {string} A string in the format: 'rgba(r,g,b,a)'
2013-10-03 01:38:35 +00:00
*/
getWebRGB: function (color) {
2014-07-10 19:31:11 +00:00
if (typeof color === 'object')
{
return 'rgba(' + color.r.toString() + ',' + color.g.toString() + ',' + color.b.toString() + ',' + (color.a / 255).toString() + ')';
}
else
{
var rgb = Phaser.Color.getRGB(color);
return 'rgba(' + rgb.r.toString() + ',' + rgb.g.toString() + ',' + rgb.b.toString() + ',' + (rgb.a / 255).toString() + ')';
}
2014-03-28 01:42:49 +00:00
2013-10-03 01:38:35 +00:00
},
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255.
*
* @method Phaser.Color.getAlpha
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
*/
getAlpha: function (color) {
return color >>> 24;
},
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1.
*
* @method Phaser.Color.getAlphaFloat
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
*/
getAlphaFloat: function (color) {
return (color >>> 24) / 255;
},
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255.
*
* @method Phaser.Color.getRed
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} color In the format 0xAARRGGBB.
* @returns {number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red).
*/
getRed: function (color) {
2014-04-11 12:09:28 +00:00
return color >> 16 & 0xFF;
2013-10-03 01:38:35 +00:00
},
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255.
*
* @method Phaser.Color.getGreen
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green).
*/
getGreen: function (color) {
2014-04-11 12:09:28 +00:00
return color >> 8 & 0xFF;
2013-10-03 01:38:35 +00:00
},
/**
* Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255.
*
* @method Phaser.Color.getBlue
2013-11-28 15:57:09 +00:00
* @static
2013-10-03 01:38:35 +00:00
* @param {number} color - In the format 0xAARRGGBB.
* @returns {number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue).
*/
getBlue: function (color) {
2014-04-11 12:09:28 +00:00
return color & 0xFF;
2013-10-03 01:38:35 +00:00
}
2014-03-28 01:42:49 +00:00
2013-10-03 01:38:35 +00:00
};
< / pre >
< / article >
< / section >
< / div >
< div class = "clearfix" > < / div >
< footer >
< span class = "copyright" >
2014-02-05 06:29:17 +00:00
Phaser Copyright © 2012-2014 Photon Storm Ltd.
2013-10-03 01:38:35 +00:00
< / span >
< br / >
< span class = "jsdoc-message" >
2014-04-11 12:09:28 +00:00
Documentation generated by < a href = "https://github.com/jsdoc3/jsdoc" > JSDoc 3.3.0-dev< / a >
2014-12-04 11:33:42 +00:00
on Thu Dec 04 2014 11:32:24 GMT-0000 (GMT) using the < a href = "https://github.com/terryweiss/docstrap" > DocStrap template< / a > .
2013-10-03 01:38:35 +00:00
< / span >
< / footer >
< / 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( {
2014-04-10 22:13:43 +00:00
anchorName : function(i, heading, prefix) {
2014-03-14 06:36:05 +00:00
return $(heading).attr("id") || ( prefix + i );
},
2013-10-03 01:38:35 +00:00
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 >