Multiplies a vector's components.
mult() can use separate numbers, as in v.mult(1, 2, 3), another p5.Vector object, as in v.mult(v2), or an array of numbers, as in v.mult([1, 2, 3]).
If only one value is provided, as in v.mult(2), then all the components will be multiplied by 2. Calling mult() with no arguments, as in v.mult(), has no effect.
You should multiply vectors only when they are the same size. When two vectors of different sizes are multiplied, the smaller dimension will be used, any additional values of the longer vector will be ignored. For example, multiplying [1, 2, 3] by [4, 5] will result in [4, 10].
The static version of mult(), as in p5.Vector.mult(v, 2), returns a new p5.Vector object and doesn't change the originals.
Examples
Syntax
mult(n)
mult(x, y, [z])
mult(arr)
mult(v)
Parameters
n
Number: The number to multiply with the vector
x
Number: number to multiply with the x component of the vector.
y
Number: number to multiply with the y component of the vector.
z
Number: number to multiply with the z component of the vector.
arr
Number[]: array to multiply with the components of the vector.
v
p5.Vector: vector to multiply with the components of the original vector.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!