arcade-physics
Version:
Use Arcade Physics without Phaser.
35 lines • 1.32 kB
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Point_1 = __importDefault(require("../point/Point"));
/**
* Get a point on a line that's a given percentage along its length.
*
* @function Phaser.Geom.Line.GetPoint
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Line} line - The line.
* @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line.
* @param {(Phaser.Geom.Point|object)} [out] - An optional point, or point-like object, to store the coordinates of the point on the line.
*
* @return {(Phaser.Geom.Point|object)} The point on the line.
*/
const GetPoint = (line, position, out) => {
if (out === undefined) {
out = new Point_1.default();
}
out.x = line.x1 + (line.x2 - line.x1) * position;
out.y = line.y1 + (line.y2 - line.y1) * position;
return out;
};
exports.default = GetPoint;
//# sourceMappingURL=GetPoint.js.map