* Returns a copy of the p5.Vector object. * * @return {p5.Vector} copy of the p5.Vector object. * * @example * function setup() { * createCanvas(100 ,100); * * background(200); * * // Create a p5.Vector object.
()
| 393 | * } |
| 394 | */ |
| 395 | copy() { |
| 396 | if (this.isPInst) { |
| 397 | return new Vector(this._fromRadians, this._toRadians, ...this.values); |
| 398 | } else { |
| 399 | return new Vector(...this.values); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Adds to a vector's components. |