File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import { NativeAdapter } from "./adapter/native.adapter.class" ;
2+ import { Point } from "./point.class" ;
3+ import { LineHelper } from "./util/linehelper.class" ;
4+
5+ export const createMovementApi = ( native : NativeAdapter , lineHelper : LineHelper ) => {
6+ return ( {
7+ down : async ( px : number ) : Promise < Point [ ] > => {
8+ const pos = await native . currentMousePosition ( ) ;
9+ return lineHelper . straightLine ( pos , new Point ( pos . x , pos . y + px ) ) ;
10+ } ,
11+ left : async ( px : number ) : Promise < Point [ ] > => {
12+ const pos = await native . currentMousePosition ( ) ;
13+ return lineHelper . straightLine ( pos , new Point ( pos . x - px , pos . y ) ) ;
14+ } ,
15+ right : async ( px : number ) : Promise < Point [ ] > => {
16+ const pos = await native . currentMousePosition ( ) ;
17+ return lineHelper . straightLine ( pos , new Point ( pos . x + px , pos . y ) ) ;
18+ } ,
19+ straightTo : async ( target : Point | Promise < Point > ) : Promise < Point [ ] > => {
20+ const targetPoint = await target ;
21+ const origin = await native . currentMousePosition ( ) ;
22+ return lineHelper . straightLine ( origin , targetPoint ) ;
23+ } ,
24+ up : async ( px : number ) : Promise < Point [ ] > => {
25+ const pos = await native . currentMousePosition ( ) ;
26+ return lineHelper . straightLine ( pos , new Point ( pos . x , pos . y - px ) ) ;
27+ } ,
28+ } ) ;
29+ } ;
You can’t perform that action at this time.
0 commit comments