> For the complete documentation index, see [llms.txt](https://imagineee.gitbook.io/mayo-gl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://imagineee.gitbook.io/mayo-gl/api/vector.md).

# Vector

A 2D Location system

```
class Vector(x: Number, y: Number)
```

If you want to store and do manipulations on 2D positions, use vector.

## Example

```
var pos = new Vector( 10, 20 )
var subtract = new Vector( 0 , 10 )
pos.sub(subtract) // x: 10, y: 10
display.rect({ ...pos.get() , ...})
```

## API

### Initialise

```
(x: Number,y: Number)
```

### get()

returns the x and y in a json object

### set()

set this instance x and y.

parameter: x: Number, y: Number

### add()

adds the provided vector to the current vector

parameter:  Vector

### sub()

subtracts the provided vector from the current vector

parameter:  Vector

### mul()

multiplies the provided vector on the current vector

parameter:  Vector

### div()

divides the provided vector from the current vector

parameter:  Vector

### X

Static variable you can set

### Y

Static variable you can set
