Fixed graphics bug + updated docs

Fixed issue with getBounds being incorrect for graphics
Updated docs
Linted code
This commit is contained in:
Mat Groves 2014-01-01 23:54:45 +00:00
parent 53506da65e
commit 7713731ab3
145 changed files with 15583 additions and 24078 deletions

View file

@ -19,7 +19,7 @@
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 1.3.0</em>
<em>API Docs for: 1.4.0</em>
</div>
</div>
<div id="bd" class="yui3-g">
@ -45,6 +45,8 @@
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
<li><a href="../classes/AtlasLoader.html">AtlasLoader</a></li>
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
@ -61,7 +63,7 @@
<li><a href="../classes/ColorMatrixFilter.html">ColorMatrixFilter</a></li>
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
<li><a href="../classes/ColorStepFilter.html">ColorStepFilter</a></li>
<li><a href="../classes/DisplacementFilter.html">DisplacementFilter</a></li>
@ -75,7 +77,7 @@
<li><a href="../classes/Graphics.html">Graphics</a></li>
<li><a href="../classes/GreyFilter.html">GreyFilter</a></li>
<li><a href="../classes/GrayFilter.html">GrayFilter</a></li>
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
@ -87,6 +89,8 @@
<li><a href="../classes/PixelateFilter.html">PixelateFilter</a></li>
<li><a href="../classes/PIXI.PixiShader.html">PIXI.PixiShader</a></li>
<li><a href="../classes/Point.html">Point</a></li>
<li><a href="../classes/Polygon.html">Polygon</a></li>
@ -109,10 +113,10 @@
<li><a href="../classes/Spine.html">Spine</a></li>
<li><a href="../classes/Sprite.html">Sprite</a></li>
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
<li><a href="../classes/Sprite™.html">Sprite™</a></li>
<li><a href="../classes/Stage.html">Stage</a></li>
<li><a href="../classes/Text.html">Text</a></li>
@ -121,8 +125,6 @@
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
</ul>
@ -190,13 +192,13 @@
var lastTime = 0;
var vendors = [&#x27;ms&#x27;, &#x27;moz&#x27;, &#x27;webkit&#x27;, &#x27;o&#x27;];
for(var x = 0; x &lt; vendors.length &amp;&amp; !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+&#x27;RequestAnimationFrame&#x27;];
window.cancelAnimationFrame = window[vendors[x]+&#x27;CancelAnimationFrame&#x27;]
|| window[vendors[x]+&#x27;CancelRequestAnimationFrame&#x27;];
window.requestAnimationFrame = window[vendors[x] + &#x27;RequestAnimationFrame&#x27;];
window.cancelAnimationFrame = window[vendors[x] + &#x27;CancelAnimationFrame&#x27;] ||
window[vendors[x] + &#x27;CancelRequestAnimationFrame&#x27;];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
@ -204,50 +206,57 @@ if (!window.requestAnimationFrame)
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame)
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
window.requestAnimFrame = window.requestAnimationFrame;
/**
* Converts a hex color number to an [R, G, B] array
*
* @method HEXtoRGB
* @method hex2rgb
* @param hex {Number}
*/
function HEXtoRGB(hex) {
return [(hex &gt;&gt; 16 &amp; 0xFF) / 255, ( hex &gt;&gt; 8 &amp; 0xFF) / 255, (hex &amp; 0xFF)/ 255];
}
PIXI.hex2rgb = function(hex) {
return [(hex &gt;&gt; 16 &amp; 0xFF) / 255, ( hex &gt;&gt; 8 &amp; 0xFF) / 255, (hex &amp; 0xFF)/ 255];
};
PIXI.rgb2hex = function(rgb) {
return ((rgb[0]*255 &lt;&lt; 16) + (rgb[1]*255 &lt;&lt; 8) + rgb[2]*255);
};
/**
* A polyfill for Function.prototype.bind
*
* @method bind
*/
if (typeof Function.prototype.bind != &#x27;function&#x27;) {
Function.prototype.bind = (function () {
var slice = Array.prototype.slice;
return function (thisArg) {
var target = this, boundArgs = slice.call(arguments, 1);
if (typeof Function.prototype.bind !== &#x27;function&#x27;) {
Function.prototype.bind = (function () {
var slice = Array.prototype.slice;
return function (thisArg) {
var target = this, boundArgs = slice.call(arguments, 1);
if (typeof target != &#x27;function&#x27;) throw new TypeError();
if (typeof target !== &#x27;function&#x27;) throw new TypeError();
function bound() {
var args = boundArgs.concat(slice.call(arguments));
target.apply(this instanceof bound ? this : thisArg, args);
}
function bound() {
var args = boundArgs.concat(slice.call(arguments));
target.apply(this instanceof bound ? this : thisArg, args);
}
bound.prototype = (function F(proto) {
proto &amp;&amp; (F.prototype = proto);
if (!(this instanceof F)) return new F;
})(target.prototype);
bound.prototype = (function F(proto) {
if (proto) F.prototype = proto;
if (!(this instanceof F)) return new F();
})(target.prototype);
return bound;
};
})();
return bound;
};
})();
}
/**
@ -256,60 +265,86 @@ if (typeof Function.prototype.bind != &#x27;function&#x27;) {
* @class AjaxRequest
* @constructor
*/
var AjaxRequest = PIXI.AjaxRequest = function()
PIXI.AjaxRequest = function AjaxRequest()
{
var activexmodes = [&quot;Msxml2.XMLHTTP.6.0&quot;, &quot;Msxml2.XMLHTTP.3.0&quot;, &quot;Microsoft.XMLHTTP&quot;] //activeX versions to check for in IE
if (window.ActiveXObject)
{ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
for (var i=0; i&lt;activexmodes.length; i++)
{
try{
return new ActiveXObject(activexmodes[i])
}
catch(e){
//suppress error
}
}
}
else if (window.XMLHttpRequest) // if Mozilla, Safari etc
{
return new XMLHttpRequest()
}
else
{
return false;
}
}
var activexmodes = [&#x27;Msxml2.XMLHTTP.6.0&#x27;, &#x27;Msxml2.XMLHTTP.3.0&#x27;, &#x27;Microsoft.XMLHTTP&#x27;]; //activeX versions to check for in IE
if (window.ActiveXObject)
{ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
for (var i=0; i&lt;activexmodes.length; i++)
{
try{
return new window.ActiveXObject(activexmodes[i]);
}
catch(e) {
//suppress error
}
}
}
else if (window.XMLHttpRequest) // if Mozilla, Safari etc
{
return new window.XMLHttpRequest();
}
else
{
return false;
}
};
/*
* DEBUGGING ONLY
*/
PIXI.runList = function(item)
PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
{
console.log(&quot;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&quot;)
console.log(&quot;_&quot;)
var safe = 0;
var tmp = item.first;
console.log(tmp);
// console.log(r, b, c, d)
return (Math.floor((r)*63) &lt;&lt; 18) | (Math.floor((g)*63) &lt;&lt; 12) | (Math.floor((b)*63) &lt;&lt; 6);// | (Math.floor((a)*63))
// i = i | (Math.floor((a)*63));
// return i;
// var r = (i / 262144.0 ) / 64;
// var g = (i / 4096.0)%64 / 64;
// var b = (i / 64.0)%64 / 64;
// var a = (i)%64 / 64;
// console.log(r, g, b, a);
// return i;
while(tmp._iNext)
{
safe++;
tmp = tmp._iNext;
console.log(tmp);
// console.log(tmp);
if(safe &gt; 100)
{
console.log(&quot;BREAK&quot;)
break
}
}
}
};
*/
/*
PIXI.packColorRGB = function(r, g, b)//r, g, b, a)
{
return (Math.floor((r)*255) &lt;&lt; 16) | (Math.floor((g)*255) &lt;&lt; 8) | (Math.floor((b)*255));
};
PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
{
return (Math.floor((r)*255) &lt;&lt; 16) | (Math.floor((g)*255) &lt;&lt; 8) | (Math.floor((b)*255));
};
*/
PIXI.canUseNewCanvasBlendModes = function()
{
var canvas = document.createElement(&#x27;canvas&#x27;);
canvas.width = 1;
canvas.height = 1;
var context = canvas.getContext(&#x27;2d&#x27;);
context.fillStyle = &#x27;#000&#x27;;
context.fillRect(0,0,1,1);
context.globalCompositeOperation = &#x27;multiply&#x27;;
context.fillStyle = &#x27;#fff&#x27;;
context.fillRect(0,0,1,1);
return context.getImageData(0,0,1,1).data[0] === 0;
};
// this function is taken from Starling Framework as its pretty neat ;)
PIXI.getNextPowerOfTwo = function(number)
{
if (number &gt; 0 &amp;&amp; (number &amp; (number - 1)) === 0) // see: http://goo.gl/D9kPj
return number;
else
{
var result = 1;
while (result &lt; number) result &lt;&lt;= 1;
return result;
}
};