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

34
LINES

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

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

Libraryless. Click here for Pure Java version (212L/2K).

final srecord Rect(int x, int y, int w, int h) {
  *(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; }
  
  Rectangle getRectangle() {
    ret new Rectangle(x, y, w, h);
  }
  
  public S toString() {
    ret x + "," + y + " / " + w + "," + h;
  }
  
  int x1() { ret x; }
  int y1() { ret y; }
  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  old transpilations   

Travelled to 22 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, lulzaavyztxj, 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/5
Text MD5: b29c77a48f8057d453e2a589089fe941
Transpilation MD5: 7c6de61c8ea500c035dfcc357c7e99f4
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-20 08:15:10
Source code size: 710 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 493 / 8805
Version history: 4 change(s)
Referenced in: [show references]

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