Draw
draw is built like print: it does not draw, it appends a command to the processor’s
buffer. The picture appears when the buffer is handed to a display — that is
drawflush’s job.
One instruction, and sixteen different commands behind it: fill the background, choose a colour, run a line, place a polygon, write text, move the origin. Their fields are shared and mean different things from command to command — hence one topic per lesson.
What we draw on
Section titled “What we draw on”| Block | Picture side | Space on the map |
|---|---|---|
| logic display | 80 dots | 3×3 |
| large logic display | 176 dots | 6×6 |
A display’s dot is neither a map tile nor a screen pixel: the picture has a grid of its own,
and its size is better asked of the block (sensor @displayWidth) than written as a number.
The origin is the bottom left corner, and the Y axis goes up. Not like a browser and not like the map editor, but like the game itself.
Lessons
Section titled “Lessons”- The first pictureFour lines and a rectangle appears on the display. Without the last of them nothing appears at all
- Shapes and linesThere are six shapes, and each asks for its own numbers: a corner here, a centre there, a radius elsewhere
- Colour and transparencyColour is a state, not a property of a shape: choose it once and it holds until the next time
- Text and picturesText reaches a display from the same buffer that feeds a message block — but not every letter survives the trip
- Translate, rotate, scaleEasier than recomputing every point: move the grid itself and draw in it as if for the first time
What you need first
Section titled “What you need first”«The text buffer» — the same “pile up, then hand out” trick is built on it, and you need it to write anything on a display.
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.