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

26
LINES

< > BotCompany Repo | #1014949 // BoxWithColor

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

Libraryless. Click here for Pure Java version (3362L/20K).

1  
sclass BoxWithColor implements RenderableWithHints {
2  
  Pt a, b;
3  
  RGB color;
4  
  
5  
  *() {}
6  
  *(Pt *a, Pt *b, RGB *color) {}
7  
  *(Rect r, Color color) {
8  
    a = pt(r.x, r.y); b = pt(r.x2(), r.y2());
9  
    this.color = RGB(color);
10  
  }
11  
  *(Rect rect, int r, int g, int b) {
12  
    this(rect, new Color(r, g, b));
13  
  }
14  
  
15  
  public void renderOn(Graphics2D g, int w, int h) {
16  
    int x1 = min(a.x, b.x), y1 = min(a.y, b.y);
17  
    int x2 = max(a.x, b.x), y2 = max(a.y, b.y);
18  
    fillRect(g, x1, y1, x2-x1+1, y2-y1+1, toColor(color));
19  
  }
20  
  
21  
  public void renderHints(Graphics2D g, int w, int h) {
22  
    int x1 = min(a.x, b.x), y1 = min(a.y, b.y);
23  
    int x2 = max(a.x, b.x), y2 = max(a.y, b.y);
24  
    drawRect(g, x1, y1, x2-x1+1, y2-y1+1, hintColor());
25  
  }
26  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014949
Snippet name: BoxWithColor
Eternal ID of this version: #1014949/7
Text MD5: 9b70a076f1591c263d6400678f77f63f
Transpilation MD5: d2f02644f6c3cb3e1118efd4996a020d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-07 18:12:15
Source code size: 764 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 345 / 944
Version history: 6 change(s)
Referenced in: [show references]