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

41
LINES

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

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

Libraryless. Click here for Pure Java version (4750L/26K).

1  
final srecord Rect(int x, int y, int w, int h) {
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  
  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  
  int x1() { ret x; }
21  
  int y1() { ret y; }
22  
  int x2() { ret x + w; }
23  
  int y2() { ret y + h; }
24  
  
25  
  bool contains(Pt p) {
26  
    ret contains(p.x, p.y);
27  
  }
28  
  
29  
  bool contains(int _x, int _y) {
30  
    ret _x >= x && _y >= y && _x < x+w && _y < y+h;
31  
  }
32  
  
33  
  bool contains(Rectangle r) {
34  
    ret rectContains(this, r);
35  
  }
36  
  
37  
  bool empty() { ret w <= 0 || h <= 0; }
38  
  
39  
  int getWidth() { ret w; }
40  
  int getHeight() { ret h; }
41  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 23 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, 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/7
Text MD5: c1e34928ae9bbbe6830270d2249664bc
Transpilation MD5: 4bccb9dba2e8165494e8113a4a09f82b
Author: stefan
Category: javax / concepts / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-09 17:39:39
Source code size: 846 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 550 / 8950
Version history: 6 change(s)
Referenced in: [show references]