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

12
LINES

< > BotCompany Repo | #1026933 // bwImageFromFunction

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

Libraryless. Click here for Pure Java version (7902L/45K).

// f should return a value between 0 and 1 (will be clamped for you)
static BWImage bwImageFromFunction(int w, int h default w, IF2_IntInt_Double f) {
  BWImage img = new(w, h);
  for y to h:
    for x to w:
      img.setPixel(x, y, (float) f.get(x, y));
  ret img;
}

static BWImage bwImageFromFunction(int w, int h default w, IF0<Double> f) {
  ret bwImageFromFunction(w, (x, y) -> f!);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026933
Snippet name: bwImageFromFunction
Eternal ID of this version: #1026933/7
Text MD5: 79db4da0ece03f30ffa766519c42f116
Transpilation MD5: 8fcc3e0dd4321fe4ccb93bbe21a0072f
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-22 19:16:25
Source code size: 401 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 281 / 416
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1032071 - rgbImageFromFunction
#1035491 - image2BFromFunction
#1035848 - floatBWImageFromFunction