Skip to content

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js

Fix calcAngle mock sign convention in mass test

acamposuribef21758c312a7
diff --git a/test/unit/mass.test.js b/test/unit/mass.test.js
index 99ffad2..3b6777b 100644
--- a/test/unit/mass.test.js
+++ b/test/unit/mass.test.js
@@ -56,7 +56,10 @@ vi.mock("../../src/core/flowfield.js", () => ({
vi.mock("../../src/core/utils.js", () => ({
rr2: (min = 0, max = 1) => (min + max) / 2,
dist: (x1, y1, x2, y2) => Math.hypot(x2 - x1, y2 - y1),
- calcAngle: (cx, cy, x, y) => (Math.atan2(y - cy, x - cx) * 180) / Math.PI,
+ calcAngle: (x1, y1, x2, y2) => {
+ const deg = (Math.atan2(-(y2 - y1), x2 - x1) * 180) / Math.PI;
+ return deg < 0 ? deg + 360 : deg;
+ },
}));
vi.mock("../../src/core/polygon.js", () => ({