Transpiled version (2763L) is out of date.
// start from center static ItIt<Pt> pixelSpiral(int w, int h) { ret pixelSpiral(w/2, h/2, w, h); } // thanks to https://stackoverflow.com/questions/398299/looping-in-a-spiral static ItIt<Pt> pixelSpiral(int sx, int sy, int imageWidth, int imageHeight, int maxPixels default Int.MAX_VALUE) { ret iff_endOnNull(new F0<Pt> { int x, y, dx, dy = -1; int maxPixels2 = min(maxPixels, sqr(max4(sx+1, imageWidth-sx, sy+1, imageHeight-sy)*2)); int i; Pt get() { while (i++ < maxPixels2) { int px = sx+x, py = sy+y; if (x == y || x < 0 && x == -y || x > 0 && x == 1-y) { int t=dx; dx=-dy; dy=t; } x += dx; y += dy; if (px >= 0 && py >= 0 && px < imageWidth && py < imageHeight) ret pt(px, py); } null; } }); }
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: | #1025244 |
Snippet name: | pixelSpiral |
Eternal ID of this version: | #1025244/10 |
Text MD5: | 08a02ee11e9c109ad0ad0c955c0a5e6d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-16 17:39:10 |
Source code size: | 867 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 257 / 421 |
Version history: | 9 change(s) |
Referenced in: | [show references] |