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

25
LINES

< > BotCompany Repo | #1024314 // RecognitionGrid - 3 colors per cell ("outer, middle, center") for visualizing stuff. probably not used anymore

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5034L/28K).

sclass RecognitionGrid {
  double cellW, cellH;
  int rows, cols;
  Cell[] cells;
  
  *() {}
  *(double *cellW, double *cellH, int w, int h) {
    rows = iceil(w/cellW);
    cols = iceil(h/cellH);
    cells = new Cell[rows*cols];
  }
  
  sclass Cell {
    int outerColor, middleColor, centerColor; // RGB + alpha
  }
  
  Cell getCell(int col, int row) {
    ret inRange(col, 0, cols) && inRange(row, 0, rows) ? cells[row*cols+col] : null;
  }
  
  Rect cellRect(int col, int row) {
    ret rectFromPoints(iround(col*cellW), iround(row*cellH),
      iround((col+1)*cellW), iround((row+1)*cellH));
  }
}

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: #1024314
Snippet name: RecognitionGrid - 3 colors per cell ("outer, middle, center") for visualizing stuff. probably not used anymore
Eternal ID of this version: #1024314/7
Text MD5: 31dba946756d32a9793963a4d5ec167b
Transpilation MD5: 572dfa132cbc0199deaad1bcc5884469
Author: stefan
Category: javax / image recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-15 17:23:28
Source code size: 628 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 197 / 621
Version history: 6 change(s)
Referenced in: [show references]