mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 14:33:53 +01:00
22 lines
740 B
Plaintext
22 lines
740 B
Plaintext
|
function Point(x = 0, y = 0) constructor {
|
||
|
if(is_array(x)) {
|
||
|
self.x = x[0];
|
||
|
self.y = x[1];
|
||
|
} else {
|
||
|
self.x = x;
|
||
|
self.y = y;
|
||
|
}
|
||
|
|
||
|
u = 0;
|
||
|
v = 0;
|
||
|
|
||
|
static add = function(x, y) { self.x += x; self.y += y; return self; }
|
||
|
static addPoint = function(p) { self.x += p.x; self.y += p.y; return self; }
|
||
|
static lerpTo = function(p, rat) { return new Point( lerp(x, p.x, rat), lerp(y, p.y, rat) ); }
|
||
|
static directionTo = function(p) { return point_direction(x, y, p.x, p.y); }
|
||
|
static distanceTo = function(p) { return point_distance(x, y, p.x, p.y); }
|
||
|
|
||
|
static equal = function(p) { return x == p.x && y == p.y; }
|
||
|
static clone = function(){ return new Point(x, y); }
|
||
|
static toArray = function() { return [ x, y ]; }
|
||
|
}
|