MCPcopy
hub / github.com/KilledByAPixel/LittleJS / vec2

Function vec2

src/engineMath.js:589–589  ·  view source on GitHub ↗

* Create a 2d vector, can take 1 or 2 scalar values * @param {number} [x] * @param {number} [y] - if y is undefined, x is used for both * @return {Vector2} * @example * let a = vec2(0, 1); // vector with coordinates (0, 1) * a = vec2(5); // set a to (5, 5) * b = vec2(); // set

(x=0, y)

Source from the content-addressed store, hash-verified

587 * b = vec2(); // set b to (0, 0)
588 * @memberof Math */
589function vec2(x=0, y) { return new Vector2(x, y ?? x); }
590
591/**
592 * Check if object is a valid Vector2

Callers 15

util.test.mjsFile · 0.90
smoke.test.mjsFile · 0.90
tween.test.mjsFile · 0.90
math.test.mjsFile · 0.90
engineInput.jsFile · 0.85
keyDirectionFunction · 0.85
gamepadStickFunction · 0.85
gamepadDpadFunction · 0.85
onMouseDownFunction · 0.85
onMouseMoveFunction · 0.85
handleTouchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected