Subtracts from a vector's components.
sub() can use separate numbers, as in v.sub(1, 2, 3), another p5.Vector object, as in v.sub(v2), or an array of numbers, as in v.sub([1, 2, 3]).
Calling sub() with no arguments, as in v.sub(), has no effect.
You should subtract vectors only when they are the same size. When two vectors of different sizes are used, the smaller dimension will be used, any additional values of the longer vector will be ignored. For example, subtracting [1, 2] from [3, 5, 7] will result in [2, 3].
The static version of sub(), as in p5.Vector.sub(v2, v1), returns a new p5.Vector object and doesn't change the originals.
Examples
Syntax
sub(x, [y], [z])
sub(value)
Parameters
Related References
textToContours
Returns an array of arrays of points outlining a string of text written using the font.
textToModel
Converts text into a 3D model that can be rendered in WebGL mode.
textToPaths
Returns a flat array of path commands that describe the outlines of a string of text.
textToPoints
Returns an array of points outlining a string of text written using the font.