Screen#
Introduction#
The VEX AIM Coding Robot’s screen provides blocks for displaying text, managing the cursor, drawing shapes, and handling touch interactions. Below is a list of all available blocks, grouped by functionality:
Cursor Print - Manage text display using a row-and-column cursor system.
print – Displays text on the screen at the current cursor position.
set cursor to row column – Moves the cursor to a specific row and column.
set cursor to next row – Moves the cursor to column 1 of the next row.
clear row – Clears a specified row of text.
screen cursor column – Returns the column number where text will be printed.
screen cursor row – Returns the row number where text will be printed.
XY Print - Print text at pixel-based coordinates.
print at – Displays text at a specified x and y coordinate.
set screen origin – Changes the origin (0, 0) used for drawing and printing.
Settings - Customize text formatting and screen display.
clear screen – Erases all text and drawings from the screen.
fill screen – Erases all text and drawings from the screen, then sets the screen’s background color.
set font – Changes the font type and size for text display.
set print precision – Adjusts the amount of decimal places for printed numbers.
set pen width – Adjusts the thickness of drawn lines.
set pen / font color – Changes the color for text and drawings.
set fill color – Defines the fill color for shapes.
Draw - Create graphics and visual elements.
show image file – Displays a user-uploaded image on the screen.
draw pixel – Draws a single pixel at a specified coordinate.
draw line – Draws a line between two points.
draw rectangle – Draws a rectangle with specified dimensions.
draw circle – Draws a circle with a given radius.
Touch - Detect screen interactions.
screen pressed? – Returns whether the screen is currently being pressed.
screen position – Returns the x and y coordinates where the screen was last touched.
when screen event – Triggers when the screen is pressed or released.
Cursor Print#
print#
The print block displays text on the robot’s screen at the current cursor position and font.
print [VEXcode] on screen ▶
Parameters |
Description |
---|---|
value |
The text, number, or variable value to display on the screen. |
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 screen ▶
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 screen. How many rows and columns can comfortably fit depends on the selected font. With the default monospaced medium font, up to 8 rows and 13 columns can be displayed clearly. Text placed beyond this range may be cut off or become difficult to read.
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 screen
Parameters |
Description |
---|---|
row |
The row of the cursor. |
column |
The column of the cursor. |
Examples
when started :: hat events
[Display text starting at Row 3 Column 2.]
set cursor to row (3) column (2) on screen
print [Row 3, Column 2] on screen ▶
when started :: hat events
[Display cargo amounts in an organized list.]
set font to [proportional v] [large v] on screen
print [Sports Balls] on screen ◀ and set cursor to next row
print [Orange Barrels] on screen ◀ and set cursor to next row
print [Blue Barrels] on screen ▶
set cursor to row [1] column [11] on screen
print [2] on screen ▶
set cursor to row [2] column [11] on screen
print [3] on screen ▶
set cursor to row [3] column [11] on screen
print [3] on screen ▶
when started :: hat events
[Display the ID of the detected AprilTag.]
set font to [proportional v] [extra large v] on screen
forever
clear screen
print [AprilTag] on screen ▶
get [all AprilTags v] data from AI Vision
if <AI Vision object exists?> then
set cursor to row [3] column [4] on screen
print (AI Vision object [tagID v]) on screen ▶
end
wait [0.1] seconds
set cursor to next row#
The set cursor to next row block moves the cursor to column 1 on the next row on the robot’s screen.
set cursor to next row on screen
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display two lines of text.]
print [Line 1] on screen ▶
set cursor to next row on screen
print [Line 2] on screen ▶
clear row#
The clear row block clears a row of text on the robot’s screen.
clear row [1] on screen
Parameters |
Description |
---|---|
row |
The row number to clear. |
Example
when started :: hat events
[Display text on two rows.]
print [This text stays] on screen ▶
set cursor to next row on screen
print [This text disappears] on screen ▶
wait [3] seconds
clear row [2] on screen
screen cursor column#
The screen cursor column block returns the column number where text will be printed as an integer.
(screen cursor column)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the cursor's current column.]
set cursor to row [3] column [2] on screen
print (screen cursor column) on screen ▶
screen cursor row#
The screen cursor row block returns the row number where text will be printed as an integer.
(screen cursor row)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the cursor's current row.]
set cursor to row [3] column [2] on screen
print (screen cursor row) on screen ▶
XY Print#
print at#
The print at block displays text on the robot’s screen at a specified x and y-coordinate (in pixels) with the currently set font.
print [VEXcode] at x:[80] y:[120] on screen
Parameters |
Description |
---|---|
value |
The text, number, or variable value to display on the screen. |
x |
The x-coordinate in pixels (0 to 240, where 0 is left and 240 is right). |
y |
The y-coordinate in pixels (0 to 240, where 0 is top and 240 is bottom). |
Example
when started :: hat events
[Display a message in the middle of the screen.]
print [Hello, Robot!] at x:[40] y:[120] on screen
set screen origin#
The set screen origin sets the origin (0,0) used for drawing or printing on the robot’s screen. By default, drawing or printing blocks consider the top left corner of the screen as the origin. This block can reset the origin to an alternate (x, y) screen coordinate location.
set screen origin x: [0] y: [0]
Parameters |
Description |
---|---|
x |
The x-coordinate in pixels to set the new origin to. |
y |
The y-coordinate in pixels to set the new origin to. |
Example
when started :: hat events
[Set the origin to the center of the screen.]
set screen origin x: [120] y: [120]
[Draw a rectangle at the new origin.]
draw rectangle [0] [0] [80] [40] on screen
Settings#
clear screen#
The clear screen block clears all drawings and text from the robot’s screen and resets the cursor position to row 1, column 1.
clear screen
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Draw a circle, and clear it after 2 seconds.]
draw circle [120] [120] [40] on screen
wait [2] seconds
clear screen
fill screen#
The fill screen block clears the robot’s screen of all drawings and text, then changes the background to a specified color.
fill screen with [red v]
Parameters |
Description |
---|---|
color |
The color to change the background to:
|
Example
when started :: hat events
[Say "Hello" then turn screen yellow.]
print [Hello] on screen ▶
wait [2] seconds
fill screen with [yellow v]
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 [monospaced v] [super small v] on screen
Parameters |
Description |
---|---|
type |
The font type:
|
size |
The font size (shown below):
|
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
Example
when started :: hat events
[Display text using a larger font]
set font to [monospaced v] [extra large v] on screen
print [VEX] on screen ▶
set print precision#
The set print precision block sets the precision formatting used for displaying numbers on the robot’s screen. This print precision will apply to all subsequently printed numbers.
set print precision to [0.1 v] on screen
Parameters |
Description |
---|---|
precision |
Sets the print precision to:
|
Example
when started :: hat events
[Print 1/3 as 0.33.]
set print precision to [0.01 v] on screen
print ([1] [math_division v] [3]) on screen ▶
set pen width#
The set pen width block sets the pen width used for drawing lines and shapes.
set pen width to [10] on screen
Parameters |
Description |
---|---|
width |
The pen width in pixels in a range from 0 to 32. |
Example
when started :: hat events
[Draw a rectangle with a pen width of 10.]
set pen width to [10] on screen
draw rectangle [50] [50] [130] [60] on screen
set pen / font color#
The set pen / font color block sets the pen color used for drawing lines, shapes, and text on the robot’s screen.
set pen / font color to [red v] on screen
Parameters |
Description |
---|---|
color |
Sets the pen color to:
|
Example
when started :: hat events
[Draw a rectangle with a red pen.]
set pen / font color to [red v] on screen
draw rectangle [50] [50] [130] [60] on screen
set fill color#
The set fill color block sets the fill color used when shapes are drawn.
set fill color to [red v] on screen
Parameters |
Description |
---|---|
color |
Sets the fill color to:
|
Examples
when started :: hat events
[Draw two orange rectangles.]
set fill color to [orange v] on screen
draw rectangle [50] [50] [100] [60] on screen
draw rectangle [50] [130] [100] [60] on screen
when started :: hat events
[Display text with a purple background.]
set fill color to [purple v] on screen
print [Highlight] on screen ▶
Draw#
show image file#
The show image file block draws a custom user-uploaded image on the robot’s screen.
show image file [1 v]
Parameters |
Description |
---|---|
image slot number |
The custom image to use, number 1 to 10. The image number aligns with the number shown in the AIM control panel. |
Example
when started :: hat events
[Draw uploaded Image 1.]
show image file [1 v]
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 screen
Parameters |
Description |
---|---|
x |
The x-coordinate to draw the pixel. |
y |
The y-coordinate to draw the pixel. |
Example
when started :: hat events
[Draw a pixel at the center of the screen.]
draw pixel [120] [120] on screen
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] [10] [10] on screen
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] [240] [240] on screen
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 screen
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 [50] [50] [130] [60] on screen
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 screen
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 rectangle on the screen.]
draw circle [120] [120] [40] on screen
Touch#
screen pressed?#
The screen pressed? block returns if the robot’s screen is currently being pressed or not pressed. This block returns a Boolean value:
True - Screen is currently being pressed
False - Screen is not being pressed
<screen pressed?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Turn LEDs white only when the screen is pressed.]
forever
if <screen pressed?> then
set [lightall v] LED color to [white v]
else
set [lightall v] LED color to [off v]
end
end
screen position#
The screen position block returns an integer showing the x- and y-coordinate (in pixels) where the screen was pressed. The return value for x is between 0 (left) and 240 (right). The return value for y is between 0 (top) and 240 (bottom).
(screen [x v] position)
Parameters |
Description |
---|---|
coordinate |
The coordinate of the last screen press in pixels:
|
Example
when started :: hat events
[Display the x and y coordinate of where the screen is pressed.]
forever
if <screen pressed?> then
clear screen
print (screen [x v] position) on screen ▶
set cursor to next row on screen
print (screen [y v] position) on screen ▶
end
end
when screen event#
The when screen event block is to be called when the robot’s screen is pressed or is no longer being pressed.
when screen [pressed v] :: hat events
Parameters |
Description |
---|---|
action |
Determines when the attached stack of blocks will execute:
|
Example
when screen [pressed v] :: hat events
[Set the LEDs to green when the screen is pressed.]
set [lightall v] LED color to [green v]