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