屏幕#

介绍#

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 blocks:

Cursor Print — Manage text display using a row-and-column cursor system.

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 used for drawing and printing.

Settings — Customize text formatting and screen display.

Draw — Create graphics and visual elements.

Touch — Detect screen interactions.

光标打印#

打印#

print 块在机器人屏幕上的当前 光标位置字体 显示文本。

打印堆栈块#
在屏幕上打印 [VEXcode]▶

参数

描述

价值

要在屏幕上显示的文本、数字或变量值。

扩大箭头

Expand the block to read and set cursor to next row to make the cursor move to the next row after this block.

例子

启动时,在屏幕的起始光标位置显示消息“你好,机器人!”。#
当开始
[Display a message at the starting cursor position.]
在屏幕上打印 [Hello, Robot!]▶

A screenshot of the robot's screen, with "Hello, Robot!" printed in white across the top.

将光标设置到行列#

使用“将光标置于行列”块时,光标会置于屏幕上特定的行和列。实际可容纳的行数和列数取决于所选字体。使用默认的等宽中等字体,最多可清晰显示 8 行 13 列。超出此范围的文本可能会被截断或难以阅读。

等宽字体的字符宽度相同,使文本位置保持一致。相比之下,比例字体的字符宽度各不相同,因此某些字母比其他字母占用更多空间。但是,无论使用哪种类型,将光标设置为行列块都会根据行和列的大小(而不是字体样式)来定位光标。可以使用 设置字体 调整字体大小。

设置游标堆栈块#
在屏幕上设定光标至 [1] 行 [1] 列

参数

描述

游标所在行。

柱子

光标所在的列。

示例

启动时,将光标移动到屏幕上的第 3 行、第 2 列,并打印“第 3 行、第 2 列”。#
当开始
[Display text starting at Row 3 Column 2.]
在屏幕上设定光标至 (3) 行 (2) 列
在屏幕上打印 [Row 3, Column 2]▶

A screenshot of the robot's screen, with Row 3, Column 2 printed in white just above the center of the screen, beginning at row 3 column 2.

当开始
[Display cargo amounts in an organized list.]
设定屏幕字体为 [比例字体 v] [大 v]
在屏幕上打印 [Sports Balls]◀ 并设定光标为下一行
在屏幕上打印 [Orange Barrels]◀ 并设定光标为下一行
在屏幕上打印 [Blue Barrels]▶
在屏幕上设定光标至 [1] 行 [11] 列
在屏幕上打印 [2]▶
在屏幕上设定光标至 [2] 行 [11] 列
在屏幕上打印 [3]▶
在屏幕上设定光标至 [3] 行 [11] 列
在屏幕上打印 [3]▶

A screenshot of the robot's screen shows three lines of white text, listing Sports Balls 2, Orange Barrels 3, and Blue Barrels 3. The numbers are aligned to the right of each label, and the list begins at the top of the screen.

当开始
[Display the ID of the detected AprilTag.]
设定屏幕字体为 [比例字体 v] [特大 v]
永久循环
清屏
在屏幕上打印 [AprilTag]▶
从 AI 视觉仪获取 [所有AprilTags v] 数据
如果 <AI 视觉仪对象存在?> 那么
在屏幕上设定光标至 [3] 行 [4] 列
在屏幕上打印 (AI 视觉仪对象 [tagID v])▶
结束
等待 [0.1] 秒

A screenshot of the robot's screen with white text printed near the center, reading AprilTag on the first line and 4 on the second line.

将光标设置到下一行#

将光标设置到下一行块将光标移动到机器人屏幕下一行的第 1 列。

将光标设置到下一行堆栈块#
在屏幕上设定光标至下一行

参数

描述

该块没有参数。

例子

启动时,在屏幕上打印“第 1 行”,将光标移动到下一行,然后打印“第 2 行”。#
当开始
[Display two lines of text.]
在屏幕上打印 [Line 1]▶
在屏幕上设定光标至下一行
在屏幕上打印 [Line 2]▶

A screenshot of the robot's screen with white text. The screen reads Line 1 on the top line, left-justified, and Line 2 directly beneath.

清除行#

清除行块清除机器人屏幕上的一行文本。

清除行堆栈块#
清除屏幕第 [1] 行

参数

描述

要清除的行号。

例子

启动后,打印两行文本。第一行保留,第二行在 3 秒后消失。#
当开始
[Display text on two rows.]
在屏幕上打印 [This text stays]▶
在屏幕上设定光标至下一行
在屏幕上打印 [This text disappears]▶
等待 [3] 秒
清除屏幕第 [2] 行

屏幕光标列#

屏幕光标列块返回将以整数形式打印文本的列号。

屏幕光标列报告块#
(屏幕光标列数)

参数

描述

该块没有参数。

例子

启动时,将光标移动到屏幕上的第 3 行、第 2 列,并打印当前光标列号。#
当开始
[Display the cursor's current column.]
在屏幕上设定光标至 [3] 行 [2] 列
在屏幕上打印 (屏幕光标列数)▶

A screenshot of the robot's screen, with a white 2 printed near the center of the upper left quadrant, at row 3 column 2.

屏幕光标行#

屏幕光标行块返回将以整数形式打印文本的行号。

屏幕光标行报告块#
(屏幕光标行数)

参数

描述

该块没有参数。

例子

启动后,将光标移动到屏幕上的第 6 行、第 2 列,并打印当前光标行号。#
当开始
[Display the cursor's current row.]
在屏幕上设定光标至 [3] 行 [2] 列
在屏幕上打印 (屏幕光标行数)▶

A screenshot of the robot's screen, with a white 3 printed near the center of the upper left quadrant, at row 3 column 2.

XY打印#

设置屏幕原点#

设置屏幕原点 设置在机器人屏幕上绘图或打印时使用的原点 (0,0)。默认情况下,绘图或打印块将屏幕左上角视为原点。此块可以将原点重置为另一个 (x, y) 屏幕坐标位置。

设置屏幕原点堆栈块#
设置屏幕原点 x: [0] y: [0]

参数

描述

设置新原点的 x 坐标(以像素为单位)。

设置新原点的 y 坐标(以像素为单位)。

例子

启动时,将屏幕原点设置为 (120, 120),并在新原点处绘制一个矩形,其左上角位于 (0,0)、宽度为 80 像素,高度为 40 像素。#
当开始
[Set the origin to the center of the screen.]
设置屏幕原点 x: [120] y: [120]
[Draw a rectangle at the new origin.]
在屏幕 [0] [0] [80] [40] 上画矩形

A screenshot of the robot’s screen with a white rectangle drawn in the lower left quadrant. The upper left corner of the rectangle is the center of the screen.

设置#

清除屏幕#

清除屏幕块清除机器人屏幕上的所有图形和文本,并将光标位置重置为第 1 行、第 1 列。

清除屏幕块#
清屏

参数

描述

该块没有参数。

例子

启动后,以 (120,120) 为圆心,半径为 40 像素绘制一个圆。2 秒后,屏幕清空。#
当开始
[Draw a circle, and clear it after 2 seconds.]
在屏幕 [120] [120] [40] 上画圆形
等待 [2] 秒
清屏

填满屏幕#

填充屏幕块清除机器人屏幕上的所有图形和文本,然后将背景更改为指定的颜色。

填充屏幕块#
屏幕填充色为 [红色 v]

参数

描述

颜色

将背景颜色更改为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色

例子

当开始
[Say "Hello" then turn screen yellow.]
在屏幕上打印 [Hello]▶
等待 [2] 秒
屏幕填充色为 [yellow v]

设置字体#

设置字体 模块用于设置机器人屏幕上显示文本的字体和大小。此字体将应用于所有后续打印的文本。

设置字体堆栈块#
设定屏幕字体为 [等宽字体 v] [超小 v]

参数

描述

类型

字体类型:

  • 等宽
  • 比例

尺寸

字体大小(如下所示):

  • 超小
  • 特小
  • 特大
  • 超大

A screenshot of the robot's screen showing a sampling of numbers and letters printed in Mono 12 font. The alphabet spans 1 row of text. The bottom reads 26 characters across and 15 rows.
monospaced super small

The same image as the one previous, with Mono 15 font. The letters A-T span 1 row of text. The bottom reads 20 characters across and 12 rows.
monospaced extra small

The same image as the one previous, with Mono 20 font. The letters A-P span 1 row of text. The bottom reads 16 characters across and 9 rows.
monospaced small

The same image as the one previous, with Mono 24 font. The letters A-M span 1 row of text. The bottom reads 13 characters across and 8 rows.
monospaced medium

Same image as the one previous, with Mono 30 font. The letters A-K span 1 row of text. The bottom reads 11 characters across and 6 rows.
monospaced large

Same image as the one previous, with Mono 40 font. The letters A-H span 1 row of text. The bottom reads 8 characters across and 5 rows.
monospaced extra large

Same image as the one previous, with Mono 60 font. The numbers 1-6 span 1 row of text. The bottom reads 3 rows.
monospaced super large

Same image as the one previous, with  Prop 20 font. The letters A-s span 1 row of text. The bottom reads 20 characters across and 9 rows.
proportional small

Same image as the one previous, with Prop 30 font. The letters A-M span 1 row of text. The bottom reads 15 characters across and 6 rows.
proportional large

Same image as the one previous, with Prop 40 font. The letters A-J span 1 row of text. The bottom reads 11 characters across and 5 rows.
proportional extra large

A screenshot of the robot's screen showing a sampling of numbers printed in Prop 60 font. The numbers 1-7 span 1 row of text. The bottom reads 7 by 3.
proportional super large

例子

启动时,将字体设置为“等宽超大”并在屏幕上打印“VEX”。#
当开始
[Display text using a larger font]
设定屏幕字体为 [等宽字体 v] [特大 v]
在屏幕上打印 [VEX]▶

A screenshot of the robot’s screen shows the word VEX in Mono 40 font printed in white in the upper left corner.

set print precision on screen#

The set print precision on screen block sets the precision formatting used for displaying numbers on the robot’s screen. This print precision will apply to all subsequently printed numbers.

设置打印精度堆栈块#
在屏幕上设定打印精度为 [0.1 v]

参数

描述

精确

将打印精度设置为:

  • 1
  • 0.1
  • 0.01
  • 0.001
  • 所有数字

例子

启动时,将打印精度设置为小数点后两位,并在屏幕上将 1/3 打印为 0.33。#
当开始
[Print 1/3 as 0.33.]
在屏幕上设定打印精度为 [0.01 v]
在屏幕上打印 ([1] [math_division v] [3])▶

A screenshot of the robot’s screen reads 0.33 in white in the upper left corner.

设置笔宽#

设置笔宽块设置用于绘制线条和形状的笔宽。

设置笔宽块#
设定屏幕笔宽为 [10]

参数

描述

宽度

笔的宽度(以像素为单位),范围从 0 到 32。

例子

启动时,将笔宽设置为10像素,并绘制一个矩形,其左上角位于(50,50),宽度为130像素,高度为60像素。#
当开始
[Draw a rectangle with a pen width of 10.]
设定屏幕笔宽为 [10]
在屏幕 [50] [50] [130] [60] 上画矩形

A screenshot of the robot's screen with a thick white rectangle drawn across the upper half.

设置画笔/字体颜色#

设置笔/字体颜色块设置用于在机器人屏幕上绘制线条、形状和文本的笔颜色。

设置钢笔字体颜色#
设定屏幕笔/字体颜色为 [红色 v]

参数

描述

颜色

将笔颜色设置为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色
  • 透明

例子

启动时,将画笔颜色设置为红色,并绘制一个矩形,左上角位于(50,50),宽度为130像素,高度为60像素。#
当开始
[Draw a rectangle with a red pen.]
设定屏幕笔/字体颜色为 [红色 v]
在屏幕 [50] [50] [130] [60] 上画矩形

A screenshot of the robot’s screen with a red rectangle with a thin border drawn across the upper half.

设置填充颜色#

设置填充颜色块设置绘制形状时使用的填充颜色。

设置填充颜色堆栈块#
设定屏幕填充色为 [红色 v]

参数

描述

颜色

将填充颜色设置为:

  • 红色
  • 绿色
  • 蓝色
  • 黑色
  • 白色
  • 黄色
  • 橙色
  • 紫色
  • 青色
  • 透明

示例

启动后,将填充颜色设置为橙色,并绘制两个矩形。第一个矩形位于 (50, 50),第二个矩形位于 (50, 130),宽度均为 100 像素,高度均为 60 像素。#
当开始
[Draw two orange rectangles.]
设定屏幕填充色为 [orange v]
在屏幕 [50] [50] [100] [60] 上画矩形
在屏幕 [50] [130] [100] [60] 上画矩形

A screenshot of the robot’s screen with two parallel orange rectangles with thin, white outlines positioned to the left center of the screen.


启动时,将背景填充颜色设置为紫色并在屏幕上打印“高亮”。#
当开始
[Display text with a purple background.]
设定屏幕填充色为 [purple v]
在屏幕上打印 [Highlight]▶

A screenshot of the robot’s screen reads Highlight in white text with a purple highlight around it, beginning in the upper left corner.

#

显示图像文件#

显示图像文件块在机器人的屏幕上绘制自定义的用户上传图像。

显示用户图像堆栈块#
显示图像文件 [1 v]

参数

描述

图像槽号

要使用的自定义图像,编号 1 到 10。图像编号与 AIM 控制面板中显示的数字一致。

例子

待办事项#
当开始
[Draw uploaded Image 1.]
显示图像文件 [1 v]

绘制像素#

绘制像素 块在当前 画笔颜色 中在指定的 (x, y) 屏幕坐标处绘制一个像素。

绘制像素堆栈块#
在屏幕 [0] [0] 上画点

参数

描述

绘制像素的 x 坐标。

绘制像素的 y 坐标。

例子

启动时,在屏幕中心坐标 (120, 120) 处绘制一个像素。#
当开始
[Draw a pixel at the center of the screen.]
在屏幕 [120] [120] 上画点

A screenshot of the robot’s screen with a single white pixel in the center.

画线#

画线 块使用当前 笔宽笔颜色 从第一个指定的屏幕坐标 (x1, y1) 到第二个指定的屏幕坐标 (x2, y2) 绘制一条线。

画线堆叠块#
在屏幕 [0] [0] [10] [10] 上画线段

参数

描述

x1

线起点的 x 坐标(以像素为单位)。

y1

线起点的 y 坐标(以像素为单位)。

x2

线末端的 x 坐标(以像素为单位)。

y2

线末端的 y 坐标(以像素为单位)。

例子

启动时,从屏幕左上角(0,0)到右下角(240,240)绘制一条对角线。#
当开始
[Draw a line from the top left to bottom right of the screen.]
在屏幕 [0] [0] [240] [240] 上画线段

A screenshot of the robot’s screen with a thin white diagonal line drawn from the upper left corner to the lower right corner.

绘制矩形#

绘制矩形块使用当前的 画笔宽度画笔颜色填充颜色 绘制一个矩形。

绘制矩形块#
在屏幕 [0] [0] [10] [10] 上画矩形

参数

描述

矩形左上角的 x 坐标(以像素为单位)。

矩形左上角的 y 坐标(以像素为单位)。

宽度

矩形的宽度(以像素为单位)。

高度

矩形的高度(以像素为单位)。

例子

启动时,在屏幕上绘制一个矩形,左上角位于(50,50),宽度为 130 像素,高度为 60 像素。#
当开始
[Draw a rectangle on the screen.]
在屏幕 [50] [50] [130] [60] 上画矩形

A screenshot of the robot’s screen with a white rectangle drawn across the upper half.

画圆#

The draw circle block draws a circle using the current pen width, pen color, and fill colors.

画圆堆叠块#
在屏幕 [0] [0] [10] 上画圆形

参数

描述

圆心的 x 坐标(以像素为单位)。

圆心的 y 坐标(以像素为单位)。

半径

圆的半径(以像素为单位)。

例子

启动时,在屏幕上绘制一个圆心为(120,120)、半径为40像素的圆圈。#
当开始
[Draw a circle on the screen.]
在屏幕 [120] [120] [40] 上画圆形

A screenshot of the robot’s screen white a white circle drawn in the center.

触碰#

屏幕被按下?#

屏幕是否被按下? 模块返回机器人的屏幕当前是否被按下。该模块返回一个布尔值:

  • True — Screen is currently being pressed

  • False — Screen is not being pressed

屏幕按下布尔块#
<屏幕按下了?>

参数

描述

该块没有参数。

例子

启动后,持续检测屏幕是否被按下。如果被按下,所有 LED 灯亮起白色;否则,所有 LED 灯保持熄灭。#
当开始
[Turn LEDs white only when the screen is pressed.]
永久循环
如果 <屏幕按下了?> 那么
设定 [lightall v] LED 颜色为 [white v]
否则
设定 [lightall v] LED 颜色为 [灭 v]
结束
结束

屏幕位置#

屏幕位置 块返回一个整数,表示按下屏幕时的 x 和 y 坐标(以像素为单位)。x 的返回值介于 0(左)和 240(右)之间。y 的返回值介于 0(上)和 240(下)之间。

A top down view of the top of the VEX AIM Coding Robot showing the bounding box of the screen as a white rectangle. Clockwise, starting in the upper left corner, coordinates (0,0), (240,0), (0,240), and (240,240) show the four corners. A red circle is centered within the square, showing the viewable area, with a white dashed crosshair intersecting at (120, 120) in the center of the screen.

屏幕位置报告块#
(屏幕 [X v] 坐标)

参数

描述

协调

The coordinate of the last screen press in pixels:

  • x — The horizontal position
  • y — The vertical position

例子

启动后,持续检测屏幕是否按下。如果按下,则清除屏幕并打印触摸位置的 x 和 y 坐标。#
当开始
[Display the x and y coordinate of where the screen is pressed.]
永久循环
如果 <屏幕按下了?> 那么
清屏
在屏幕上打印 (屏幕 [X v] 坐标)▶
在屏幕上设定光标至下一行
在屏幕上打印 (屏幕 [y v] 坐标)▶
结束
结束

当屏幕事件#

当机器人的屏幕被按下或不再被按下时,将调用当屏幕事件块。

当屏幕事件帽子块#
当屏幕 [pressed v]

参数

描述

行动

Determines when the attached stack of blocks will execute:

  • pressed
  • released

例子

按下屏幕时,所有 LED 均变为绿色。#
当屏幕 [pressed v]
[Set the LEDs to green when the screen is pressed.]
设定 [lightall v] LED 颜色为 [绿色 v]