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

11
LINES

< > BotCompany Repo | #1000540 // box (paints a box)

JavaX fragment (include)

  static void box(Img img, Box p) {
    int w = img.getWidth(), h = img.getHeight();
    double x1 = normalize(p.cx-p.w), x2 = normalize(p.cx+p.w);
    double y1 = normalize(p.cy-p.h), y2 = normalize(p.cy+p.h);
    int xx1 = round(x1*(w-1)), xx2 = round(x2*(w-1));
    int yy1 = round(y1*(h-1)), yy2 = round(y2*(h-1));
    
    for (int yy = yy1; yy <= yy2; yy++)
      for (int xx = xx1; xx <= xx2; xx++)
        img.setPixel(xx, yy, p.color);
  }
  

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: #1000540
Snippet name: box (paints a box)
Eternal ID of this version: #1000540/1
Text MD5: a5c67f2027086342e620621240b6d9de
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-11 01:38:46
Source code size: 464 bytes / 11 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 633 / 807
Referenced in: [show references]