-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.2.1-rc.0
Web browser and version
Any (reproduced on Chrome 132)
Operating system
Windows 11
Steps to reproduce this
div() with multiple number args uses args[0] for all components instead of args[i]. So v.div(2, 4, 6) on (10, 20, 30) gives (5, 10, 15) instead of (5, 5, 5)
One char typo p5.Vector.js line 1241:
this._values = this._values.map((val, i) => val / args[0]); // should be args[i]
Also mult() straight up has no branch for multiple number args. v.mult(2, 3, 4) silently returns the vector unchanged. No warning, nothing. Docs say both should work
add() and sub() handle this fine btw
function setup() {
let v1 = createVector(10, 20, 30);
v1.div(2, 4, 6);
console.log(v1.toString()); // (5, 10, 15) — wrong, should be (5, 5, 5)
let v2 = createVector(10, 20, 30);
v2.mult(2, 3, 4);
console.log(v2.toString()); // (10, 20, 30) — unchanged, should be (20, 60, 120)
}Reactions are currently unavailable