phaser/docs/WebGLGraphics.js.html
2014-12-04 11:33:42 +00:00

1899 lines
53 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Phaser Source: d:/wamp/www/phaser/src/pixi/renderers/webgl/utils/WebGLGraphics.js</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.ArrayList.html">ArrayList</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-1">
<a href="Phaser.Device.html">Device</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-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.GamepadButton.html">GamepadButton</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.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.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-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.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.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.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>
<li class="class-depth-1">
<a href="PIXI.SpineTextureLoader.html">SpineTextureLoader</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.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>
</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.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>
<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.Emitter.html">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.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>
<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.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>
<li class="class-depth-1"><a href="https://leanpub.com/u/photonstorm">Phaser Books</a></li>
<li class="class-depth-1"><a href="https://www.gittip.com/photonstorm/">GitTip</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div id="main">
<h1 class="page-title">Source: d:/wamp/www/phaser/src/pixi/renderers/webgl/utils/WebGLGraphics.js</h1>
<section>
<article>
<pre class="sunlight-highlight-javascript linenums">/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
/**
* A set of functions used by the webGL renderer to draw the primitive graphics data
*
* @class WebGLGraphics
* @private
* @static
*/
PIXI.WebGLGraphics = function()
{
};
/**
* Renders the graphics object
*
* @static
* @private
* @method renderGraphics
* @param graphics {Graphics}
* @param renderSession {Object}
*/
PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset)
{
var gl = renderSession.gl;
var projection = renderSession.projection,
offset = renderSession.offset,
shader = renderSession.shaderManager.primitiveShader,
webGLData;
if(graphics.dirty)
{
PIXI.WebGLGraphics.updateGraphics(graphics, gl);
}
var webGL = graphics._webGL[gl.id];
// This could be speeded up for sure!
for (var i = 0; i &lt; webGL.data.length; i++)
{
if(webGL.data[i].mode === 1)
{
webGLData = webGL.data[i];
renderSession.stencilManager.pushStencil(graphics, webGLData, renderSession);
// render quad..
gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 );
renderSession.stencilManager.popStencil(graphics, webGLData, renderSession);
}
else
{
webGLData = webGL.data[i];
renderSession.shaderManager.setShader( shader );//activatePrimitiveShader();
shader = renderSession.shaderManager.primitiveShader;
gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
gl.uniform3fv(shader.tintColor, PIXI.hex2rgb(graphics.tint));
gl.uniform1f(shader.alpha, graphics.worldAlpha);
gl.bindBuffer(gl.ARRAY_BUFFER, webGLData.buffer);
gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 4 * 6, 0);
gl.vertexAttribPointer(shader.colorAttribute, 4, gl.FLOAT, false,4 * 6, 2 * 4);
// set the index buffer!
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, webGLData.indexBuffer);
gl.drawElements(gl.TRIANGLE_STRIP, webGLData.indices.length, gl.UNSIGNED_SHORT, 0 );
}
}
};
/**
* Updates the graphics object
*
* @static
* @private
* @method updateGraphics
* @param graphicsData {Graphics} The graphics object to update
* @param gl {WebGLContext} the current WebGL drawing context
*/
PIXI.WebGLGraphics.updateGraphics = function(graphics, gl)
{
// get the contexts graphics object
var webGL = graphics._webGL[gl.id];
// if the graphics object does not exist in the webGL context time to create it!
if(!webGL)webGL = graphics._webGL[gl.id] = {lastIndex:0, data:[], gl:gl};
// flag the graphics as not dirty as we are about to update it...
graphics.dirty = false;
var i;
// if the user cleared the graphics object we will need to clear every object
if(graphics.clearDirty)
{
graphics.clearDirty = false;
// lop through and return all the webGLDatas to the object pool so than can be reused later on
for (i = 0; i &lt; webGL.data.length; i++)
{
var graphicsData = webGL.data[i];
graphicsData.reset();
PIXI.WebGLGraphics.graphicsDataPool.push( graphicsData );
}
// clear the array and reset the index..
webGL.data = [];
webGL.lastIndex = 0;
}
var webGLData;
// loop through the graphics datas and construct each one..
// if the object is a complex fill then the new stencil buffer technique will be used
// other wise graphics objects will be pushed into a batch..
for (i = webGL.lastIndex; i &lt; graphics.graphicsData.length; i++)
{
var data = graphics.graphicsData[i];
if(data.type === PIXI.Graphics.POLY)
{
// need to add the points the the graphics object..
data.points = data.shape.points.slice();
if(data.shape.closed)
{
// close the poly if the value is true!
if(data.points[0] !== data.points[data.points.length-2] || data.points[1] !== data.points[data.points.length-1])
{
data.points.push(data.points[0], data.points[1]);
}
}
// MAKE SURE WE HAVE THE CORRECT TYPE..
if(data.fill)
{
if(data.points.length >= 6)
{
if(data.points.length &lt; 6 * 2)
{
webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0);
var canDrawUsingSimple = PIXI.WebGLGraphics.buildPoly(data, webGLData);
// console.log(canDrawUsingSimple);
if(!canDrawUsingSimple)
{
// console.log("&lt;>>>")
webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1);
PIXI.WebGLGraphics.buildComplexPoly(data, webGLData);
}
}
else
{
webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1);
PIXI.WebGLGraphics.buildComplexPoly(data, webGLData);
}
}
}
if(data.lineWidth > 0)
{
webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0);
PIXI.WebGLGraphics.buildLine(data, webGLData);
}
}
else
{
webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0);
if(data.type === PIXI.Graphics.RECT)
{
PIXI.WebGLGraphics.buildRectangle(data, webGLData);
}
else if(data.type === PIXI.Graphics.CIRC || data.type === PIXI.Graphics.ELIP)
{
PIXI.WebGLGraphics.buildCircle(data, webGLData);
}
else if(data.type === PIXI.Graphics.RREC)
{
PIXI.WebGLGraphics.buildRoundedRectangle(data, webGLData);
}
}
webGL.lastIndex++;
}
// upload all the dirty data...
for (i = 0; i &lt; webGL.data.length; i++)
{
webGLData = webGL.data[i];
if(webGLData.dirty)webGLData.upload();
}
};
/**
* @static
* @private
* @method switchMode
* @param webGL {WebGLContext}
* @param type {Number}
*/
PIXI.WebGLGraphics.switchMode = function(webGL, type)
{
var webGLData;
if(!webGL.data.length)
{
webGLData = PIXI.WebGLGraphics.graphicsDataPool.pop() || new PIXI.WebGLGraphicsData(webGL.gl);
webGLData.mode = type;
webGL.data.push(webGLData);
}
else
{
webGLData = webGL.data[webGL.data.length-1];
if(webGLData.mode !== type || type === 1)
{
webGLData = PIXI.WebGLGraphics.graphicsDataPool.pop() || new PIXI.WebGLGraphicsData(webGL.gl);
webGLData.mode = type;
webGL.data.push(webGLData);
}
}
webGLData.dirty = true;
return webGLData;
};
/**
* Builds a rectangle to draw
*
* @static
* @private
* @method buildRectangle
* @param graphicsData {Graphics} The graphics object containing all the necessary properties
* @param webGLData {Object}
*/
PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData)
{
// --- //
// need to convert points to a nice regular data
//
var rectData = graphicsData.shape;
var x = rectData.x;
var y = rectData.y;
var width = rectData.width;
var height = rectData.height;
if(graphicsData.fill)
{
var color = PIXI.hex2rgb(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var verts = webGLData.points;
var indices = webGLData.indices;
var vertPos = verts.length/6;
// start
verts.push(x, y);
verts.push(r, g, b, alpha);
verts.push(x + width, y);
verts.push(r, g, b, alpha);
verts.push(x , y + height);
verts.push(r, g, b, alpha);
verts.push(x + width, y + height);
verts.push(r, g, b, alpha);
// insert 2 dead triangles..
indices.push(vertPos, vertPos, vertPos+1, vertPos+2, vertPos+3, vertPos+3);
}
if(graphicsData.lineWidth)
{
var tempPoints = graphicsData.points;
graphicsData.points = [x, y,
x + width, y,
x + width, y + height,
x, y + height,
x, y];
PIXI.WebGLGraphics.buildLine(graphicsData, webGLData);
graphicsData.points = tempPoints;
}
};
/**
* Builds a rounded rectangle to draw
*
* @static
* @private
* @method buildRoundedRectangle
* @param graphicsData {Graphics} The graphics object containing all the necessary properties
* @param webGLData {Object}
*/
PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
{
var rrectData = graphicsData.shape;
var x = rrectData.x;
var y = rrectData.y;
var width = rrectData.width;
var height = rrectData.height;
var radius = rrectData.radius;
var recPoints = [];
recPoints.push(x, y + radius);
recPoints = recPoints.concat(PIXI.WebGLGraphics.quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height));
recPoints = recPoints.concat(PIXI.WebGLGraphics.quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius));
recPoints = recPoints.concat(PIXI.WebGLGraphics.quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y));
recPoints = recPoints.concat(PIXI.WebGLGraphics.quadraticBezierCurve(x + radius, y, x, y, x, y + radius));
if (graphicsData.fill) {
var color = PIXI.hex2rgb(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var verts = webGLData.points;
var indices = webGLData.indices;
var vecPos = verts.length/6;
var triangles = PIXI.PolyK.Triangulate(recPoints);
var i = 0;
for (i = 0; i &lt; triangles.length; i+=3)
{
indices.push(triangles[i] + vecPos);
indices.push(triangles[i] + vecPos);
indices.push(triangles[i+1] + vecPos);
indices.push(triangles[i+2] + vecPos);
indices.push(triangles[i+2] + vecPos);
}
for (i = 0; i &lt; recPoints.length; i++)
{
verts.push(recPoints[i], recPoints[++i], r, g, b, alpha);
}
}
if (graphicsData.lineWidth) {
var tempPoints = graphicsData.points;
graphicsData.points = recPoints;
PIXI.WebGLGraphics.buildLine(graphicsData, webGLData);
graphicsData.points = tempPoints;
}
};
/**
* Calculate the points for a quadratic bezier curve. (helper function..)
* Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
*
* @static
* @private
* @method quadraticBezierCurve
* @param fromX {Number} Origin point x
* @param fromY {Number} Origin point x
* @param cpX {Number} Control point x
* @param cpY {Number} Control point y
* @param toX {Number} Destination point x
* @param toY {Number} Destination point y
* @return {Array(Number)}
*/
PIXI.WebGLGraphics.quadraticBezierCurve = function(fromX, fromY, cpX, cpY, toX, toY) {
var xa,
ya,
xb,
yb,
x,
y,
n = 20,
points = [];
function getPt(n1 , n2, perc) {
var diff = n2 - n1;
return n1 + ( diff * perc );
}
var j = 0;
for (var i = 0; i &lt;= n; i++ )
{
j = i / n;
// The Green Line
xa = getPt( fromX , cpX , j );
ya = getPt( fromY , cpY , j );
xb = getPt( cpX , toX , j );
yb = getPt( cpY , toY , j );
// The Black Dot
x = getPt( xa , xb , j );
y = getPt( ya , yb , j );
points.push(x, y);
}
return points;
};
/**
* Builds a circle to draw
*
* @static
* @private
* @method buildCircle
* @param graphicsData {Graphics} The graphics object to draw
* @param webGLData {Object}
*/
PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData)
{
// need to convert points to a nice regular data
var circleData = graphicsData.shape;
var x = circleData.x;
var y = circleData.y;
var width;
var height;
// TODO - bit hacky??
if(graphicsData.type === PIXI.Graphics.CIRC)
{
width = circleData.radius;
height = circleData.radius;
}
else
{
width = circleData.width;
height = circleData.height;
}
var totalSegs = 40;
var seg = (Math.PI * 2) / totalSegs ;
var i = 0;
if(graphicsData.fill)
{
var color = PIXI.hex2rgb(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var verts = webGLData.points;
var indices = webGLData.indices;
var vecPos = verts.length/6;
indices.push(vecPos);
for (i = 0; i &lt; totalSegs + 1 ; i++)
{
verts.push(x,y, r, g, b, alpha);
verts.push(x + Math.sin(seg * i) * width,
y + Math.cos(seg * i) * height,
r, g, b, alpha);
indices.push(vecPos++, vecPos++);
}
indices.push(vecPos-1);
}
if(graphicsData.lineWidth)
{
var tempPoints = graphicsData.points;
graphicsData.points = [];
for (i = 0; i &lt; totalSegs + 1; i++)
{
graphicsData.points.push(x + Math.sin(seg * i) * width,
y + Math.cos(seg * i) * height);
}
PIXI.WebGLGraphics.buildLine(graphicsData, webGLData);
graphicsData.points = tempPoints;
}
};
/**
* Builds a line to draw
*
* @static
* @private
* @method buildLine
* @param graphicsData {Graphics} The graphics object containing all the necessary properties
* @param webGLData {Object}
*/
PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
{
// TODO OPTIMISE!
var i = 0;
var points = graphicsData.points;
if(points.length === 0)return;
// if the line width is an odd number add 0.5 to align to a whole pixel
if(graphicsData.lineWidth%2)
{
for (i = 0; i &lt; points.length; i++) {
points[i] += 0.5;
}
}
// get first and last point.. figure out the middle!
var firstPoint = new PIXI.Point( points[0], points[1] );
var lastPoint = new PIXI.Point( points[points.length - 2], points[points.length - 1] );
// if the first point is the last point - gonna have issues :)
if(firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y)
{
// need to clone as we are going to slightly modify the shape..
points = points.slice();
points.pop();
points.pop();
lastPoint = new PIXI.Point( points[points.length - 2], points[points.length - 1] );
var midPointX = lastPoint.x + (firstPoint.x - lastPoint.x) *0.5;
var midPointY = lastPoint.y + (firstPoint.y - lastPoint.y) *0.5;
points.unshift(midPointX, midPointY);
points.push(midPointX, midPointY);
}
var verts = webGLData.points;
var indices = webGLData.indices;
var length = points.length / 2;
var indexCount = points.length;
var indexStart = verts.length/6;
// DRAW the Line
var width = graphicsData.lineWidth / 2;
// sort color
var color = PIXI.hex2rgb(graphicsData.lineColor);
var alpha = graphicsData.lineAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var px, py, p1x, p1y, p2x, p2y, p3x, p3y;
var perpx, perpy, perp2x, perp2y, perp3x, perp3y;
var a1, b1, c1, a2, b2, c2;
var denom, pdist, dist;
p1x = points[0];
p1y = points[1];
p2x = points[2];
p2y = points[3];
perpx = -(p1y - p2y);
perpy = p1x - p2x;
dist = Math.sqrt(perpx*perpx + perpy*perpy);
perpx /= dist;
perpy /= dist;
perpx *= width;
perpy *= width;
// start
verts.push(p1x - perpx , p1y - perpy,
r, g, b, alpha);
verts.push(p1x + perpx , p1y + perpy,
r, g, b, alpha);
for (i = 1; i &lt; length-1; i++)
{
p1x = points[(i-1)*2];
p1y = points[(i-1)*2 + 1];
p2x = points[(i)*2];
p2y = points[(i)*2 + 1];
p3x = points[(i+1)*2];
p3y = points[(i+1)*2 + 1];
perpx = -(p1y - p2y);
perpy = p1x - p2x;
dist = Math.sqrt(perpx*perpx + perpy*perpy);
perpx /= dist;
perpy /= dist;
perpx *= width;
perpy *= width;
perp2x = -(p2y - p3y);
perp2y = p2x - p3x;
dist = Math.sqrt(perp2x*perp2x + perp2y*perp2y);
perp2x /= dist;
perp2y /= dist;
perp2x *= width;
perp2y *= width;
a1 = (-perpy + p1y) - (-perpy + p2y);
b1 = (-perpx + p2x) - (-perpx + p1x);
c1 = (-perpx + p1x) * (-perpy + p2y) - (-perpx + p2x) * (-perpy + p1y);
a2 = (-perp2y + p3y) - (-perp2y + p2y);
b2 = (-perp2x + p2x) - (-perp2x + p3x);
c2 = (-perp2x + p3x) * (-perp2y + p2y) - (-perp2x + p2x) * (-perp2y + p3y);
denom = a1*b2 - a2*b1;
if(Math.abs(denom) &lt; 0.1 )
{
denom+=10.1;
verts.push(p2x - perpx , p2y - perpy,
r, g, b, alpha);
verts.push(p2x + perpx , p2y + perpy,
r, g, b, alpha);
continue;
}
px = (b1*c2 - b2*c1)/denom;
py = (a2*c1 - a1*c2)/denom;
pdist = (px -p2x) * (px -p2x) + (py -p2y) + (py -p2y);
if(pdist > 140 * 140)
{
perp3x = perpx - perp2x;
perp3y = perpy - perp2y;
dist = Math.sqrt(perp3x*perp3x + perp3y*perp3y);
perp3x /= dist;
perp3y /= dist;
perp3x *= width;
perp3y *= width;
verts.push(p2x - perp3x, p2y -perp3y);
verts.push(r, g, b, alpha);
verts.push(p2x + perp3x, p2y +perp3y);
verts.push(r, g, b, alpha);
verts.push(p2x - perp3x, p2y -perp3y);
verts.push(r, g, b, alpha);
indexCount++;
}
else
{
verts.push(px , py);
verts.push(r, g, b, alpha);
verts.push(p2x - (px-p2x), p2y - (py - p2y));
verts.push(r, g, b, alpha);
}
}
p1x = points[(length-2)*2];
p1y = points[(length-2)*2 + 1];
p2x = points[(length-1)*2];
p2y = points[(length-1)*2 + 1];
perpx = -(p1y - p2y);
perpy = p1x - p2x;
dist = Math.sqrt(perpx*perpx + perpy*perpy);
perpx /= dist;
perpy /= dist;
perpx *= width;
perpy *= width;
verts.push(p2x - perpx , p2y - perpy);
verts.push(r, g, b, alpha);
verts.push(p2x + perpx , p2y + perpy);
verts.push(r, g, b, alpha);
indices.push(indexStart);
for (i = 0; i &lt; indexCount; i++)
{
indices.push(indexStart++);
}
indices.push(indexStart-1);
};
/**
* Builds a complex polygon to draw
*
* @static
* @private
* @method buildComplexPoly
* @param graphicsData {Graphics} The graphics object containing all the necessary properties
* @param webGLData {Object}
*/
PIXI.WebGLGraphics.buildComplexPoly = function(graphicsData, webGLData)
{
//TODO - no need to copy this as it gets turned into a FLoat32Array anyways..
var points = graphicsData.points.slice();
if(points.length &lt; 6)return;
// get first and last point.. figure out the middle!
var indices = webGLData.indices;
webGLData.points = points;
webGLData.alpha = graphicsData.fillAlpha;
webGLData.color = PIXI.hex2rgb(graphicsData.fillColor);
/*
calclate the bounds..
*/
var minX = Infinity;
var maxX = -Infinity;
var minY = Infinity;
var maxY = -Infinity;
var x,y;
// get size..
for (var i = 0; i &lt; points.length; i+=2)
{
x = points[i];
y = points[i+1];
minX = x &lt; minX ? x : minX;
maxX = x > maxX ? x : maxX;
minY = y &lt; minY ? y : minY;
maxY = y > maxY ? y : maxY;
}
// add a quad to the end cos there is no point making another buffer!
points.push(minX, minY,
maxX, minY,
maxX, maxY,
minX, maxY);
// push a quad onto the end..
//TODO - this aint needed!
var length = points.length / 2;
for (i = 0; i &lt; length; i++)
{
indices.push( i );
}
};
/**
* Builds a polygon to draw
*
* @static
* @private
* @method buildPoly
* @param graphicsData {Graphics} The graphics object containing all the necessary properties
* @param webGLData {Object}
*/
PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData)
{
var points = graphicsData.points;
if(points.length &lt; 6)return;
// get first and last point.. figure out the middle!
var verts = webGLData.points;
var indices = webGLData.indices;
var length = points.length / 2;
// sort color
var color = PIXI.hex2rgb(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var triangles = PIXI.PolyK.Triangulate(points);
if(!triangles)return false;
var vertPos = verts.length / 6;
var i = 0;
for (i = 0; i &lt; triangles.length; i+=3)
{
indices.push(triangles[i] + vertPos);
indices.push(triangles[i] + vertPos);
indices.push(triangles[i+1] + vertPos);
indices.push(triangles[i+2] +vertPos);
indices.push(triangles[i+2] + vertPos);
}
for (i = 0; i &lt; length; i++)
{
verts.push(points[i * 2], points[i * 2 + 1],
r, g, b, alpha);
}
return true;
};
PIXI.WebGLGraphics.graphicsDataPool = [];
/**
* @class WebGLGraphicsData
* @private
* @static
*/
PIXI.WebGLGraphicsData = function(gl)
{
this.gl = gl;
//TODO does this need to be split before uploding??
this.color = [0,0,0]; // color split!
this.points = [];
this.indices = [];
this.buffer = gl.createBuffer();
this.indexBuffer = gl.createBuffer();
this.mode = 1;
this.alpha = 1;
this.dirty = true;
};
/**
* @method reset
*/
PIXI.WebGLGraphicsData.prototype.reset = function()
{
this.points = [];
this.indices = [];
};
/**
* @method upload
*/
PIXI.WebGLGraphicsData.prototype.upload = function()
{
var gl = this.gl;
// this.lastIndex = graphics.graphicsData.length;
this.glPoints = new PIXI.Float32Array(this.points);
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
gl.bufferData(gl.ARRAY_BUFFER, this.glPoints, gl.STATIC_DRAW);
this.glIndicies = new PIXI.Uint16Array(this.indices);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.glIndicies, gl.STATIC_DRAW);
this.dirty = false;
};
</pre>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
Phaser Copyright © 2012-2014 Photon Storm Ltd.
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
on Thu Dec 04 2014 11:32:24 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</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( {
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>