Docs updated

example updated
misplaced files removed
This commit is contained in:
Mat Groves 2013-06-22 11:46:57 +01:00
parent 72e38cccb0
commit e91be9b53a
100 changed files with 6387 additions and 12207 deletions

View file

@ -4,7 +4,7 @@
* Copyright (c) 2012, Mat Groves
* http://goodboydigital.com/
*
* Compiled: 2013-06-21
* Compiled: 2013-06-22
*
* Pixi.JS is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
@ -2597,6 +2597,7 @@ PIXI.autoDetectRenderer = function(width, height, view, transparent)
}
else
{
console.log("PIXI Warning: shape too complex to fill")
return [];
}
}
@ -2846,26 +2847,21 @@ PIXI.activatePrimitiveShader = function()
*/
/**
* A DisplayObjectContainer represents a collection of display objects. It is the base class of all display objects that act as a container for other objects.
* @class DisplayObjectContainer
* @extends DisplayObject
* @constructor
* A set of functions used by the webGL renderer to draw the primitive graphics data
* @class CanvasGraphics
*/
PIXI.WebGLGraphics = function()
{
}
// constructor
PIXI.WebGLGraphics.constructor = PIXI.WebGLGraphics;
PIXI.WebGLGraphics.renderGraphics = function(graphics, projection)
{
PIXI.activatePrimitiveShader();
var gl = PIXI.gl;
// a collection of "shapes" (mainly lines right now!)
if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,
buffer:gl.createBuffer(),
indexBuffer:gl.createBuffer()};
@ -2913,7 +2909,6 @@ PIXI.WebGLGraphics.updateGraphics = function(graphics)
{
var data = graphics.graphicsData[i];
if(data.type == PIXI.Graphics.POLY)
{
if(data.fill)
@ -3096,12 +3091,8 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
var verts = webGLData.points;
var indices = webGLData.indices;
var length = points.length / 2;
var indexCount = points.length;// + 2;
var indexCount = points.length;
var indexStart = verts.length/6;
// DRAW the Line
@ -3114,118 +3105,133 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
var g = color[1] * alpha;
var b = color[2] * alpha;
// i = 0 //
var point1 = new PIXI.Point( points[0], points[1] );
var point2 = new PIXI.Point( points[2], points[3] );
var p1x, p1y, p2x, p2y, p3x, p3y;
var perpx, perpy, perp2x, perp2y, perp3x, perp3y;
var ipx, ipy;
var a1, b1, c1, a2, b2, c2;
var denom, pdist, dist;
var perp = new PIXI.Point(-(point1.y - point2.y), point1.x - point2.x);
var dist = Math.sqrt(perp.x*perp.x + perp.y*perp.y);
p1x = points[0];
p1y = points[1];
perp.x /= dist;
perp.y /= dist;
perp.x *= width;
perp.y *= width;
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(points[0] - perp.x , points[1] - perp.y);
verts.push(r, g, b, alpha);
verts.push(points[0] + perp.x , points[1] + perp.y);
verts.push(r, g, b, alpha);
verts.push(p1x + perpx , p1y + perpy,
r, g, b, alpha);
for (var i = 1; i < length-1; i++)
{
var point1 = new PIXI.Point( points[(i-1)*2],points[(i-1)*2 + 1] );
var point2 = new PIXI.Point(points[(i)*2],points[(i)*2 + 1] );
var point3 = new PIXI.Point(points[(i+1)*2],points[(i+1)*2 + 1] );
p1x = points[(i-1)*2];
p1y = points[(i-1)*2 + 1];
var perp = new PIXI.Point(-(point1.y - point2.y), point1.x - point2.x);
var dist = Math.sqrt(perp.x*perp.x + perp.y*perp.y);
perp.x /= dist;
perp.y /= dist;
perp.x *= width;
perp.y *= width;
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;
var perp2 = new PIXI.Point(-(point2.y - point3.y), point2.x - point3.x);
var dist2 = Math.sqrt(perp2.x*perp2.x + perp2.y*perp2.y);
perp2.x /= dist2;
perp2.y /= dist2;
perp2.x *= width;
perp2.y *= width;
perp2x = -(p2y - p3y);
perp2y = p2x - p3x;
var A = new PIXI.Point(-perp.x+ point2.x , -perp.y+point2.y);
var B = new PIXI.Point(-perp.x+ point1.x, -perp.y+point1.y);
dist = Math.sqrt(perp2x*perp2x + perp2y*perp2y);
perp2x /= dist;
perp2y /= dist;
perp2x *= width;
perp2y *= width;
var E = new PIXI.Point(-perp2.x+ point2.x , -perp2.y+point2.y );
var F = new PIXI.Point(-perp2.x+ point3.x , -perp2.y+point3.y );
var a1 = B.y-A.y;
var b1 = A.x-B.x;
var c1 = B.x*A.y - A.x*B.y;
var a2 = F.y-E.y;
var b2 = E.x-F.x;
var c2 = F.x*E.y - E.x*F.y;
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);
var denom = a1*b2 - a2*b1;
denom = a1*b2 - a2*b1;
if (denom == 0) {
denom+=1;
}
var p = new PIXI.Point();
p.x = (b1*c2 - b2*c1)/denom;
p.y = (a2*c1 - a1*c2)/denom;
px = (b1*c2 - b2*c1)/denom;
py = (a2*c1 - a1*c2)/denom;
var pdist = (p.x -point2.x) * (p.x -point2.x) + (p.y -point2.y) + (p.y -point2.y);
pdist = (px -p2x) * (px -p2x) + (py -p2y) + (py -p2y);
if(pdist > 140 * 140)
{
var perp3 = new PIXI.Point(perp.x - perp2.x, perp.y - perp2.y);
var dist3 = Math.sqrt(perp3.x*perp3.x + perp3.y*perp3.y);
perp3.x /= dist3;
perp3.y /= dist3;
perp3.x *= width;
perp3.y *= width;
perp3x = perpx - perp2x;
perp3y = perpy - perp2y;
verts.push(point2.x - perp3.x, point2.y -perp3.y);
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(point2.x + perp3.x, point2.y +perp3.y);
verts.push(p2x + perp3x, p2y +perp3y);
verts.push(r, g, b, alpha);
verts.push(point2.x - perp3.x, point2.y -perp3.y);
verts.push(p2x - perp3x, p2y -perp3y);
verts.push(r, g, b, alpha);
indexCount++;
}
else
{
verts.push(p.x , p.y);
verts.push(px , py);
verts.push(r, g, b, alpha);
verts.push(point2.x - (p.x-point2.x), point2.y - (p.y - point2.y));//, 4);
verts.push(p2x - (px-p2x), p2y - (py - p2y));//, 4);
verts.push(r, g, b, alpha);
}
}
var point1 = new PIXI.Point( points[(length-2)*2], points[(length-2)*2 + 1] );
var point2 = new PIXI.Point( points[(length-1)*2], points[(length-1)*2 + 1] );
p1x = points[(length-2)*2]
p1y = points[(length-2)*2 + 1]
var perp = new PIXI.Point(-(point1.y - point2.y), point1.x - point2.x);
var dist = Math.sqrt(perp.x*perp.x + perp.y*perp.y);
perp.x /= dist;
perp.y /= dist;
perp.x *= width;
perp.y *= width;
p2x = points[(length-1)*2]
p2y = points[(length-1)*2 + 1]
verts.push(point2.x - perp.x , point2.y - perp.y)
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(point2.x + perp.x , point2.y + perp.y)
verts.push(p2x + perpx , p2y + perpy)
verts.push(r, g, b, alpha);
indices.push(indexStart);
@ -3259,8 +3265,6 @@ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData)
var triangles = PIXI.PolyK.Triangulate(points);
var vertPos = verts.length / 6;
for (var i=0; i < triangles.length; i+=3)
@ -3272,8 +3276,6 @@ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData)
indices.push(triangles[i+2] + vertPos);
};
indices.push(triangles[i+2] + vertPos);
for (var i = 0; i < length; i++)
{
verts.push(points[i * 2], points[i * 2 + 1],
@ -5464,18 +5466,22 @@ PIXI.CanvasRenderer.prototype.renderStrip = function(strip)
/**
* A DisplayObjectContainer represents a collection of display objects. It is the base class of all display objects that act as a container for other objects.
* @class DisplayObjectContainer
* @extends DisplayObject
* @constructor
* A set of functions used by the canvas renderer to draw the primitive graphics data
* @class CanvasGraphics
*/
PIXI.CanvasGraphics = function()
{
}
// constructor
/*
* @private
* @static
* @method renderGraphics
* @param graphics {Graphics}
* @param context {Context2D}
*/
PIXI.CanvasGraphics.renderGraphics = function(graphics, context)
{
@ -5635,6 +5641,7 @@ PIXI.Graphics.constructor = PIXI.Graphics;
PIXI.Graphics.prototype = Object.create( PIXI.DisplayObjectContainer.prototype );
/**
* Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method.
* @method lineStyle
* @param lineWidth {Number}
* @param color {Number}
@ -5655,6 +5662,7 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
}
/**
* Moves the current drawing position to (x, y).
* @method moveTo
* @param x {Number}
* @param y {Number}
@ -5666,14 +5674,13 @@ PIXI.Graphics.prototype.moveTo = function(x, y)
this.currentPath = this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
// {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha, points:[], type:PIXI.Graphics.POLY};
this.currentPath.points.push(x, y);
this.graphicsData.push(this.currentPath);
}
/**
* Draws a line using the current line style from the current drawing position to (x, y); the current drawing position is then set to (x, y).
* @method lineTo
* @param x {Number}
* @param y {Number}
@ -5685,9 +5692,10 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
}
/**
* Specifies a simple one-color fill that subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) use when drawing.
* @method beginFill
* @param color {Number}
* @param alpha {Number}
* @param color {uint} the color of the fill
* @param alpha {Number} the alpha
*/
PIXI.Graphics.prototype.beginFill = function(color, alpha)
{
@ -5697,6 +5705,7 @@ PIXI.Graphics.prototype.beginFill = function(color, alpha)
}
/**
* Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.
* @method endFill
*/
PIXI.Graphics.prototype.endFill = function()
@ -5726,6 +5735,7 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height )
}
/**
* Draws a circle.
* @method drawCircle
* @param x {Number}
* @param y {Number}
@ -5744,6 +5754,7 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
}
/**
* Draws an elipse.
* @method drawElipse
* @param x {Number}
* @param y {Number}
@ -5763,10 +5774,14 @@ PIXI.Graphics.prototype.drawElipse = function( x, y, width, height)
}
/**
* Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
* @method clear
*/
PIXI.Graphics.prototype.clear = function()
{
this.lineWidth = 0;
this.filling = false;
this.dirty = true;
this.clearDirty = true;
this.graphicsData = [];