Uses 9620K of libraries. Click here for Pure Java version (4853L/32K/107K).
!752 static BWImage bw; static Thread producer; static Reproducing rp; !include #1004556 // class Reproducing static int luaMaxSteps = 1000*1000; p { rp = new Reproducing; rendererMaker = func(S s) { if (startsWith(s, "lua ")) ret luaRenderer(dropPrefix("lua ", s)); null; // fallback to default (unstructure) }; bw = rp.bw = loadBWImage("#1004576"); rp.imageSurfaceToUpdateWithBest = showImage(bw.getBufferedImage()); rp.startProduction = r { produce() }; // Note: This doesn't terminate as it keeps looking for better // solutions. It does write the shortest100.txt file in the mean // time which is your real output. rp.findShortest100_openEnd(); } static void produce() { cancelThread(producer); producer = new Thread(r { // STRATEGY! rp.push(fullGrab(bw)); int w = 1; while licensed { rp.push(new RandomSolid().reproduce(bw)); S best = rp.bestDesc(); if (best != null) rp.push(varyFloat(best)); if (w < bw.getWidth()) rp.push(hrepeat(bw, w++)); } }, "Producer"); producer.start(); } static Renderer luaRenderer(final S code) { ret new Renderer { public BWImage render(int w, int h) { BWImage img = new BWImage(w, h); Sandbox sandbox = makeSandbox(img); luaMaxSteps(luaMaxSteps); quickLua(sandbox, code); ret img; } }; } static Sandbox makeSandbox(final BWImage img) { Sandbox s = luaSandbox(); s.setOuter("w", Lua.value(img.getWidth())); s.setOuter("h", Lua.value(img.getHeight())); s.setInner("set", new ThreeArgFunction() { public LuaValue call(LuaValue x, LuaValue y, LuaValue theByte) { img.setByte(x.toint(), y.toint(), (byte) theByte.toint()); ret Lua.NIL; } }); ret s; }
Began life as a copy of #1004557
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004577 |
Snippet name: | Image Compressor ("go-basics.txt") |
Eternal ID of this version: | #1004577/1 |
Text MD5: | 52e96ccf0e6f668a991471c4f09a8f88 |
Transpilation MD5: | 6af80c5a175a38e89d49da100eedd67f |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-22 16:30:01 |
Source code size: | 1862 bytes / 75 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 572 / 641 |
Referenced in: | [show references] |