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

43
LINES

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

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

Libraryless. Click here for Pure Java version (7975L/45K).

srecord Rect(int x, int y, int w, int h) is WidthAndHeight {
  *(Rectangle r) {
    x = r.x;
    y = r.y;
    w = r.width;
    h = r.height;
  }
  
  *(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; }
  
  final Rectangle getRectangle() {
    ret new Rectangle(x, y, w, h);
  }
  
  public S toString() {
    ret x + "," + y + " / " + w + "," + h;
  }
  
  final int x1() { ret x; }
  final int y1() { ret y; }
  final int x2() { ret x + w; }
  final int y2() { ret y + h; }
  
  final bool contains(Pt p) {
    ret contains(p.x, p.y);
  }
  
  final bool contains(int _x, int _y) {
    ret _x >= x && _y >= y && _x < x+w && _y < y+h;
  }
  
  final bool contains(Rectangle r) {
    ret rectContains(this, r);
  }
  
  final bool empty() { ret w <= 0 || h <= 0; }
  
  final public int getWidth() { ret w; }
  final public int getHeight() { ret h; }
  
  final public int area() { ret w*h; }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 24 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, lulzaavyztxj, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv, xrpafgyirdlv

No comments. add comment

Snippet ID: #1005390
Snippet name: class Rect - persistable version of Rectangle
Eternal ID of this version: #1005390/11
Text MD5: e31b5554df7a0e4a008813e545a4c9af
Transpilation MD5: 3df73390795200bc389c695855e6b2d9
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-10 19:57:55
Source code size: 982 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 606 / 9232
Version history: 10 change(s)
Referenced in: [show references]