diff --git a/app/build.gradle b/app/build.gradle index cda32968..fe08cb3a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.stardust.scriptdroid" minSdkVersion 17 targetSdkVersion 23 - versionCode 244 - versionName "3.0.0 Alpha44" + versionCode 245 + versionName "3.0.0 Alpha45" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true ndk { diff --git a/app/src/main/assets/docs/images.html b/app/src/main/assets/docs/images.html index 21735e25..5b36f480 100644 --- a/app/src/main/assets/docs/images.html +++ b/app/src/main/assets/docs/images.html @@ -84,6 +84,7 @@
  • images.findColor(image, color, options)
  • images.findColorInRegion(img, color, x, y[, width, height, threshold])
  • images.findColorEquals(img, color[, x, y, width, height])
  • +
  • images.findMultiColors(img, firstColor, colors[, options])
  • images.detectsColor(image, color, x, y[, threshold = 16, algorithm = "diff"])
  • images.findImage(img, template[, options])
  • images.findImageInRegion(img, template, x, y[, width, height, threshold])
  • @@ -210,7 +211,7 @@ images.save(clip, "/sdcard/clip.png");

    选项包括:

    该函数也可以作为全局函数使用。

    一个循环找色的例子如下:

    @@ -274,6 +275,28 @@ if(p){ }else{ toast("没有未读消息"); } +

    images.findMultiColors(img, firstColor, colors[, options])#

    +
    +

    多点找色,类似于按键精灵的多点找色,其过程如下:

    +
      +
    1. 在图片img中找到颜色firstColor的位置(x0, y0)
    2. +
    3. 对于数组colors的每个元素[x, y, color],检查图片img在位置(x + x0, y + y0)上的像素是否是颜色color,是的话返回(x0, y0),否则继续寻找firstColor的位置,重新执行第1步
    4. +
    5. 整张图片都找不到时返回null
    6. +
    +

    例如,对于代码images.findMultiColors(img, "#123456", [[10, 20, "#ffffff"], [30, 40, "#000000"]]),假设图片在(100, 200)的位置的颜色为#123456, 这时如果(110, 220)的位置的颜色为#fffff且(130, 240)的位置的颜色为#000000,则函数返回点(100, 200)。

    +

    如果要指定找色区域,则在options中指定,例如:

    +
    var p = images.findMultiColors(img, "#123456", [[10, 20, "#ffffff"], [30, 40, "#000000"]], {
    +    region: [0, 960, 1080, 960]
    +});
     

    images.detectsColor(image, color, x, y[, threshold = 16, algorithm = "diff"])#