Updating to Pixi 1.6.1

This commit is contained in:
photonstorm 2014-07-18 11:22:55 +01:00
parent 883c11e377
commit f9a6d1f376
15 changed files with 91 additions and 69 deletions

View file

@ -78,7 +78,7 @@ PIXI.sayHello = function (type)
if ( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 )
{
var args = [
'%c %c %c Pixi.js ' + PIXI.VERSION + ' - ' + type + ' %c ' + ' %c ' + ' http://pixijs.com %c %c ♥%c♥%c♥ ',
'%c %c %c Pixi.js ' + PIXI.VERSION + ' - ' + type + ' %c ' + ' %c ' + ' http://www.pixijs.com/ %c %c ♥%c♥%c♥ ',
'background: #ff66a5',
'background: #ff66a5',
'color: #ff66a5; background: #030307;',
@ -96,7 +96,7 @@ PIXI.sayHello = function (type)
}
else if (window['console'])
{
console.log('Pixi.js ' + PIXI.VERSION + ' - http://pixjs.com');
console.log('Pixi.js ' + PIXI.VERSION + ' - http://www.pixijs.com/');
}
PIXI.dontSayHello = true;

View file

@ -42,8 +42,19 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
return this.scale.x * this.getLocalBounds().width;
},
set: function(value) {
this.scale.x = value / (this.getLocalBounds().width/this.scale.x);
var width = this.getLocalBounds().width;
if(width !== 0)
{
this.scale.x = value / ( width/this.scale.x );
}
else
{
this.scale.x = 1;
}
this._width = value;
}
});
@ -61,7 +72,18 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
return this.scale.y * this.getLocalBounds().height;
},
set: function(value) {
this.scale.y = value / (this.getLocalBounds().height/this.scale.y);
var height = this.getLocalBounds().height;
if(height !== 0)
{
this.scale.y = value / ( height/this.scale.y );
}
else
{
this.scale.y = 1;
}
this._height = value;
}
});

View file

@ -1286,7 +1286,7 @@ spine.AtlasRegion.prototype = {
index: 0,
rotate: false,
splits: null,
pads: null,
pads: null
};
spine.AtlasReader = function (text) {

View file

@ -10,7 +10,7 @@ PIXI.BlurXFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: '1f', value: 1/512},
blur: {type: '1f', value: 1/512}
};
this.fragmentSrc = [

View file

@ -10,7 +10,7 @@ PIXI.BlurYFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: '1f', value: 1/512},
blur: {type: '1f', value: 1/512}
};
this.fragmentSrc = [

View file

@ -21,7 +21,7 @@ PIXI.ColorMatrixFilter = function()
matrix: {type: 'mat4', value: [1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1]},
0,0,0,1]}
};
this.fragmentSrc = [

View file

@ -16,7 +16,7 @@ PIXI.ColorStepFilter = function()
// set the uniforms
this.uniforms = {
step: {type: '1f', value: 5},
step: {type: '1f', value: 5}
};
this.fragmentSrc = [

View file

@ -10,7 +10,7 @@ PIXI.CrossHatchFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: '1f', value: 1 / 512},
blur: {type: '1f', value: 1 / 512}
};
this.fragmentSrc = [

View file

@ -16,7 +16,7 @@ PIXI.GrayFilter = function()
// set the uniforms
this.uniforms = {
gray: {type: '1f', value: 1},
gray: {type: '1f', value: 1}
};
this.fragmentSrc = [

View file

@ -16,7 +16,7 @@ PIXI.InvertFilter = function()
// set the uniforms
this.uniforms = {
invert: {type: '1f', value: 1},
invert: {type: '1f', value: 1}
};
this.fragmentSrc = [

View file

@ -18,7 +18,7 @@ PIXI.PixelateFilter = function()
this.uniforms = {
invert: {type: '1f', value: 0},
dimensions: {type: '4fv', value:new Float32Array([10000, 100, 10, 10])},
pixelSize: {type: '2f', value:{x:10, y:10}},
pixelSize: {type: '2f', value:{x:10, y:10}}
};
this.fragmentSrc = [

View file

@ -16,7 +16,7 @@ PIXI.SepiaFilter = function()
// set the uniforms
this.uniforms = {
sepia: {type: '1f', value: 1},
sepia: {type: '1f', value: 1}
};
this.fragmentSrc = [

View file

@ -10,7 +10,7 @@ PIXI.SmartBlurFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: '1f', value: 1/512},
blur: {type: '1f', value: 1/512}
};
this.fragmentSrc = [

View file

@ -18,7 +18,7 @@ PIXI.TwistFilter = function()
this.uniforms = {
radius: {type: '1f', value:0.5},
angle: {type: '1f', value:5},
offset: {type: '2f', value:{x:0.5, y:0.5}},
offset: {type: '2f', value:{x:0.5, y:0.5}}
};
this.fragmentSrc = [

View file

@ -174,7 +174,7 @@ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl)
}
else if(data.type === PIXI.Graphics.RREC)
{
PIXI.WebGLGraphics.buildRoundedRectangle(data, webGL);
PIXI.WebGLGraphics.buildRoundedRectangle(data, webGLData);
}
}
@ -298,53 +298,6 @@ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData)
*/
PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
{
/**
* Calcul the points for a quadratic bezier curve.
* Based on : https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
*
* @param {number} fromX Origin point x
* @param {number} fromY Origin point x
* @param {number} cpX Control point x
* @param {number} cpY Control point y
* @param {number} toX Destination point x
* @param {number} toY Destination point y
* @return {number[]}
*/
function quadraticBezierCurve(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 <= 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;
}
var points = graphicsData.points;
var x = points[0];
@ -356,10 +309,10 @@ PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
var recPoints = [];
recPoints.push(x, y + radius);
recPoints = recPoints.concat(quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height));
recPoints = recPoints.concat(quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius));
recPoints = recPoints.concat(quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y));
recPoints = recPoints.concat(quadraticBezierCurve(x + radius, y, x, y, 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) {
@ -404,6 +357,53 @@ PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
}
};
/**
* Calcul 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
*
* @param {number} fromX Origin point x
* @param {number} fromY Origin point x
* @param {number} cpX Control point x
* @param {number} cpY Control point y
* @param {number} toX Destination point x
* @param {number} toY Destination point y
* @return {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 <= 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