MCPcopy Create free account
hub / github.com/SkalskiP/make-sense / convertDirectionToVector

Method convertDirectionToVector

src/utils/DirectionUtil.ts:5–28  ·  view source on GitHub ↗
(direction: Direction)

Source from the content-addressed store, hash-verified

3
4export class DirectionUtil {
5 public static convertDirectionToVector(direction: Direction): IPoint {
6 switch (direction) {
7 case Direction.RIGHT:
8 return {x: 1, y: 0};
9 case Direction.LEFT:
10 return {x: -1, y: 0};
11 case Direction.TOP:
12 return {x: 0, y: 1};
13 case Direction.BOTTOM:
14 return {x: 0, y: -1};
15 case Direction.TOP_RIGHT:
16 return {x: 1, y: 1};
17 case Direction.TOP_LEFT:
18 return {x: -1, y: 1};
19 case Direction.BOTTOM_RIGHT:
20 return {x: 1, y: -1};
21 case Direction.BOTTOM_LEFT:
22 return {x: -1, y: -1};
23 case Direction.CENTER:
24 return {x: 0, y: 0};
25 default:
26 return null;
27 }
28 }
29}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected