mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Triangle.getLineA/B/C now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
This commit is contained in:
parent
4704745ac6
commit
968dc05eae
2 changed files with 34 additions and 12 deletions
|
@ -81,6 +81,9 @@
|
|||
* Rectangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Rectangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Rectangle.getLineD now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Triangle.getLineA now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Triangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
* Triangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ var Class = require('../../utils/Class');
|
|||
var Contains = require('./Contains');
|
||||
var GetPoint = require('./GetPoint');
|
||||
var GetPoints = require('./GetPoints');
|
||||
var Line = require('../line/Line');
|
||||
var Random = require('./Random');
|
||||
|
||||
/**
|
||||
|
@ -203,42 +204,60 @@ var Triangle = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Returns a Line object that corresponds to Line A of this Triangle.
|
||||
*
|
||||
* @method Phaser.Geom.Triangle#getLineA
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {{x1:number,y1:number,x2:number,y2:number}} [description]
|
||||
* @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created.
|
||||
*
|
||||
* @return {Phaser.Geom.Line} A Line object that corresponds to line A of this Triangle.
|
||||
*/
|
||||
getLineA: function ()
|
||||
getLineA: function (line)
|
||||
{
|
||||
return { x1: this.x1, y1: this.y1, x2: this.x2, y2: this.y2 };
|
||||
if (line === undefined) { line = new Line(); }
|
||||
|
||||
line.setTo(this.x1, this.y1, this.x2, this.y2);
|
||||
|
||||
return line;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Returns a Line object that corresponds to Line B of this Triangle.
|
||||
*
|
||||
* @method Phaser.Geom.Triangle#getLineB
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {{x1:number,y1:number,x2:number,y2:number}} [description]
|
||||
* @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created.
|
||||
*
|
||||
* @return {Phaser.Geom.Line} A Line object that corresponds to line B of this Triangle.
|
||||
*/
|
||||
getLineB: function ()
|
||||
getLineB: function (line)
|
||||
{
|
||||
return { x1: this.x2, y1: this.y2, x2: this.x3, y2: this.y3 };
|
||||
if (line === undefined) { line = new Line(); }
|
||||
|
||||
line.setTo(this.x2, this.y2, this.x3, this.y3);
|
||||
|
||||
return line;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Returns a Line object that corresponds to Line C of this Triangle.
|
||||
*
|
||||
* @method Phaser.Geom.Triangle#getLineC
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {{x1:number,y1:number,x2:number,y2:number}} [description]
|
||||
* @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created.
|
||||
*
|
||||
* @return {Phaser.Geom.Line} A Line object that corresponds to line C of this Triangle.
|
||||
*/
|
||||
getLineC: function ()
|
||||
getLineC: function (line)
|
||||
{
|
||||
return { x1: this.x3, y1: this.y3, x2: this.x1, y2: this.y1 };
|
||||
if (line === undefined) { line = new Line(); }
|
||||
|
||||
line.setTo(this.x3, this.y3, this.x1, this.y1);
|
||||
|
||||
return line;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue