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.

1  
sclass CheckerBoard implements MakesBufferedImage {
2  
  int w = 256, h = 256;
3  
  double cols = 8, rows = 8;
4  
  RGB color1 = RGB(Color.black), color2 = RGB(Color.white);
5  
  
6  
  public int getWidth() { ret w; }
7  
  public int getHeight() { ret h; }
8  
  
9  
  public BufferedImage getBufferedImage() {
10  
    ret toBufferedImage(rgbImageFromFunction(w, h, (x, y) -> {
11  
      double col = doubleRatio(x, w)*cols/2;
12  
      double row = doubleRatio(y, h)*rows/2;
13  
      double xlow = frac(col), ylow = frac(row);
14  
      ret xlow < .5 == ylow < .5 ? color1 : color2;
15  
    }));
16  
  }
17  
}

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: 168 / 315
Version history: 4 change(s)
Referenced in: [show references]