The first picture
Four lines and a rectangle appears on the display. Without the last of them nothing appears at all
A display is a separate block, and like a message block it has to be reached with a link.
The program draws not on it but in the processor’s buffer, and only drawflush carries
what has piled up onto the screen.
Press “run”. An orange rectangle appears on a grey background — four lines, and each one does exactly one thing.
Line by line
Section titled “Line by line”draw clear 40 40 50draw color 255 180 60 255draw rect 20 20 60 40drawflush display1| Line | What it does |
|---|---|
clear |
fills the whole display with a colour: three fields — red, green, blue |
color |
chooses the colour for whatever is drawn next; the fourth field is opacity |
rect |
fills a rectangle: corner x, y, then width and height |
drawflush |
hands what has piled up to the display |
The colour holds until the next color: it is not attached to a shape, it simply becomes the
current one. So two shapes of one colour are one color and two drawing commands.
Coordinates count from the bottom left corner
Section titled “Coordinates count from the bottom left corner”A large display’s side is 176 dots, so 0 0 is the bottom left corner and 175 175 the top
right. The Y axis grows upwards.
draw rect 20 20 60 40That is a rectangle 60 wide and 40 tall whose bottom left corner sits at 20 20. Not the
centre — the corner.
Without drawflush nothing appears
Section titled “Without drawflush nothing appears”The same program without the last line. Press “run” — the display stays dark, although all three commands run perfectly well: they sit in the processor’s buffer waiting to be sent.
The picture stays until it is wiped
Section titled “The picture stays until it is wiped”A display remembers what was drawn. It has no notion of a “frame”: draw nothing new and the
old stays. So a program drawing a moving arrow starts its iteration with clear — otherwise
the previous arrows stay where they were.
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.