add screen capture and color searching
This commit is contained in:
3
app/src/main/assets/help/documentation/图片与图色处理.md
Normal file
3
app/src/main/assets/help/documentation/图片与图色处理.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### requestScreenCapture(\[width, height\])
|
||||
|
||||
* width \<Number\> 可选参数
|
||||
@@ -5,7 +5,8 @@ var dialogs = {};
|
||||
|
||||
dialogs.rawInput = function(title, prefill){
|
||||
prefill = prefill || "";
|
||||
return String(__runtime__.dialogs.rawInput(title, prefill));
|
||||
var s = __runtime__.dialogs.rawInput(title, prefill);
|
||||
return s ? String(s) : null;
|
||||
};
|
||||
|
||||
dialogs.input = function(title, prefill){
|
||||
|
||||
17
app/src/main/assets/sample/图片与图色处理/区域找色1.js
Normal file
17
app/src/main/assets/sample/图片与图色处理/区域找色1.js
Normal file
@@ -0,0 +1,17 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
//0xffffff为白色
|
||||
toastLog("开始找色");
|
||||
//指定在位置(90, 220)宽高为900*1000的区域找色。
|
||||
//0xff00cc是编辑器的深粉红色字体(字符串)颜色
|
||||
var point = findColorInRegion(img, 0xff00cc, 90, 220, 900, 1000);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
|
||||
|
||||
18
app/src/main/assets/sample/图片与图色处理/区域找色2.js
Normal file
18
app/src/main/assets/sample/图片与图色处理/区域找色2.js
Normal file
@@ -0,0 +1,18 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
//0xffffff为白色
|
||||
toastLog("开始找色");
|
||||
//指定在位置(90, 220)宽高为900*1000的区域找色。
|
||||
//0xff00cc是编辑器的深粉红色字体(字符串)颜色
|
||||
var point = findColor(img, 0xff00cc, {
|
||||
region: [90, 220, 900, 1000],
|
||||
threads: 8
|
||||
});
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
19
app/src/main/assets/sample/图片与图色处理/多线程找色.js
Normal file
19
app/src/main/assets/sample/图片与图色处理/多线程找色.js
Normal file
@@ -0,0 +1,19 @@
|
||||
//减少截图分辨率以提高速度
|
||||
if(!requestScreenCapture(640, 960)){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
toastLog("开始找色");
|
||||
//0x02b902为输入法绿色字体的颜色
|
||||
var point = findColor(img, 0x02b902, {
|
||||
//指定用8个线程找色
|
||||
threads: 8
|
||||
});
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
|
||||
|
||||
6
app/src/main/assets/sample/图片与图色处理/截图并保存1.js
Normal file
6
app/src/main/assets/sample/图片与图色处理/截图并保存1.js
Normal file
@@ -0,0 +1,6 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
images.saveImage(img, "/sdcard/1.png");
|
||||
6
app/src/main/assets/sample/图片与图色处理/截图并保存2.js
Normal file
6
app/src/main/assets/sample/图片与图色处理/截图并保存2.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//指定截图分辨率为 640×960
|
||||
if(!requestScreenCapture(640, 960)){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
captureScreen("/sdcard/1.png");
|
||||
16
app/src/main/assets/sample/图片与图色处理/找到QQ红点位置.js
Normal file
16
app/src/main/assets/sample/图片与图色处理/找到QQ红点位置.js
Normal file
@@ -0,0 +1,16 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
launchApp("QQ");
|
||||
sleep(2000);
|
||||
var img = captureScreen();
|
||||
toastLog("开始找色");
|
||||
var point = findColor(img, 0xf64d30);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
|
||||
|
||||
22
app/src/main/assets/sample/图片与图色处理/找色与找色算法.js
Normal file
22
app/src/main/assets/sample/图片与图色处理/找色与找色算法.js
Normal file
@@ -0,0 +1,22 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
//0xffffff为白色
|
||||
toastLog("开始找色");
|
||||
var point = findColor(img, 0xffffff, {
|
||||
//指定算法为rgb+,更默认算法rgb更准确,但时间更久
|
||||
algorithm: "rgb+",
|
||||
//指定颜色临界值为16
|
||||
threshold: 16,
|
||||
//指定用8个线程找色
|
||||
threads: 8
|
||||
});
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
|
||||
|
||||
15
app/src/main/assets/sample/图片与图色处理/模糊找色.js
Normal file
15
app/src/main/assets/sample/图片与图色处理/模糊找色.js
Normal file
@@ -0,0 +1,15 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
//0x9966ff为编辑器紫色字体的颜色
|
||||
toastLog("开始找色");
|
||||
var point = findColor(img, 0x9966ff);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
|
||||
|
||||
16
app/src/main/assets/sample/图片与图色处理/精确找色.js
Normal file
16
app/src/main/assets/sample/图片与图色处理/精确找色.js
Normal file
@@ -0,0 +1,16 @@
|
||||
if(!requestScreenCapture()){
|
||||
toast("请求截图失败");
|
||||
stop();
|
||||
}
|
||||
var img = captureScreen();
|
||||
toastLog("开始找色");
|
||||
//0x006699为编辑器蓝色字体(var)的颜色
|
||||
//找到颜色与0x006699完全相等的颜色
|
||||
var point = findColorEquals(img, 0x006699);
|
||||
if(point){
|
||||
toastLog("x = " + point.x + ", y = " + point.y);
|
||||
}else{
|
||||
toastLog("没有找到");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user