Draw Flush
A processor's command buffer is not endless: 256 at a time, and everything above that is lost in silence
drawflush is exactly printflush for pictures: it hands the display everything draw has
piled up, and clears the buffer in any case — wrong block, demolished block, not a display
at all, it makes no difference.
No more than 256 commands at a time
Section titled “No more than 256 commands at a time”The program draws a 16 by 16 grid — exactly 256 cells, filling the display. Press “run” and look at the top right corner: two cells are missing.
The buffer has 256 slots too, but two of them are already taken: clear and color are
commands like any other. So 254 cells are drawn, and the variable commands shows exactly that
many slots reaching the display.
Count all the commands, not just the shapes: clear, color, stroke and the transforms take
slots just like them — in the example above it is exactly they that cost us two cells. And
a caption takes as many slots as it has characters —
one command per letter.
You do not have to hand it all out at once
Section titled “You do not have to hand it all out at once”The buffer is cleared after every drawflush, so a picture is easy to split:
draw clear 20 20 30# …the first two hundred commands…drawflush display1# …the next two hundred…drawflush display1A display remembers what was drawn, so the second batch lands on top of the first rather than instead of it. The one thing this cannot do is show everything at once: time passes between the two hand-offs, and on a fast-moving picture that shows.
Several displays
Section titled “Several displays”The buffer has no address: there is one per processor, and until drawflush nobody knows who
it will be handed to. So with two displays the order is: draw for the first, hand to the first,
draw for the second, hand to the second.
Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.