Libraryless. Click here for Pure Java version (4870L/32K).
!7 sclass LockMatrix > DynModule { transient int n; transient BitSet data; transient JComponent canvas; visualize { canvas = dynamicallyPaintedComponent(voidfunc(Graphics2D g, int w, int h) { int rows = ifloor(sqrt(n)); if (rows == 0) fillRect(g, 0, 0, w, h, Color.white); int cols = (n+rows-1)/rows; L<Rect> tiles = tileRects(w, h, cols, rows); _print("n=" + n + ", rows=" + rows + ", first tile=" + first(tiles)); for i over tiles: fillRect(g, tiles.get(i), main.contains(data, i) ? Color.red : Color.black); }); awtEvery(canvas, 1000, r updateMe); ret canvas; } void update { new BitSet bs; L l = dm_listModules(); for i over l: if (isLocked((Lock) getOpt(l.get(i), 'lock))) { print("Locked: " + l.get(i)); bs.set(i); } setFields(n := l(l), data := bs); repaint(canvas); } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016660 |
Snippet name: | Lock Matrix [shows which modules are currently locked] |
Eternal ID of this version: | #1016660/19 |
Text MD5: | 93a41a3802a73eff03814b0bff65f2d7 |
Transpilation MD5: | 3374b3fd4533fb82dbf3ba450cd45fdf |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-11 17:30:12 |
Source code size: | 938 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 382 / 546 |
Version history: | 18 change(s) |
Referenced in: | -