Skip to content

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.

tick 0
Draw0
rgb
Draw1
rgb
a
Draw2
xy
widthheight
Draw Flush3
Stop4
@counter0number

Press “run”. An orange rectangle appears on a grey background — four lines, and each one does exactly one thing.

draw clear 40 40 50
draw color 255 180 60 255
draw rect 20 20 60 40
drawflush 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 40

That is a rectangle 60 wide and 40 tall whose bottom left corner sits at 20 20. Not the centre — the corner.

tick 0
Draw0
rgb
Draw1
rgb
a
Draw2
xy
widthheight
Stop3
@counter0number

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.

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.