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

25
LINES

< > BotCompany Repo | #1033853 // orBitMatrixWithItselfShifted

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

Libraryless. Click here for Pure Java version (5146L/29K).

svoid orBitMatrixWithItselfShifted(int dx, int dy, BitMatrix m) {
  if (dx == 0 && dy == 0);
  int w = m.getWidth(), h = m.getHeight();
  if (dx <= 0 && dy <= 0) {
    for (int y = -dy; y < h; y++)
      for (int x = -dx; x < h; x++)
        if (m.get(x, y))
          m.set(x+dx, y+dy, true);
  } else if (dx <= 0 && dy > 0) {
    for (int y = 0; y < h-y; y++)
      for (int x = -dx; x < h; x++)
        if (m.get(x, y))
          m.set(x+dx, y+dy, true);
  } else if (dx > 0 && dy <= 0) {
    for (int y = -dy; y < h; y++)
      for (int x = 0; x < h-dx; x++)
        if (m.get(x, y))
          m.set(x+dx, y+dy, true);
  } else if (dx > 0 && dy > 0) {
    for (int y = 0; y < h-dy; y++)
      for (int x = 0; x < h-dx; x++)
        if (m.get(x, y))
          m.set(x+dx, y+dy, true);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033853
Snippet name: orBitMatrixWithItselfShifted
Eternal ID of this version: #1033853/5
Text MD5: 9260f812c895c0caa88146d250e73073
Transpilation MD5: 60f087a6a5801ad4f1b2ccbeeefa2d11
Author: stefan
Category: javax / gazelle v
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-07 04:27:38
Source code size: 817 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 125 / 184
Version history: 4 change(s)
Referenced in: [show references]