initial commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
shadow$provide.module$node_modules$pixi_DOT_js$lib$maths$shapes$Triangle = function(global, require, module, exports) {
|
||||
var squaredDistanceToLineSegment = require("module$node_modules$pixi_DOT_js$lib$maths$misc$squaredDistanceToLineSegment"), Rectangle = require("module$node_modules$pixi_DOT_js$lib$maths$shapes$Rectangle");
|
||||
"use strict";
|
||||
class Triangle {
|
||||
constructor(x = 0, y = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0) {
|
||||
this.type = "triangle";
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.x3 = x3;
|
||||
this.y3 = y3;
|
||||
}
|
||||
contains(x, y) {
|
||||
const s = (this.x - this.x3) * (y - this.y3) - (this.y - this.y3) * (x - this.x3), t = (this.x2 - this.x) * (y - this.y) - (this.y2 - this.y) * (x - this.x);
|
||||
if (0 > s !== 0 > t && 0 !== s && 0 !== t) {
|
||||
return !1;
|
||||
}
|
||||
x = (this.x3 - this.x2) * (y - this.y2) - (this.y3 - this.y2) * (x - this.x2);
|
||||
return 0 === x || 0 > x === 0 >= s + t;
|
||||
}
|
||||
strokeContains(pointX, pointY, strokeWidth, _alignment) {
|
||||
strokeWidth /= 2;
|
||||
strokeWidth *= strokeWidth;
|
||||
const {x, x2, x3, y, y2, y3} = this;
|
||||
return squaredDistanceToLineSegment.squaredDistanceToLineSegment(pointX, pointY, x, y, x2, y3) <= strokeWidth || squaredDistanceToLineSegment.squaredDistanceToLineSegment(pointX, pointY, x2, y2, x3, y3) <= strokeWidth || squaredDistanceToLineSegment.squaredDistanceToLineSegment(pointX, pointY, x3, y3, x, y) <= strokeWidth ? !0 : !1;
|
||||
}
|
||||
clone() {
|
||||
return new Triangle(this.x, this.y, this.x2, this.y2, this.x3, this.y3);
|
||||
}
|
||||
copyFrom(triangle) {
|
||||
this.x = triangle.x;
|
||||
this.y = triangle.y;
|
||||
this.x2 = triangle.x2;
|
||||
this.y2 = triangle.y2;
|
||||
this.x3 = triangle.x3;
|
||||
this.y3 = triangle.y3;
|
||||
return this;
|
||||
}
|
||||
copyTo(triangle) {
|
||||
triangle.copyFrom(this);
|
||||
return triangle;
|
||||
}
|
||||
getBounds(out) {
|
||||
out || (out = new Rectangle.Rectangle());
|
||||
const minX = Math.min(this.x, this.x2, this.x3), maxX = Math.max(this.x, this.x2, this.x3), minY = Math.min(this.y, this.y2, this.y3), maxY = Math.max(this.y, this.y2, this.y3);
|
||||
out.x = minX;
|
||||
out.y = minY;
|
||||
out.width = maxX - minX;
|
||||
out.height = maxY - minY;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
exports.Triangle = Triangle;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$maths$shapes$Triangle.js.map
|
||||
Reference in New Issue
Block a user