屏幕#
介绍#
VEX AIM 编程机器人的屏幕提供了用于显示文本、管理光标、绘制形状和处理触摸交互的模块。以下是所有可用模块的列表,按功能分组:
光标打印 - 使用行列光标系统管理文本显示。
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 at – Displays text at a specified x and y coordinate.
set screen origin – Changes the origin (0, 0) used for drawing and printing.
设置 - 自定义文本格式和屏幕显示。
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.
绘制——创建图形和视觉元素。
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.
触摸——检测屏幕交互。
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.
光标打印#
打印#
The print block displays text on the robot’s screen at the current cursor position and font.
打印 [VEX代码] 在屏幕 ▶
参数 |
描述 |
---|---|
价值 |
要在屏幕上显示的文本、数字或变量值。 |
扩大箭头 |
Expand the block to read and set cursor to next row and make the cursor move to the next row after this block. |
例子
当开始 :: hat events
[在起始光标位置显示一条消息.]
打印 [你好,机器人!] 在屏幕 ▶
将光标设置到行列#
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.
在屏幕上设定光标至 [1] 行 [1] 列
参数 |
描述 |
---|---|
排 |
游标所在行。 |
柱子 |
光标所在的列。 |
示例
当开始 :: hat events
[从第 3 行第 2 列开始显示文本.]
在屏幕上设定光标至 (3) 行 (2) 列
打印 [第 3 行,第 2 列] 在屏幕 ▶
当开始 :: hat events
[以有序列表的形式显示货物数量.]
设定屏幕字体为 [比例 v] [大 v]
打印 [运动球] 在屏幕 ◀ 并设定光标至下一行
打印 [橙色桶] 在屏幕 ◀ 并设定光标至下一行
打印 [蓝桶] 在屏幕 ▶
在屏幕上设定光标至 [1] 行 [11] 列
打印 [2] 在屏幕 ▶
在屏幕上设定光标至 [2] 行 [1] 列
打印 [3] 在屏幕 ▶
在屏幕上设定光标至 [3] 行 [11] 列
打印 [3] 在屏幕 ▶
当开始 :: hat events
[显示检测到的 AprilTag 的 ID.]
设定屏幕字体为 [比例 v] [特大 v]
永久循环
清屏
打印 [四月标签] 在屏幕 ▶
获得 AI 视觉仪 [四月标签 v] 数据
如果 <AI 视觉仪对象存在?> 那么
在屏幕上设定光标至 [3] 行 [4] 列
打印 (AI 视觉仪对象 [标签ID v]) 在屏幕 ▶
结束
等待 [0.1] 秒
将光标设置到下一行#
将光标设置到下一行块将光标移动到机器人屏幕下一行的第 1 列。
在屏幕上设定光标至下一行
参数 |
描述 |
---|---|
该块没有参数。 |
例子
当开始 :: hat events
[显示两行文本.]
打印 [1 号线] 在屏幕 ▶
在屏幕上设定光标至下一行
打印 [2 号线] 在屏幕 ▶
清除行#
清除行块清除机器人屏幕上的一行文本。
清除屏幕第 [1] 行
参数 |
描述 |
---|---|
排 |
要清除的行号。 |
例子
当开始 :: hat events
[在两行上显示文本.]
打印 [此文本保留] 在屏幕 ▶
在屏幕上设定光标至下一行
打印 [此文本消失] 在屏幕 ▶
等待 [3] 秒
清除屏幕第 [2] 行
屏幕光标列#
屏幕光标列块返回将以整数形式打印文本的列号。
(屏幕光标列)
参数 |
描述 |
---|---|
该块没有参数。 |
例子
当开始 :: hat events
[显示光标的当前列.]
在屏幕上设定光标至 [3] 行 [2] 列
打印 (屏幕光标列) 在屏幕 ▶
屏幕光标行#
屏幕光标行块返回将以整数形式打印文本的行号。
(屏幕光标行)
参数 |
描述 |
---|---|
该块没有参数。 |
例子
当开始 :: hat events
[显示光标的当前行.]
在屏幕上设定光标至 [3] 行 [2] 列
打印 (屏幕光标行) 在屏幕 ▶
XY打印#
打印于#
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.
打印 [VEX代码] 至屏幕 [80] [120]
参数 |
描述 |
---|---|
价值 |
要在屏幕上显示的文本、数字或变量值。 |
十 |
x 坐标(以像素为单位)(0 到 240,其中 0 为左,240 为右)。 |
是 |
y 坐标(以像素为单位)(0 到 240,其中 0 为顶部,240 为底部)。 |
例子
当开始 :: hat events
[在屏幕中间显示一条消息.]
打印 [你好,机器人!] 至屏幕 [40] [120]
设置屏幕原点#
设置屏幕原点 设置在机器人屏幕上绘图或打印时使用的原点 (0,0)。默认情况下,绘图或打印块将屏幕左上角视为原点。此块可以将原点重置为另一个 (x, y) 屏幕坐标位置。
设置屏幕原点x: [0] y: [0]
参数 |
描述 |
---|---|
十 |
设置新原点的 x 坐标(以像素为单位)。 |
是 |
设置新原点的 y 坐标(以像素为单位)。 |
例子
当开始 :: hat events
[将原点设置为屏幕中心.]
设置屏幕原点x: [120] y: [120]
[在新原点处绘制一个矩形.]
屏幕 [0] [0] [80] [40] 画矩形
设置#
清除屏幕#
The clear screen block clears all drawings and text from the robot’s screen and resets the cursor position to row 1, column 1.
清屏
参数 |
描述 |
---|---|
该块没有参数。 |
例子
当开始 :: hat events
[画一个圆圈,2秒后清除.]
屏幕 [120] [120] [40] 画圆形
等待 [2] 秒
清屏
填满屏幕#
填充屏幕块清除机器人屏幕上的所有图形和文本,然后将背景更改为指定的颜色。
屏幕填充色为 [红色 v]
参数 |
描述 |
---|---|
颜色 |
The color to change the background to:
|
例子
当开始 :: hat events
[说 "你好" 然后屏幕变黄.]
打印 [你好] 在屏幕 ▶
等待 [2] 秒
屏幕填充色为 [黄色 v]
设置字体#
设置字体 模块用于设置机器人屏幕上显示文本的字体和大小。此字体将应用于所有后续打印的文本。
设定屏幕字体为 [等间距 v] [超小 v]
参数 |
描述 |
---|---|
类型 |
The font type:
|
尺寸 |
The font size (shown below):
|
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
例子
当开始 :: hat events
[使用较大的字体显示文本]
设定屏幕字体为 [等间距 v] [特大 v]
打印 [烦恼] 在屏幕 ▶
设置打印精度#
设置打印精度 模块用于设置机器人屏幕上显示数字的精度格式。此打印精度将应用于所有后续打印的数字。
在屏幕上设定打印精度为 [0.1 v]
参数 |
描述 |
---|---|
精确 |
Sets the print precision to:
|
例子
当开始 :: hat events
[将 1/3 打印为 0.33]
在屏幕上设定打印精度为 [0.01 v]
打印 ([1] [math_division v] [3]) 在屏幕 ▶
设置笔宽#
设置笔宽块设置用于绘制线条和形状的笔宽。
设定屏幕笔宽为 [10]
参数 |
描述 |
---|---|
宽度 |
笔的宽度(以像素为单位),范围从 0 到 32。 |
例子
当开始 :: hat events
[画一个笔宽为10的矩形.]
设定屏幕笔宽为 [10]
屏幕 [50] [130] [100] [60] 画矩形
设置画笔/字体颜色#
设置笔/字体颜色块设置用于在机器人屏幕上绘制线条、形状和文本的笔颜色。
设定屏幕笔/字体颜色为 [红色 v]
例子
参数 |
描述 |
---|---|
颜色 |
Sets the pen color to:
|
当开始 :: hat events
[用红笔画一个矩形.]
设定屏幕笔/字体颜色为 [红色 v]
屏幕 [50] [130] [100] [60] 画矩形
设置填充颜色#
设置填充颜色块设置绘制形状时使用的填充颜色。
设定屏幕填充色为 [红色 v]
参数 |
描述 |
---|---|
颜色 |
Sets the fill color to:
|
示例
当开始 :: hat events
[画两个橙色矩形.]
设定屏幕填充色为 [橙色 v]
屏幕 [50] [50] [100] [60] 画矩形
屏幕 [50] [130] [100] [60] 画矩形
当开始 :: hat events
[显示具有紫色背景的文本.]
设定屏幕填充色为 [紫色 v]
打印 [强调] 在屏幕 ▶
画#
显示图像文件#
显示图像文件块在机器人的屏幕上绘制自定义的用户上传图像。
显示图像文件 [1 v]
参数 |
描述 |
---|---|
图像槽号 |
要使用的自定义图像,编号 1 到 10。图像编号与 AIM 控制面板中显示的数字一致。 |
例子
当开始 :: hat events
[绘制已上传的图片 1.]
显示图像文件 [1 v]
绘制像素#
The draw pixel block draws a pixel at the specified (x, y) screen coordinate in the current pen color.
屏幕 [0] [0] 画点
参数 |
描述 |
---|---|
十 |
绘制像素的 x 坐标。 |
是 |
绘制像素的 y 坐标。 |
例子
当开始 :: hat events
[在屏幕中心绘制一个像素.]
屏幕 [120] [120] 画点
画线#
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.
屏幕 [0] [0] [10] [10] 画线段
参数 |
描述 |
---|---|
x1 |
线起点的 x 坐标(以像素为单位)。 |
y1 |
线起点的 y 坐标(以像素为单位)。 |
x2 |
线末端的 x 坐标(以像素为单位)。 |
y2 |
线末端的 y 坐标(以像素为单位)。 |
例子
当开始 :: hat events
[从屏幕左上角到右下角画一条线.]
屏幕 [0] [0] [240] [240] 画线段
绘制矩形#
The draw rectangle block draws a rectangle using the current pen width, pen color, and fill colors.
屏幕 [0] [0] [10] [10] 画矩形
例子
参数 |
描述 |
---|---|
十 |
矩形左上角的 x 坐标(以像素为单位)。 |
是 |
矩形左上角的 y 坐标(以像素为单位)。 |
宽度 |
矩形的宽度(以像素为单位)。 |
高度 |
矩形的高度(以像素为单位)。 |
当开始 :: hat events
[在屏幕上绘制一个矩形.]
屏幕 [50] [130] [100] [60] 画矩形
画圆#
The draw circle block draws a circle using the current pen width, pen color, and fill colors.
屏幕 [0] [0] [10] 画圆形
参数 |
描述 |
---|---|
十 |
圆心的 x 坐标(以像素为单位)。 |
是 |
圆心的 y 坐标(以像素为单位)。 |
半径 |
圆的半径(以像素为单位)。 |
例子
当开始 :: hat events
[在屏幕上绘制一个矩形.]
屏幕 [120] [120] [40] 画圆形
触碰#
屏幕被按下?#
屏幕是否被按下? 模块返回机器人的屏幕当前是否被按下。该模块返回一个布尔值:
True - Screen is currently being pressed
False - Screen is not being pressed
<屏幕按下了?>
参数 |
描述 |
---|---|
该块没有参数。 |
例子
当开始 :: hat events
[仅当按下屏幕时,LED 才会变为白色.]
永久循环
如果 <屏幕按下了?> 那么
将 [lightall v] LED颜色设置为 [白色 v]
否则
将 [lightall v] LED颜色设置为 [灭 v]
结束
结束
屏幕位置#
屏幕位置 块返回一个整数,表示按下屏幕时的 x 和 y 坐标(以像素为单位)。x 的返回值介于 0(左)和 240(右)之间。y 的返回值介于 0(上)和 240(下)之间。
(屏幕 [x v] 位置)
参数 |
描述 |
---|---|
协调 |
The coordinate of the last screen press in pixels:
|
例子
当开始 :: hat events
[显示按下屏幕的 x 和 y 坐标。]
永久循环
如果 <屏幕按下了?> 那么
清屏
打印 (屏幕 [x v] 位置) 在屏幕 ▶
在屏幕上设定光标至下一行
打印 (屏幕 [y v] 位置) 在屏幕 ▶
结束
结束
当屏幕事件#
当机器人的屏幕被按下或不再被按下时,将调用当屏幕事件块。
当屏幕 [按下 v] :: hat events
参数 |
描述 |
---|---|
行动 |
Determines when the attached stack of blocks will execute:
|
例子
当屏幕 [按下 v] :: hat events
[按下屏幕时将 LED 设置为绿色.]
将 [lightall v] LED颜色设置为 [绿色 v]