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

37
LINES

< > BotCompany Repo | #1005390 - class Rect - persistable version of Rectangle

JavaX fragment (include)

sclass Rect {
  int x, y, w, h;
  
  *() {}
  *(Rectangle r) {
    x = r.x;
    y = r.y;
    w = r.width;
    h = r.height;
  }
  *(int *x, int *y, int *w, int *h) {}
  *(Pt p, int *w, int *h) { x = p.x; y = p.y; }
  *(Rect r) { x = r.x; y = r.y; w = r.w; h = r.h; }
  
  Rectangle getRectangle() {
    ret new Rectangle(x, y, w, h);
  }
  
  [stdEq]
  
  public S toString() {
    ret x + "," + y + " / " + w + "," + h;
  }
  
  int x2() { ret x + w; }
  int y2() { ret y + h; }
  
  bool contains(Pt p) {
    ret contains(p.x, p.y);
  }
  
  bool contains(int _x, int _y) {
    ret _x >= x && _y >= y && _x < x+w && _y < y+h;
  }
  
  bool empty() { ret w <= 0 || h <= 0; }
}

download  show line numbers  debug dex   

Travelled to 18 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, lulzaavyztxj, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, sawdedvomwva, tslmcundralx, tvejysmllsmz, wtqryiryparv, xrpafgyirdlv

No comments. add comment

Snippet ID: #1005390
Snippet name: class Rect - persistable version of Rectangle
Eternal ID of this version: #1005390/3
Text MD5: a8d3108683ad32861835c7b25033931a
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-27 22:04:23
Source code size: 713 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 385 / 8484
Version history: 2 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1005390 & http://1005390.tinybrain.de