Static p5_sys::global::createVector[][src]

pub static createVector: CreateVectorInternalType
Expand description

Creates a new p5.Vector (the datatype for storing vectors). This provides a two or three dimensional vector, specifically a Euclidean (also known as geometric) vector. A vector is an entity that has both magnitude and direction.

Examples

let v1;
function setup() {
  createCanvas(100, 100);
  stroke(255, 0, 255);
  v1 = createVector(width / 2, height / 2);
}

function draw() {
  background(255);
  line(v1.x, v1.y, mouseX, mouseY);
}

Parameters

x? x component of the vector

y? y component of the vector

z? z component of the vector