Transpiled version (181L) is out of date.
1 | sclass DoubleRect { |
2 | double x, y, w, h; |
3 | |
4 | *() {} |
5 | *(Rectangle r) { |
6 | x = r.x; |
7 | y = r.y; |
8 | w = r.width; |
9 | h = r.height; |
10 | } |
11 | *(double *x, double *y, double *w, double *h) {} |
12 | |
13 | // Huh. not implementing equals()/hashCode? Stefan is mysterious |
14 | bool eq(O o) { |
15 | if (!o instanceof DoubleRect) false; |
16 | if (o == this) true; |
17 | DoubleRect r = cast o; |
18 | ret x == r.x && y == r.y && w == r.w && h == r.h; |
19 | } |
20 | |
21 | toString { |
22 | ret x + "," + y + " / " + w + "," + h; |
23 | } |
24 | |
25 | double x1() { ret x; } |
26 | double y1() { ret y; } |
27 | double x2() { ret x + w; } |
28 | double y2() { ret y + h; } |
29 | |
30 | bool contains(Pt p) { |
31 | ret contains(p.x, p.y); |
32 | } |
33 | |
34 | bool contains(double _x, double _y) { |
35 | ret _x >= x && _y >= y && _x < x+w && _y < y+h; |
36 | } |
37 | |
38 | bool empty() { ret w <= 0 || h <= 0; } |
39 | } |
Began life as a copy of #1005390
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009184 |
Snippet name: | class DoubleRect - floating point version of Rectangle |
Eternal ID of this version: | #1009184/4 |
Text MD5: | b85c19f028f023781273dc277c160fdb |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-10 17:01:48 |
Source code size: | 841 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 587 / 1218 |
Version history: | 3 change(s) |
Referenced in: | [show references] |