Screen#
Introduction#
The Screen category includes blocks that allow your VEX IQ (2nd generation) robot to display text, values, and graphics on the Brain’s built-in screen or the Print Console. These blocks can be used to print sensor data, create custom interfaces, or draw visual elements like lines, shapes, and text with adjustable styles and colors.
Below is a list of available blocks:
Print – Display text and values on the Brain or Console screen.
print – Prints a value or text to the selected screen.
set cursor – Sets the row and column location for printing.
next row – Moves the cursor to the next row.
set print precision – Sets how many decimal places to show.
clear all rows – Clears the entire screen.
clear row – Clears a specific row.
Drawing – Create shapes and graphics on the Brain screen.
draw pixel – Draws a single pixel at a coordinate.
draw line – Draws a line between two points.
draw rectangle – Draws a rectangle.
draw circle – Draws a circle.
set font – Sets the font style and size for printed text.
set pen width – Sets the line thickness for drawings.
set pen to color – Sets the color used for outlines and text.
set fill color – Sets the fill color for drawn shapes.
Print#
print#
The print block displays text on the Brain’s screen or Console at the current cursor position and font.
print [VEXcode] on [Brain v] ▶
Parameters |
Description |
---|---|
value |
The text, number, or variable value to display. |
device |
The device to display the text on:
|
expanding arrow |
Expand the block to read and set cursor to next row and make the cursor move to the next row after this block. |
Example
when started :: hat events
[Display a message at the starting cursor position.]
print [Hello, Robot!] on [Brain v] ◀ and set cursor to next row
set cursor to row column#
When using the set cursor to row column block, the cursor is placed at a specific row and column on the Brain’s screen. How many rows and columns can comfortably fit depends on the selected font.
Monospaced fonts have characters that are all the same width, making text placement consistent. In contrast, proportional fonts vary in character width, so some letters take up more space than others. However, regardless of which type is used, the set cursor to row column block positions the cursor based on row and column size, not font style. The font size can be adjusted using the set font block.
set cursor to row [1] column [1] on [Brain v]
Parameters |
Description |
---|---|
row |
The row of the cursor. |
column |
The column of the cursor. |
Example
when started :: hat events
[Repeatedly print the current timer at Row 1 Column 1]
forever
print (timer in seconds) on [Brain v] ◀ and set cursor to next row
wait (1) seconds
clear all rows on [Brain v]
set cursor to row (1) column (1) on [Brain v]
set cursor to next row#
The set cursor to next row block moves the cursor to column 1 on the next row on the Brain’s screen or Console.
set cursor to next row on [Brain v]
Parameters |
Description |
---|---|
device |
The device to display the text on:
|
Example
when started :: hat events
[Display two lines of text.]
print [Line 1] on [Brain v] ▶
set cursor to next row on [Brain v]
print [Line 2] on [Brain v] ◀ and set cursor to next row
set print precision#
The set print precision block sets the precision formatting used for displaying numbers on the Brain’s screen or Console. This print precision will apply to all subsequently printed numbers.
set print precision to [0.1 v] on [Brain v]
Parameters |
Description |
---|---|
precision |
Sets the print precision to:
|
device |
The device to display the text on:
|
Example
when started :: hat events
[Print 1/3 as 0.33.]
set print precision to [0.01 v] on [Brain v]
print ([1] / [3]) on [Brain v] ◀ and set cursor to next row
clear all rows#
The clear all rows block clears all text from the Brain’s screen or Console.
clear all rows on [Brain v]
Parameters |
Description |
---|---|
device |
The device to display the text on:
|
Example
when started :: hat events
[Fill the screen, then clear it after 2 seconds.]
repeat (5)
print [Line] on [Brain v] ◀ and set cursor to next row
end
wait (3) seconds
clear all rows on [Brain v]
clear row#
The clear row block is used to clear a single row on the Brain’s screen.
clear row (1) on [Brain v]
Parameters |
Description |
---|---|
row |
The row number to clear. |
device |
The device to clear a row on:
|
Example
when started :: hat events
[Display text on two rows, but only keep one.]
print [This text stays] on [Brain v] ◀ and set cursor to next row
print [This disappears] on [Brain v] ◀ and set cursor to next row
wait (3) seconds
clear row (2) on [Brain v]
Draw#
draw pixel#
The draw pixel block draws a pixel at the specified (x, y) screen coordinate in the current pen color.
draw pixel [0] [0] on Brain
Parameters |
Description |
---|---|
x |
The x-coordinate to draw the pixel. |
y |
The y-coordinate to draw the pixel. |
Example
when started :: hat events
[Draw one pixel at the center of the screen.]
draw pixel (80) (50) on Brain
draw line#
The draw line block draws a line from the first specified screen coordinate (x1, y1) to the second specified screen coordinate (x2, y2) using the current pen width and pen color.
draw line [0] [0] [159] [107] on Brain
Parameters |
Description |
---|---|
x1 |
The x-coordinate in pixels of the start of the line. |
y1 |
The y-coordinate in pixels of the start of the line. |
x2 |
The x-coordinate in pixels of the end of the line. |
y2 |
The y-coordinate in pixels of the end of the line. |
Example
when started :: hat events
[Draw a line from the top left to bottom right of the screen.]
draw line (0) (0) (159) (107) on Brain
draw rectangle#
The draw rectangle block draws a rectangle using the current pen width, pen color, and fill colors.
draw rectangle [0] [0] [10] [10] on Brain
Parameters |
Description |
---|---|
x |
The x-coordinate in pixels of the top-left corner of the rectangle. |
y |
The y-coordinate in pixels of the top-left corner of the rectangle. |
width |
The width of the rectangle in pixels. |
height |
The height of the rectangle in pixels. |
Example
when started :: hat events
[Draw a rectangle on the screen.]
draw rectangle (25) (25) (100) (50) on Brain
draw circle#
The draw circle block draws a circle using the current pen width, pen color, and fill colors.
draw circle [0] [0] [10] on Brain
Parameters |
Description |
---|---|
x |
The x-coordinate in pixels of the center of the circle. |
y |
The y-coordinate in pixels of the center of the circle. |
radius |
The radius of the circle in pixels. |
Example
when started :: hat events
[Draw a circle on the screen.]
draw circle (80) (50) (20) on Brain
set font#
The set font block sets the font and size used for displaying text on the robot’s screen. This font will apply to all subsequently printed text.
set font to [Mono Medium v] on Brain
Parameters |
Description |
---|---|
font |
The font to use:
|
|
|
|
---|---|---|
|
|
|
|
|
|
|
Example
when started :: hat events
[Display two different fonts on separate lines.]
set font to [Mono Medium v] on Brain
print [Mono Medium] on [Brain v] ◀ and set cursor to next row
set font to [Prop Medium v] on Brain
print [Prop Medium] on [Brain v] ◀ and set cursor to next row
set pen width#
The set pen width block sets the pen width used for drawing lines and shapes.
set pen width to [10] on Brain
Parameters |
Description |
---|---|
width |
The pen width in pixels in a range from 0 to 32. |
Example
when started :: hat events
[Draw two circles with different pen widths.]
draw circle (40) (70) (20) on Brain
set pen width to (5) on Brain
draw circle (100) (70) (20) on Brain
set pen color#
The set pen color block sets the pen color used for drawing lines, shapes, and text on the Brain’s screen and Console.
set pen color to [red v] on [Brain v]
Parameters |
Description |
---|---|
color |
Sets the pen color to:
|
device |
The device to set the color on:
|
Example
when started :: hat events
[Draw two rectangles with different colors.]
draw rectangle (100) (50) (10) (20) on Brain
set pen color to [blue v] on [Brain v]
draw rectangle (50) (50) (10) (20) on Brain
set fill color#
The set fill color block sets the fill color used when shapes are drawn.
set fill color to [red v] on Brain
Parameters |
Description |
---|---|
color |
Sets the fill color to:
|
Example
when started :: hat events
[Draw a yellow circle.]
set fill color to [yellow v] on Brain
draw circle (50) (50) (20) on Brain