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

17
LINES

< > BotCompany Repo | #1032072 // CheckerBoard - creates an image, can't be moved

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

Transpiled version (10235L) is out of date.

sclass CheckerBoard implements MakesBufferedImage {
  int w = 256, h = 256;
  double cols = 8, rows = 8;
  RGB color1 = RGB(Color.black), color2 = RGB(Color.white);
  
  public int getWidth() { ret w; }
  public int getHeight() { ret h; }
  
  public BufferedImage getBufferedImage() {
    ret toBufferedImage(rgbImageFromFunction(w, h, (x, y) -> {
      double col = doubleRatio(x, w)*cols/2;
      double row = doubleRatio(y, h)*rows/2;
      double xlow = frac(col), ylow = frac(row);
      ret xlow < .5 == ylow < .5 ? color1 : color2;
    }));
  }
}

Author comment

Began life as a copy of #1032070

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032072
Snippet name: CheckerBoard - creates an image, can't be moved
Eternal ID of this version: #1032072/5
Text MD5: 313815fd456f1927b22ff0ee18460e76
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-20 20:28:36
Source code size: 570 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 314
Version history: 4 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)
#1035257 - CheckerBoard2 - G2Drawable, can move around