ms-vite-plugin 1.4.56 → 1.4.57

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/docs/api/image.md CHANGED
@@ -504,6 +504,7 @@ function findImage(
504
504
  rgb?: boolean,
505
505
  options?: {
506
506
  scaleFactors?: number[];
507
+ orz?: number;
507
508
  },
508
509
  ): {
509
510
  index: number; // 模板图片索引,从 0 开始
@@ -533,8 +534,9 @@ function findImage(
533
534
  | `limit` | number | 是 | - | 最大查找数量,每个模板图片最多找 limit 个匹配结果 |
534
535
  | `method` | number | 是 | - | 匹配方法,见下方说明 |
535
536
  | `rgb` | boolean | 否 | `false` | 是否使用 RGB 找图,默认 `false` 会自动转灰度找图 |
536
- | `options` | object | 否 | - | 额外选项,目前仅 method=`99` 时生效 |
537
+ | `options` | object | 否 | - | 额外选项。`scaleFactors` method=`99` 生效;`orz` 用于按方向取结果 |
537
538
  | `options.scaleFactors` | number\[] | 否 | `[1.0, 0.9, 1.1, 0.8, 1.2]` | 仅 method=`99` 生效。模板相对当前图的缩放比列表(**不是** `device.getScreenScale()`)。应按 baseScale 动态计算,见下方详解;默认值只适合尺寸接近时的盲扫 |
539
+ | `options.orz` | number | 否 | 不传 | 查找方向(1-8),与找色 `orz` 相同。不传或非 1-8 时仍按相似度从高到低返回。传入 1-8 时按该方向取前 `limit` 个达标结果;`limit=1` 时只返回该方向第一个,不会把其余命中都找出来。method `0`(SIFT)会先完成匹配再按方向排序截取 |
538
540
 
539
541
  #### method 匹配方法说明
540
542
 
@@ -744,6 +746,24 @@ if (matches.length > 0) {
744
746
  action.click(best.centerX, best.centerY, 100, false);
745
747
  }
746
748
 
749
+ // 只要右下角那一个(界面上可能有很多份,不必全找出来)
750
+ const corner = image.findImage(
751
+ "screen",
752
+ "btn.png",
753
+ 0,
754
+ 0,
755
+ 0,
756
+ 0,
757
+ 0.9,
758
+ 1,
759
+ 5,
760
+ false,
761
+ { orz: 5 }, // 与找色相同:5 右下角起,纵向开始
762
+ );
763
+ if (corner.length > 0) {
764
+ action.click(corner[0].centerX, corner[0].centerY, 100, false);
765
+ }
766
+
747
767
  // 2) 缩放全分辨率找图:按「截模板设备宽 / 当前设备宽」计算比例
748
768
  // 假设模板是在宽度 750 的设备上截的
749
769
  const templateDeviceWidth = 750;
@@ -511,6 +511,7 @@ function 找图(
511
511
  是否使用RGB找图?: 布尔值,
512
512
  选项?: {
513
513
  scaleFactors?: 数字[];
514
+ orz?: 数字;
514
515
  },
515
516
  ): {
516
517
  index: 数字; // 模板图片索引,从 0 开始
@@ -542,8 +543,9 @@ function 找图(
542
543
  | `限制数量` | 数字 | 是 | - | 最大查找数量,每个模板图片最多找 限制数量 个匹配结果 |
543
544
  | `方法` | 数字 | 是 | - | 匹配方法,见下方说明 |
544
545
  | `是否使用RGB找图` | 布尔值 | 否 | `false` | 是否使用 RGB 找图,默认 `false` 会自动转灰度找图 |
545
- | `选项` | 对象 | 否 | - | 额外选项,目前仅 方法=`99` 时生效 |
546
+ | `选项` | 对象 | 否 | - | 额外选项。`scaleFactors` 方法=`99` 生效;`orz` 用于按方向取结果 |
546
547
  | `选项.scaleFactors` | 数字\[] | 否 | `[1.0, 0.9, 1.1, 0.8, 1.2]` | 仅 方法=`99` 生效。模板相对当前图的缩放比列表(**不是** `$设备.获取屏幕缩放比例()`)。应按 baseScale 动态计算,见下方详解;默认值只适合尺寸接近时的盲扫 |
548
+ | `选项.orz` | 数字 | 否 | 不传 | 查找方向(1-8),与单点找色的查找方向相同。不传或非 1-8 时仍按相似度从高到低返回。传入 1-8 时按该方向取前 `限制数量` 个达标结果;`限制数量=1` 时只返回该方向第一个,不会把其余命中都找出来。方法 `0`(SIFT)会先完成匹配再按方向排序截取 |
547
549
 
548
550
  #### 方法(method)匹配说明
549
551
 
@@ -753,6 +755,24 @@ if (匹配区域数组.length > 0) {
753
755
  $动作.点击(best.centerX, best.centerY, 100, false);
754
756
  }
755
757
 
758
+ // 只要右下角那一个(界面上可能有很多份,不必全找出来)
759
+ const 右下角 = $图片.找图(
760
+ "screen",
761
+ "btn.png",
762
+ 0,
763
+ 0,
764
+ 0,
765
+ 0,
766
+ 0.9,
767
+ 1,
768
+ 5,
769
+ false,
770
+ { orz: 5 }, // 与单点找色相同:5 右下角起,纵向开始
771
+ );
772
+ if (右下角.length > 0) {
773
+ $动作.点击(右下角[0].centerX, 右下角[0].centerY, 100, false);
774
+ }
775
+
756
776
  // 2) 缩放全分辨率找图:按「截模板设备宽 / 当前设备宽」计算比例
757
777
  // 假设模板是在宽度 750 的设备上截的
758
778
  const 模板设备宽 = 750;
@@ -614,8 +614,9 @@ function findImage(imageId, templateImageId, x, y, ex, ey, threshold, limit, met
614
614
  | `limit` | number | 是 | - | 最大查找数量,每个模板图片最多找 limit 个匹配结果 |
615
615
  | `method` | number | 是 | - | 匹配方法,见下方说明 |
616
616
  | `rgb` | boolean | 否 | `false` | 是否使用 RGB 找图,默认 `false` 会自动转灰度找图 |
617
- | `options` | table | 否 | - | 额外选项,目前仅 method=`99` 时生效 |
617
+ | `options` | table | 否 | - | 额外选项。`scaleFactors` method=`99` 生效;`orz` 用于按方向取结果 |
618
618
  | `options.scaleFactors` | number\[] | 否 | `[1.0, 0.9, 1.1, 0.8, 1.2]` | 仅 method=`99` 生效。模板相对当前图的缩放比列表(**不是** `device.getScreenScale()`)。应按 baseScale 动态计算,见下方详解;默认值只适合尺寸接近时的盲扫 |
619
+ | `options.orz` | number | 否 | 不传 | 查找方向(1-8),与找色 `orz` 相同。不传或非 1-8 时仍按相似度从高到低返回。传入 1-8 时按该方向取前 `limit` 个达标结果;`limit=1` 时只返回该方向第一个,不会把其余命中都找出来。method `0`(SIFT)会先完成匹配再按方向排序截取 |
619
620
 
620
621
  #### method 匹配方法说明
621
622
 
@@ -824,6 +825,24 @@ if #matches > 0 then
824
825
  print("找到匹配,置信度: " .. tostring(best.confidence))
825
826
  action.click(best.centerX, best.centerY, 100, false)
826
827
  end
828
+
829
+ -- 只要右下角那一个(界面上可能有很多份,不必全找出来)
830
+ local corner = image.findImage(
831
+ "screen",
832
+ "btn.png",
833
+ 0,
834
+ 0,
835
+ 0,
836
+ 0,
837
+ 0.9,
838
+ 1,
839
+ 5,
840
+ false,
841
+ { orz = 5 } -- 与找色相同:5 右下角起,纵向开始
842
+ )
843
+ if #corner > 0 then
844
+ action.click(corner[1].centerX, corner[1].centerY, 100, false)
845
+ end
827
846
  -- 2) 缩放全分辨率找图:按「截模板设备宽 / 当前设备宽」计算比例
828
847
  -- 假设模板是在宽度 750 的设备上截的
829
848
  local templateDeviceWidth = 750
@@ -479,8 +479,9 @@ def findImage(id: str, templateImageId: str, x: int, y: int, ex: int, ey: int, t
479
479
  | `limit` | int | 是 | <br /> | 最大查找数量,每个模板图片最多找 limit 个匹配结果 |
480
480
  | `method` | int | 是 | <br /> | 匹配方法,见下方说明 |
481
481
  | `rgb` | bool | 否 | `False` | 是否使用 RGB 找图,默认 `False` 会自动转灰度找图 |
482
- | `options` | dict | 否 | `{}` | 额外选项,目前仅 method=`99` 时生效 |
482
+ | `options` | dict | 否 | `{}` | 额外选项。`scaleFactors` method=`99` 生效;`orz` 用于按方向取结果 |
483
483
  | `options.scaleFactors` | list\[float] | 否 | `[1.0, 0.9, 1.1, 0.8, 1.2]` | 仅 method=`99` 生效。模板相对当前图的缩放比列表(**不是** `device.getScreenScale()`)。应按 baseScale 动态计算,见下方详解;默认值只适合尺寸接近时的盲扫 |
484
+ | `options.orz` | int | 否 | 不传 | 查找方向(1-8),与找色 `orz` 相同。不传或非 1-8 时仍按相似度从高到低返回。传入 1-8 时按该方向取前 `limit` 个达标结果;`limit=1` 时只返回该方向第一个,不会把其余命中都找出来。method `0`(SIFT)会先完成匹配再按方向排序截取 |
484
485
 
485
486
  #### method 匹配方法说明
486
487
 
@@ -690,6 +691,23 @@ if len(matches) > 0:
690
691
  print(f"找到匹配,置信度: {best.confidence}")
691
692
  action.click(best.centerX, best.centerY, 100, False)
692
693
 
694
+ # 只要右下角那一个(界面上可能有很多份,不必全找出来)
695
+ corner = image.findImage(
696
+ "screen",
697
+ "btn.png",
698
+ 0,
699
+ 0,
700
+ 0,
701
+ 0,
702
+ 0.9,
703
+ 1,
704
+ 5,
705
+ False,
706
+ {"orz": 5}, # 与找色相同:5 右下角起,纵向开始
707
+ )
708
+ if corner:
709
+ action.click(corner[0].centerX, corner[0].centerY, 100, False)
710
+
693
711
  # 2) 缩放全分辨率找图:按「截模板设备宽 / 当前设备宽」计算比例
694
712
  # 假设模板是在宽度 750 的设备上截的
695
713
  template_device_width = 750
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.4.56",
3
+ "version": "1.4.57",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {