-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
Point.js
87 lines (75 loc) · 1.91 KB
/
Point.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var GEOM_CONST = require('../const');
/**
* @classdesc
* Defines a Point in 2D space, with an x and y component.
*
* @class Point
* @memberof Phaser.Geom
* @constructor
* @since 3.0.0
*
* @param {number} [x=0] - The x coordinate of this Point.
* @param {number} [y=x] - The y coordinate of this Point.
*/
var Point = new Class({
initialize:
function Point (x, y)
{
if (x === undefined) { x = 0; }
if (y === undefined) { y = x; }
/**
* The geometry constant type of this object: `GEOM_CONST.POINT`.
* Used for fast type comparisons.
*
* @name Phaser.Geom.Point#type
* @type {number}
* @readonly
* @since 3.19.0
*/
this.type = GEOM_CONST.POINT;
/**
* The x coordinate of this Point.
*
* @name Phaser.Geom.Point#x
* @type {number}
* @default 0
* @since 3.0.0
*/
this.x = x;
/**
* The y coordinate of this Point.
*
* @name Phaser.Geom.Point#y
* @type {number}
* @default 0
* @since 3.0.0
*/
this.y = y;
},
/**
* Set the x and y coordinates of the point to the given values.
*
* @method Phaser.Geom.Point#setTo
* @since 3.0.0
*
* @param {number} [x=0] - The x coordinate of this Point.
* @param {number} [y=x] - The y coordinate of this Point.
*
* @return {this} This Point object.
*/
setTo: function (x, y)
{
if (x === undefined) { x = 0; }
if (y === undefined) { y = x; }
this.x = x;
this.y = y;
return this;
}
});
module.exports = Point;