Subtracts from a vector's x
, y
, and z
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])
.
If a value isn't provided for a component, it won't change. For example, v.sub(4, 5)
subtracts 4 from v.x
, 5 from v.y
, and 0 from v.z
. Calling sub()
with no arguments, as in v.sub()
, has no effect.
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)
sub(v1, v2, [target])
Parameters
Returns
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.