function isNumber(n){
if ( typeof(n) === 'number' && Number.isFinite(n) ) {
return true;
}
return false;
}
function isNumberAllowString(n) {
const type = typeof(n);
if ( type === 'number' && Number.isFinite(n) ) {
return true;
}
if ( type === 'string' && n.trim() !== '' && Number.isFinite(n - 0) ) {
return true;
}
return false;
}
class Col {
constructor(r, g, b, a) {
this.r = 0;
this.g = 0;
this.b = 0;
this.a = 0;
if((isNumber(r) == true)&&(4 <=r.length)){
this.r = Number(r[0]);
this.g = Number(r[1]);
this.b = Number(r[2]);
this.a = Number(r[3]);
return this;
}
if(a != undefined){
this.r = Number(r);
this.g = Number(g);
this.b = Number(b);
this.a = Number(a);
return this;
}
return this;
}
}
class Vec2 {
constructor(x, y) {
this.typename = "Vec2";
this.x = 0;
this.y = 0;
if(x != undefined){
if(x.typename == "Vec2"){
this.x = x.x;
this.y = x.y;
return this;
}
else if((isNumber(x) == true)&&(2 <=x.length)){
this.x = Number(x[0]);
this.y = Number(x[1]);
return this;
}
else if(y != undefined){
this.x = Number(x);
this.y = Number(y);
return this;
}
}
return this;
}
}
class Vec3 {
constructor(x, y, z) {
this.typename = "Vec3";
this.x = 0;
this.y = 0;
this.z = 0;
if(x != undefined){
if(x.typename == "Vec3"){
this.x = x.x;
this.y = x.y;
this.z = x.z;
return this;
}
else if((isNumber(x) == true)&&(3 <=x.length)){
this.x = Number(x[0]);
this.y = Number(x[1]);
this.z = Number(x[2]);
return this;
}
else if(z != undefined){
this.x = Number(x);
this.y = Number(y);
this.z = Number(z);
return this;
}
}
return this;
}
}
class Vec4 {
constructor(x, y, z, w) {
this.typename = "Vec4";
this.x = 0;
this.y = 0;
this.z = 0;
this.w = 0;
if(x != undefined){
if(x.typename == "Vec4"){
this.x = x.x;
this.y = x.y;
this.z = x.z;
this.w = x.w;
return this;
}
else if((isNumber(x) == true)&&(4 <=x.length)){
this.x = Number(x[0]);
this.y = Number(x[1]);
this.z = Number(x[2]);
this.w = Number(x[3]);
return this;
}
else if(w != undefined){
this.x = Number(x);
this.y = Number(y);
this.z = Number(z);
this.w = Number(w);
return this;
}
}
return this;
}
}
class Rectangle {
constructor(x, y, w, h) {
this.typename = "Rectangle";
this.x = 0;
this.y = 0;
this.w = 0;
this.h = 0;
if(x != undefined){
if(x.typename == "Rectangle"){
this.x = x.x;
this.y = x.y;
this.w = x.w;
this.h = x.h;
return this;
}
else if((isNumber(x) == true)&&(4 <=x.length)){
this.x = Number(x[0]);
this.y = Number(x[1]);
this.w = Number(x[2]);
this.h = Number(x[3]);
return this;
}
else if(h != undefined){
this.x = Number(x);
this.y = Number(y);
this.w = Number(w);
this.h = Number(h);
return this;
}
}
return this;
}
create(x, y){
var l = x.x;
var r = y.x;
var u = x.y;
var d = y.y;
if(r < l) { l = y.x; r = x.x; }
if(d < u) { u = y.y; d = x.y; }
this.x = l;
this.y = u;
this.w = r - l;
this.h = d - u;
return this;
}
}