phaser/src/geom/triangle/Offset.js

36 lines
1,022 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2019-01-15 16:20:22 +00:00
* @copyright 2019 Photon Storm Ltd.
2018-02-12 16:01:20 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
2017-10-13 13:11:54 +00:00
/**
2018-12-03 15:16:23 +00:00
* Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset.
2017-10-13 13:11:54 +00:00
*
* @function Phaser.Geom.Triangle.Offset
* @since 3.0.0
*
2018-03-27 13:27:08 +00:00
* @generic {Phaser.Geom.Triangle} O - [triangle,$return]
*
2018-12-03 15:16:23 +00:00
* @param {Phaser.Geom.Triangle} triangle - The Triangle to move.
* @param {number} x - The horizontal offset (distance) by which to move each point. Can be positive or negative.
* @param {number} y - The vertical offset (distance) by which to move each point. Can be positive or negative.
2017-10-13 13:11:54 +00:00
*
2018-12-03 15:16:23 +00:00
* @return {Phaser.Geom.Triangle} The modified Triangle.
2017-10-13 13:11:54 +00:00
*/
var Offset = function (triangle, x, y)
{
triangle.x1 += x;
triangle.y1 += y;
triangle.x2 += x;
triangle.y2 += y;
triangle.x3 += x;
triangle.y3 += y;
return triangle;
};
module.exports = Offset;