Skip to content

Commit f78009a

Browse files
authored
Merge pull request #8191 from limzykenneth/dev-2.0
Vector toString() consistency fix
2 parents 62ff014 + 73480e8 commit f78009a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/data/local_storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function storage(p5, fn){
147147
value = value.toString();
148148
} else if (value instanceof p5.Vector) {
149149
type = 'p5.Vector';
150-
const coord = [value.x, value.y, value.z];
150+
const coord = value.values;
151151
value = coord;
152152
}
153153
value = JSON.stringify(value);

src/math/p5.Vector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ class Vector {
265265
* function setup() {
266266
* let v = createVector(20, 30);
267267
*
268-
* // Prints 'p5.Vector Object : [20, 30, 0]'.
268+
* // Prints 'vector[20, 30, 0]'.
269269
* print(v.toString());
270270
* }
271271
* </code>
272272
* </div>
273273
*/
274274
toString() {
275-
return `[${this._values.join(', ')}]`;
275+
return `vector[${this._values.join(', ')}]`;
276276
}
277277

278278
/**

test/unit/math/p5.Vector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ suite('p5.Vector', function () {
20352035
describe('vector to string', () => {
20362036
it('should return the string version of a vector', () => {
20372037
v = new mockP5.Vector(1, 2, 3, 4);
2038-
expect(v.toString()).toBe('[1, 2, 3, 4]');
2038+
expect(v.toString()).toBe('vector[1, 2, 3, 4]');
20392039
});
20402040
});
20412041

0 commit comments

Comments
 (0)