@bettergi/types 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,14 @@
1
- TypeScript type definitions for [Better Genshin Impact](https://github.com/babalae/better-genshin-impact) JavaScript scripts.
1
+ 本项目是一个为 [Better Genshin Impact](https://github.com/babalae/better-genshin-impact) 提供的 JavaScript 类型声明文件。
2
2
 
3
- ## Installation
3
+ ## 安装
4
4
 
5
5
  ```shell
6
6
  npm install --save-dev @bettergi/types
7
7
  ```
8
8
 
9
- ## Usage
9
+ ## 用法
10
+
11
+ 在项目的 `tsconfig.json` 文件中添加类型引用。
10
12
 
11
13
  ```json
12
14
  {
@@ -15,7 +17,3 @@ npm install --save-dev @bettergi/types
15
17
  }
16
18
  }
17
19
  ```
18
-
19
- ## Related Tools
20
-
21
- [@bettergi/create-script](https://www.npmjs.com/package/@bettergi/create-script)
@@ -83,8 +83,10 @@ export interface RecognitionObject {
83
83
  /** 颜色匹配方式 */
84
84
  colorConversionCode: ColorConversionCodes;
85
85
 
86
+ /** 起始颜色范围 */
86
87
  lowerColor: Scalar;
87
88
 
89
+ /** 终止颜色范围 */
88
90
  upperColor: Scalar;
89
91
 
90
92
  /**
@@ -108,19 +110,44 @@ export interface RecognitionObject {
108
110
  /** 正则匹配 多个值全匹配的情况下才算成功 */
109
111
  regexMatchText: List<string>;
110
112
 
113
+ /** 初始化模板 */
111
114
  initTemplate(): RecognitionObject;
112
115
  }
113
116
 
114
117
  declare global {
115
118
  namespace RecognitionObject {
119
+ /**
120
+ * 识别图片模板
121
+ * @param mat 模板图片
122
+ */
116
123
  function templateMatch(mat: Mat): RecognitionObject;
117
124
 
125
+ /**
126
+ * 在指定区域识别图片模板
127
+ * @param mat 模板图片
128
+ * @param x 水平位置(像素)
129
+ * @param y 垂直位置(像素)
130
+ * @param w 宽度
131
+ * @param h 高度
132
+ */
118
133
  function templateMatch(mat: Mat, x: number, y: number, w: number, h: number): RecognitionObject;
119
134
 
135
+ /**
136
+ * 识别指定区域
137
+ * @param x 水平位置(像素)
138
+ * @param y 垂直位置(像素)
139
+ * @param w 宽度
140
+ * @param h 高度
141
+ */
120
142
  function ocr(x: number, y: number, w: number, h: number): RecognitionObject;
121
143
 
144
+ /**
145
+ * 识别矩形区域
146
+ * @param rect 矩形
147
+ */
122
148
  function ocr(rect: Rect): RecognitionObject;
123
149
 
150
+ /** 识别文字 */
124
151
  var ocrThis: RecognitionObject;
125
152
  }
126
153
  }
@@ -16,5 +16,6 @@ export enum RecognitionTypes {
16
16
  /** 提取指定颜色后进行文字识别 */
17
17
  ColorRangeAndOcr,
18
18
 
19
+ /** 自动检测 */
19
20
  Detect
20
21
  }
@@ -1,4 +1,7 @@
1
1
  export interface Point {
2
+ /** 目标水平位置(像素) */
2
3
  x: number;
4
+
5
+ /** 目标垂直位置(像素) */
3
6
  y: number;
4
7
  }
@@ -1,9 +1,23 @@
1
1
  export interface POINT {
2
+ /** 目标水平位置(像素) */
2
3
  x: number;
4
+
5
+ /** 目标垂直位置(像素) */
3
6
  y: number;
7
+
8
+ /** 判断该点是否为空 */
4
9
  isEmpty: boolean;
5
10
 
11
+ /**
12
+ * 通过给定的偏移量移动当前点
13
+ * @param dx - x 轴方向的偏移量(正数向右,负数向左)。
14
+ * @param dy - y 轴方向的偏移量(正数向下,负数向上)。
15
+ */
6
16
  offset(dx: number, dy: number): void;
7
17
 
18
+ /**
19
+ * 通过另一个点对象偏移当前点
20
+ * @param p - 包含偏移量的 `POINT` 对象,其 `x` 和 `y` 值会被加到当前点。
21
+ */
8
22
  offset(p: POINT): void;
9
23
  }
@@ -2,17 +2,36 @@ import { POINT } from "./POINT";
2
2
  import { SIZE } from "./SIZE";
3
3
 
4
4
  export interface RECT {
5
+ /** 矩形左侧的 x 坐标 */
5
6
  left: number;
7
+
8
+ /** 矩形顶部的 y 坐标 */
6
9
  top: number;
10
+
11
+ /** 矩形右侧的 x 坐标 */
7
12
  right: number;
13
+
14
+ /** 矩形底部的 y 坐标 */
8
15
  bottom: number;
16
+
17
+ /** 目标水平位置(像素) */
9
18
  x: number;
19
+
20
+ /** 目标垂直位置(像素) */
10
21
  y: number;
22
+
23
+ /** 矩形的宽度 */
11
24
  width: number;
25
+
26
+ /** 矩形的高度 */
12
27
  height: number;
28
+
29
+ /** 判断矩形是否为空 */
13
30
  isEmpty: boolean;
14
31
 
32
+ /** 获取矩形的位置 */
15
33
  location(): POINT;
16
34
 
35
+ /** 获取矩形的尺寸 */
17
36
  size(): SIZE;
18
37
  }
@@ -1,9 +1,19 @@
1
1
  export interface SIZE {
2
+ /** 尺寸的宽度 */
2
3
  cx: number;
4
+
5
+ /** 尺寸的高度 */
3
6
  cy: number;
7
+
8
+ /** 尺寸的宽度 */
4
9
  width: number;
10
+
11
+ /** 尺寸的高度 */
5
12
  height: number;
13
+
14
+ /** 判断尺寸是否为空 */
6
15
  isEmpty: boolean;
7
16
 
17
+ /** 返回当前尺寸的副本 */
8
18
  toSize(): SIZE;
9
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettergi/types",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "TypeScript Definitions for BetterGI JavaScript",
5
5
  "type": "module",
6
6
  "author": "Bread Grocery<https://github.com/breadgrocery>",