屏幕#

介绍#

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. 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.

以下是可用块的列表:

Print – Display text and values on the Brain.

Settings – Configure screen display properties.

Draw – Create shapes and graphics on the Brain screen.

打印#

打印#

The print block displays text on the Brain’s screen at the current cursor position and font.

在屏幕上打印 [VEXcode]▶

参数

描述

价值

要显示的文本、数字或变量值。

扩大箭头

展开块来读取并将光标设置到下一行,并使光标移动到该块之后的下一行。

例子

当开始 :: hat events
[Display a message at the starting cursor position.]
在屏幕上打印 [Hello, Robot!]◀ 并设定光标为下一行

VEX IQ 机器人的俯视图,位于一个蓝色圆形图中,图中显示了基本方向。机器人面朝上(0°)。该图指示机器人向右旋转 90°,向下旋转 180°,向左旋转 270°。该机器人由橙色和灰色组件组成,前面板上可见“VEX3”字样。机器人两侧均可见轮子。

将光标设置到行列#

使用“将光标置于行列”积木块时,光标会放置在 Brain 屏幕上的特定行和列上。实际可容纳的行数和列数取决于所选的字体。

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

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

参数

描述

游标所在行。

柱子

光标所在的列。

例子

当开始 :: hat events
[Repeatedly print the current timer at Row 1 Column 1]
永久循环
在屏幕上打印 (计时器秒数)◀ 并设定光标为下一行
等待 (1) 秒
清屏
在屏幕上设定光标至 (1) 行 (1) 列

替代文本

将光标设置到下一行#

The set cursor to next row block moves the cursor to column 1 on the next row on the Brain’s screen.

在屏幕上设定光标至下一行

例子

当开始 :: hat events
[Display two lines of text.]
在屏幕上打印 [Line 1]▶
在屏幕上设定光标至下一行
在屏幕上打印 [Line 2]◀ 并设定光标为下一行

替代文本

清除行#

清除行块用于清除 Brain 屏幕上的一行。

清除屏幕第 (1) 行

参数

描述

要清除的行号。

例子

当开始 :: hat events
[Display text on two rows, but only keep one.]
在屏幕上打印 [This text stays]◀ 并设定光标为下一行
在屏幕上打印 [This disappears]◀ 并设定光标为下一行
等待 (3) 秒
清除屏幕第 (2) 行

cursor column#

The cursor column block returns the column number where text will be printed as an integer.

cursor column reporter block#
(光标列数)

例子

When started, moves the cursor to row 3, column 2 on the screen and prints the current cursor column number.#
当开始 :: hat events
[Display the cursor's current column.]
在屏幕上设定光标至 [3] 行 [2] 列
在屏幕上打印 (光标列数)▶

cursor row#

The cursor row block returns the row number where text will be printed as an integer.

cursor row reporter block#
(光标行数)

例子

When started, moves the cursor to row 6, column 2 on the screen and prints the current cursor row number.#
当开始 :: hat events
[Display the cursor's current row.]
在屏幕上设定光标至 [3] 行 [2] 列
在屏幕上打印 (光标行数)▶

Settings#

clear screen#

The clear screen block clears all text from the Brain’s screen.

清屏

例子

当开始 :: hat events
[Fill the screen, then clear it after 2 seconds.]
重复 (5)
在屏幕上打印 [Line]◀ 并设定光标为下一行
结束
等待 (3) 秒
清屏

设置字体#

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

设定屏幕字体为 [等宽字体 v] [中 v]

参数

描述

字体

The font to use:

  • monospaced
  • proportional

size

The size to use:

  • extra small
  • small
  • medium
  • large
  • extra large
  • super large

标题为 MONO 12 的屏幕显示完整的数字和字母线,其中音符有 26 个,行数为 9。
Mono Extra Small

标有 MONO 15 的屏幕显示两行字符,表示横跨 20 个字符,共 7 行。
Mono Small

标题为 MONO 20 的屏幕显示数字和大写字母,后面跟着 16 个横排和 5 行。
Mono Medium

标有 MONO 30 的屏幕显示两行数字,后跟 3 行文本。
Mono Large

标题为 MONO 40 的屏幕以等宽字体显示下方的数字 12345678。
Mono Extra Large

屏幕在黑色背景上以大号白色字体显示 MN60。
单色超大

标题为 PROP 20 的屏幕显示多行数字和大写字母,后面跟着 26 个数字和 5 行。
Prop Medium

标有 PROP 30 的屏幕显示一行数字及其下方的等式 18 x 3。
Prop Large

屏幕上显示 PROP 40,其下方有一行 14 x 2,背景为黑色,白色文字。
Prop Extra Large

屏幕上以黑色背景大白字显示 PROP 60,没有其他内容。
Prop Super Large

例子

当开始 :: hat events
[Display two different fonts on separate lines.]
设定屏幕字体为 [等宽字体 v] [中 v]
在屏幕上打印 [Mono Medium]◀ 并设定光标为下一行
设定屏幕字体为 [比例字体 v] [中 v]
在屏幕上打印 [Prop Medium]◀ 并设定光标为下一行

替代文本

设置打印精度#

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

在屏幕上设定打印精度为 [0.1 v]

参数

描述

精确

将打印精度设置为:

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

例子

当开始 :: hat events
[Print 1/3 as 0.33.]
在屏幕上设定打印精度为 [0.01 v]
在屏幕上打印 ([1] / [3])◀ 并设定光标为下一行

替代文本

设置笔宽#

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

设定屏幕笔宽为 [10]

参数

描述

宽度

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

例子

当开始 :: hat events
[Draw two circles with different pen widths.]
在屏幕 (40) (70) (20) 上画圆形
设定屏幕笔宽为 (5)
在屏幕 (100) (70) (20) 上画圆形

替代文本

设置笔颜色#

The set pen color block sets the pen color used for drawing lines, shapes, and text on the Brain’s screen.

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

参数

描述

颜色

将笔颜色设置为:

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

例子

当开始 :: hat events
[Draw two rectangles with different colors.]
在屏幕 (100) (50) (10) (20) 上画矩形
设定屏幕笔/字体颜色为 [蓝色 v]
在屏幕 (50) (50) (10) (20) 上画矩形

替代文本

设置填充颜色#

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

设定屏幕填充色为 [红色 v]

参数

描述

颜色

将填充颜色设置为:

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

例子

当开始 :: hat events
[Draw a yellow circle.]
设定屏幕填充色为 [yellow v]
在屏幕 (50) (50) (20) 上画圆形

替代文本

#

绘制像素#

The draw pixel block draws a pixel at the specified (x, y) screen coordinate in the current pen color.

在屏幕 [0] [0] 上画点

参数

描述

x

绘制像素的 x 坐标。

y

绘制像素的 y 坐标。

例子

当开始 :: hat events
[Draw one pixel at the center of the screen.]
在屏幕 (80) (50) 上画点

替代文本

画线#

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] [159] [107] 上画线段

参数

描述

x1

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

y1

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

x2

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

y2

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

例子

当开始 :: hat events
[Draw a line from the top left to bottom right of the screen.]
在屏幕 (0) (0) (159) (107) 上画线段

替代文本

绘制矩形#

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

在屏幕 [0] [0] [10] [10] 上画矩形

参数

描述

x

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

y

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

宽度

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

高度

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

例子

当开始 :: hat events
[Draw a rectangle on the screen.]
在屏幕 (25) (25) (100) (50) 上画矩形

替代文本

画圆#

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

在屏幕 [0] [0] [10] 上画圆形

参数

描述

x

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

y

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

半径

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

例子

当开始 :: hat events
[Draw a circle on the screen.]
在屏幕 (80) (50) (20) 上画圆形

替代文本