@js-draw/math
Advanced tools
Comparing version 1.24.1 to 1.24.2
@@ -510,4 +510,4 @@ "use strict"; | ||
// A command (\w+) | ||
// followed by a set of arguments ([ \t\n0-9eE.,\-%]+) | ||
const partRegex = /(\w+)\s?\(([^)]*)\)/gi; | ||
// followed by a set of arguments ([^)]*) | ||
const partRegex = /(?:^|\W)(\w+)\s?\(([^)]*)\)/gi; | ||
let match; | ||
@@ -514,0 +514,0 @@ let matrix = null; |
@@ -8,2 +8,3 @@ "use strict"; | ||
const LineSegment2_1 = __importDefault(require("./LineSegment2")); | ||
const Mat33_1 = __importDefault(require("../Mat33")); | ||
const Vec2_1 = require("../Vec2"); | ||
@@ -248,2 +249,6 @@ const Abstract2DShape_1 = __importDefault(require("./Abstract2DShape")); | ||
transformedBoundingBox(affineTransform) { | ||
// Optimize transforming by the identity matrix (a common case). | ||
if (affineTransform === Mat33_1.default.identity) { | ||
return this; | ||
} | ||
return Rect2.bboxOf(this.corners.map((corner) => affineTransform.transformVec2(corner))); | ||
@@ -250,0 +255,0 @@ } |
{ | ||
"name": "@js-draw/math", | ||
"version": "1.24.1", | ||
"version": "1.24.2", | ||
"description": "A math library for js-draw. ", | ||
@@ -30,3 +30,3 @@ "types": "./dist/mjs/lib.d.ts", | ||
"devDependencies": { | ||
"@js-draw/build-tool": "^1.24.1", | ||
"@js-draw/build-tool": "^1.24.2", | ||
"@types/bezier-js": "4.1.0", | ||
@@ -48,3 +48,3 @@ "@types/jest": "29.5.5", | ||
], | ||
"gitHead": "ef847374748e32d6d96d993a2236a99d9109a32c" | ||
"gitHead": "32c8db56fc8996c8d485118d1ee37077428344a3" | ||
} |
@@ -613,4 +613,4 @@ import { Point2, Vec2 } from './Vec2'; | ||
// A command (\w+) | ||
// followed by a set of arguments ([ \t\n0-9eE.,\-%]+) | ||
const partRegex = /(\w+)\s?\(([^)]*)\)/gi; | ||
// followed by a set of arguments ([^)]*) | ||
const partRegex = /(?:^|\W)(\w+)\s?\(([^)]*)\)/gi; | ||
let match; | ||
@@ -617,0 +617,0 @@ let matrix: Mat33 | null = null; |
@@ -117,2 +117,6 @@ import Rect2 from './Rect2'; | ||
it('A transformed bounding box', () => { | ||
expect(Rect2.unitSquare.transformedBoundingBox(Mat33.scaling2D(2))).objEq( | ||
new Rect2(0, 0, 2, 2), | ||
); | ||
const rotationMat = Mat33.zRotation(Math.PI / 4); | ||
@@ -119,0 +123,0 @@ const rect = Rect2.unitSquare.translatedBy(Vec2.of(-0.5, -0.5)); |
@@ -313,2 +313,7 @@ import LineSegment2 from './LineSegment2'; | ||
public transformedBoundingBox(affineTransform: Mat33): Rect2 { | ||
// Optimize transforming by the identity matrix (a common case). | ||
if (affineTransform === Mat33.identity) { | ||
return this; | ||
} | ||
return Rect2.bboxOf(this.corners.map((corner) => affineTransform.transformVec2(corner))); | ||
@@ -315,0 +320,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
658082
17848