Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1025283 // Find area on screen without change v1 [OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 974K of libraries. Click here for Pure Java version (4976L/27K).

!7

!include once #1025225 // Shared IntegralImage

cmodule FindConstantArea > DynImageSurface {
  switchable int displayWidth = 400, cubeSize = 40;
  transient Rect area; // area currently looked at
  transient RGB lastColor;
  
  start {
    dm_vmBus_onMessage_q newScreenshotInStream(voidfunc(O mod, virtual Screenshot ss) {
      IntegralImage ii = cast rget integralImage(ss);
      setImage(scaledBufferedImageFromIntegralImage(displayWidth, ii));
      if (area == null) area = randomRect(cubeSize, cubeSize, ii_rect(ii));
      print("Area: " + area);
      setSelection(scaleRect(area, doubleRatio(displayWidth, ii.getWidth())));
      RGB color = ii_averageColorOfArea(ii, area);
      if (lastColor != null) {
        if (eq(color, lastColor))
          print("Same color! " + color);
        else {
          print("New color (" + lastColor + "/" + color + "). Switching area.");
          area = null;
        }
      }
      lastColor = color;
    });
  }
}

Author comment

Began life as a copy of #1025278

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025283
Snippet name: Find area on screen without change v1 [OK]
Eternal ID of this version: #1025283/14
Text MD5: a955c261c7327b2b28967916ae1acab4
Transpilation MD5: e7f72ff0d62a70fb5e3b0a55cf806898
Author: stefan
Category: javax / screen recognition
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-20 18:09:33
Source code size: 999 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 205 / 373
Version history: 13 change(s)
Referenced in: [show references]