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

48
LINES

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

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

Libraryless. Click here for Pure Java version (9142L/51K).

1  
srecord Rect(int x, int y, int w, int h) is WidthAndHeight {
2  
  *(Rectangle r) {
3  
    x = r.x;
4  
    y = r.y;
5  
    w = r.width;
6  
    h = r.height;
7  
  }
8  
  
9  
  *(Pt p, int *w, int *h) { x = p.x; y = p.y; }
10  
  *(Rect r) { x = r.x; y = r.y; w = r.w; h = r.h; }
11  
  
12  
  final Rectangle getRectangle() {
13  
    ret new Rectangle(x, y, w, h);
14  
  }
15  
  
16  
  public S toString() {
17  
    ret x + "," + y + " / " + w + "," + h;
18  
  }
19  
  
20  
  final int x1() { ret x; }
21  
  final int y1() { ret y; }
22  
  final int x2() { ret x + w; }
23  
  final int y2() { ret y + h; }
24  
  
25  
  final bool contains(Pt p) {
26  
    ret contains(p.x, p.y);
27  
  }
28  
  
29  
  final bool contains(int _x, int _y) {
30  
    ret _x >= x && _y >= y && _x < x+w && _y < y+h;
31  
  }
32  
  
33  
  final bool contains(Rectangle r) {
34  
    ret rectContains(this, r);
35  
  }
36  
  
37  
  final bool empty() { ret w <= 0 || h <= 0; }
38  
  
39  
  final public int getWidth() { ret w; }
40  
  final public int getHeight() { ret h; }
41  
  
42  
  final public int area() { ret w*h; }
43  
  
44  
  final public int x() { ret x; }
45  
  final public int y() { ret y; }
46  
  
47  
  WidthAndHeight widthAndHeight() { ret main widthAndHeight(w, h); }
48  
}

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/14
Text MD5: edcde344afa0a5b5d90b6b651838d1d4
Transpilation MD5: d042cdfd7eda7eee2abefaaaac2ca2ef
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-15 20:15:28
Source code size: 1130 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 739 / 9473
Version history: 13 change(s)
Referenced in: [show references]