屏幕#

介绍#

The Screen blocks control the VEX AIR Drone Controller’s screen, allowing your controller to show text, numbers, graphics, and images, and respond to touch input.

**注意:**如果 VEX AIR 无人机已与控制器配对,则打印屏幕顶部将显示一个计时器,指示当前项目的已用时间。任何文本或绘图都将显示在计时器后面。

Below is a list of available blocks:

Cursor Print - Display text and manage the print cursor.

XY 打印 - 在基于像素的坐标处打印文本。

Settings - Change the appearance of text, graphics, and screen display.

绘制——创建图形和视觉元素。

触摸 - 检测屏幕交互。

光标打印#

将光标设置到屏幕上的行列#

The set cursor to row column on screen stack block moves the cursor to a specific row and column on the controller screen. The next print on screen block will start printing at that location.

The number of characters that can fit on the screen depends on the selected font. With the default monospaced medium font, up to 18 rows and 53 columns can be displayed clearly. Text placed beyond this range may be cut off or become difficult to read.

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

参数

描述

The row to move the cursor to.

柱子

The column to move the cursor to.

示例

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

VEX AIR 无人机控制器屏幕的截图,屏幕中心附近有白色文字,显示“第 7 行,第 25 列”。

将光标移至屏幕上的下一行#

The set cursor to next row on screen stack block moves the cursor to column 1 on the next row on the controller screen.

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

参数

描述

该块没有参数。

例子

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

VEX AIR 无人机控制器屏幕的截图,左上角有白色文字,第一行显示“第 1 行”,第二行紧随其后。

屏幕上的清除行#

The clear row on screen stack block clears a row of text on the controller screen.

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

参数

描述

要清除的行号。

例子

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

屏幕光标列#

The screen cursor column reporter block reports the column number where text will be printed as an integer.

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

参数

描述

该块没有参数。

例子

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

VEX AIR 无人机控制器屏幕的截图,屏幕中心附近有白色文字“25”,位于第 7 行第 25 列。

屏幕光标行#

The screen cursor row reporter block reports the row number where text will be printed as an integer.

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

参数

描述

该块没有参数。

例子

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

VEX AIR 无人机控制器屏幕的截图,屏幕中心附近有白色文字显示“7”,位于第 7 行第 25 列。

XY打印#

设置屏幕原点#

The set screen origin stack block sets the origin (0, 0) used for drawing and coordinate-based printing on the controller screen. By default, the origin is the top-left corner of the screen. This block can reset the origin to an alternate (x, y) screen coordinate location.

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

参数

描述

x

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

y

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

例子

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

VEX AIR 无人机控制器屏幕的截图,绘制了一个白色矩形,使左上角位于屏幕中心。

设置#

清除屏幕#

The clear screen stack block clears all drawings, text, and images from the controller screen.

clear screen stack block#
清屏

参数

描述

该块没有参数。

例子

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

等待屏幕渲染#

The wait for screen to render stack block switches screen drawing to render-later behavior. Once this block runs, following screen blocks will not appear on the controller screen until the next wait for screen to render block runs.

Note: Use this block before drawing a group of text, shapes, or images, then use it again to render the full update at once.

等待屏幕渲染

参数

描述

该块没有参数。

例子

启动时,绘制一个以 (120,120) 为圆心、半径为 40 像素的圆。2 秒后,屏幕清空。#
当开始
[Display text and images when button 7 is pressed.]
等待屏幕渲染
在屏幕上打印 [Screen rendered!]▶
在屏幕 [320] [240] [80] 上画圆形
等到 <遥控器按键 [7 v] 按下了?>
等待屏幕渲染

VEX AIR 无人机控制器屏幕的截图,左上角有白色文字“屏幕渲染完成!”,屏幕中央画有一个白色圆圈。

填满屏幕#

The fill screen stack block clears all drawings, text, and images from the controller screen, then changes the background to a specified color.

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

参数

描述

颜色

The color to change the background to:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan

例子

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

VEX AIR 无人机控制器屏幕的截图,屏幕上所有可打印区域都填充了亮绿色。

设置屏幕上的字体#

The set font on screen stack block sets the font and size used for displaying text on the controller screen. This font will apply to all text printed after this block runs.

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

参数

描述

类型

The font type: monospaced or proportional.

尺寸

The font size (shown below):

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

VEX AIR 无人机控制器屏幕截图,左上角以 Mono 12 字体打印了一系列白色字母和数字。字母 AZ 位于一行,占据屏幕宽度的大约三分之一。左下角显示“91 个字符,30 行”。
等宽超小号

与上一张图片相同,现在使用 Mono 15 字体。字母 AZ 位于一行,占据屏幕近一半的宽度。左下角显示
71 个字符,23 行/_static/img/fonts/MONO15-hornet.png。

与上一张图片相同,现在使用 Mono 20 字体。字母 AZ 位于一行,占据屏幕宽度的一半。左下角显示“53 个字符,
行/_static/img/fonts/MONO20-hornet.png。

与上一张图片相同,现在使用 Mono 24 字体。字母 AZ 位于一行,占据屏幕宽度的一半多一点。左下角显示“45/_static/img/fonts/MONO24-hornet.png字符,
行”。

与上一张图片相同,现在使用 Mono 30 字体。字母 AZ 位于一行,占据屏幕宽度/_static/img/fonts/MONO30-hornet.png大约四分之三。左下角显示“35 个字符,
行”。

与上一张图片相同,现在使用 Mono 40 字体。字母 AZ 位于一行,横跨屏幕宽度。左下角显示“26 个字符,
行/_static/img/fonts/MONO40-hornet.png。

与上一张图片相同,现在使用 Mono 60 字体。字母 AQ 位于一行,横跨屏幕宽度。左下角显示 17/_static/img/fonts/MONO60-hornet.png字符,
行。

与上一张图片相同,现在使用 Prop 20 字体。字母 AZ 位于一行,占据屏幕宽度的一半多一点。左下角显示为 49 个字符,18 行。
proportional small

与上一张图片相同,现在使用 Prop 24 字体。字母 AZ 位于一行,占据屏幕宽度的约三分之二。左下角显示 42 个字符,15 行。
proportional medium

与上一张图片相同,现在使用 Prop 30 字体。字母 AZ 位于一行,占据屏幕宽度的四分之三。左下角显示“33 个字符,12 行”。
proportional large

与上一张图片相同,现在使用 Prop 40 字体。字母 AY 位于一行,横跨屏幕宽度。左下角显示“24 个字符,9 行”。
proportional extra large

与上一张图片相同,现在使用 Prop 60 字体。字母 AQ 位于一行,横跨屏幕宽度。左下角显示 17 个字符,6 行。
proportional super large

例子

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

与之前的图片相同,现在左上角有白色文字,内容为 VEX is Mono 40 字体。

设置屏幕打印精度#

The set print precision on screen stack block sets how many decimal places are shown when numbers are printed on the controller screen. This print precision will apply to all numbers printed after this block runs.

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

参数

描述

精确

Sets the print precision to:

  • 1
  • 0.1
  • 0.01
  • 0.001
  • All Digits

例子

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

VEX AIR 无人机控制器屏幕的截图,左上角有白色文字显示 0.33。

设置屏幕上的笔宽#

The set pen width on screen stack block sets the thickness of drawn lines and shape outlines.

set pen width stack block#
设定屏幕笔宽为 [10]

参数

描述

宽度

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

例子

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

VEX AIR 无人机控制器屏幕的截图,中间印有一个带粗边框的白色矩形。

设置屏幕上的笔/字体颜色#

The set pen / font color on screen stack block sets the color of text, pixels, lines, and shape outlines. The default color is white.

set pen / font color stack block#
设定屏幕笔/字体颜色为 [红色 v]

例子

参数

描述

颜色

The pen and font color to use:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan
  • transparent

启动时,将画笔颜色设置为红色,并绘制一个矩形,左上角位于 (50, 50),宽度为 130 像素,高度为 60 像素。#
当开始
[Draw a rectangle with an orange outline.]
设定屏幕笔/字体颜色为 [orange v]
在屏幕 [200] [150] [240] [150] 上画矩形
设定屏幕笔/字体颜色为 [white v]
print [VEXcode AIR] at x: [250] y: [220] on screen

VEX AIR 无人机控制器屏幕的截图,中间有一个细长的橙色矩形,矩形内印有白色的“VEXcode AIR”字样。

设置屏幕上的文本填充颜色#

The set text fill color on screen stack block sets the fill color behind printed text. The default text fill color is transparent.

set text fill color stack block#
将屏幕上的文本填充颜色设置为 [红色 v]

参数

描述

颜色

The text fill color to use:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan
  • transparent

示例

启动后,将填充颜色设置为橙色,并绘制两个矩形。第一个矩形位于 (50, 50),第二个矩形位于 (50, 130),宽度均为 100 像素,高度均为 60 像素。#
当开始 :: hat events
[Display two colors behind text.]
将屏幕上的文本填充颜色设置为 [红色 v]
在屏幕上打印 ["Red"]▶
在屏幕上设定光标至下一行
将屏幕上的文本填充颜色设置为 [蓝色 v]
在屏幕上打印 ["Blue"]▶

设置屏幕上的绘制填充颜色#

The set draw fill color on screen stack block sets the fill color used when shapes are drawn. The default fill color is black.

set draw fill color stack block#
将屏幕上的绘制填充颜色设置为 [红色 v]

参数

描述

颜色

The shape fill color to use:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan
  • transparent

示例

启动后,将填充颜色设置为橙色,并绘制两个矩形。第一个矩形位于 (50, 50),第二个矩形位于 (50, 130),宽度均为 100 像素,高度均为 60 像素。#
当开始
[Draw an orange-filled rectangle with text on top.]
将屏幕上的绘制填充颜色设置为 [orange v]
在屏幕 [200] [150] [240] [150] 上画矩形
print [VEXcode AIR] at x: [250] y: [220] on screen

VEX AIR 无人机控制器屏幕的截图,图中有一个实心橙色矩形,带有细白边框,矩形中心印有白色文字“VEXcode AIR”。

#

在屏幕上显示图像文件#

The show image file on screen stack block draws a custom user-uploaded image on the controller screen at the set origin.

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

参数

描述

图像编号

要使用的用户上传的图片。如果在控制面板中编辑了图片名称,选项将会更改。

例子

待办事项#
当开始
[Display custom image on screen.]
显示图像文件 [IMAGE1 v]

在屏幕上绘制像素#

The draw pixel on screen stack block draws one pixel at the selected x and y coordinate using the current pen color.

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

参数

描述

x

The x-coordinate to draw the pixel from 0 to 640.

y

The y-coordinate to draw the pixel from 0 to 480.

例子

启动时,在屏幕中心坐标 (120, 120) 处绘制一个像素。#
当开始
[Draw five pixels in a diagonal.]
在屏幕 [360] [200] 上画点
在屏幕 [340] [220] 上画点
在屏幕 [320] [240] 上画点
在屏幕 [300] [260] 上画点
在屏幕 [280] [280] 上画点

VEX AIR 无人机控制器屏幕的截图,屏幕中央沿对角线均匀地印有 5 个像素。

在屏幕上画线#

The draw line on screen stack block draws a line from the first screen coordinate (x1, y1) to the second screen coordinate (x2, y2) using the current pen width and pen color.

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

参数

描述

x1

The x-coordinate in pixels of the start of the line from 0 to 640.

y1

The y-coordinate in pixels of the start of the line from 0 to 480.

x2

The x-coordinate in pixels of the end of the line from 0 to 640.

y2

The y-coordinate in pixels of the end of the line from 0 to 480.

例子

启动时,从屏幕左上角(0,0)到右下角(240,240)绘制一条对角线。#
当开始
[Make an X across the screen.]
在屏幕 [0] [0] [640] [480] 上画线段
设定屏幕笔/字体颜色为 [cyan v]
在屏幕 [0] [480] [640] [0] 上画线段

VEX AIR 无人机控制器屏幕的截图,从左上角到右下角画一条白线,从左下角到右上角画一条青色线,两条线在中心相交。

在屏幕上绘制矩形#

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

draw rectangle stack block#
在屏幕 [0] [0] [10] [10] 上画矩形

例子

参数

描述

x

The x-coordinate in pixels of the top-left corner of the rectangle from 0 to 640.

y

The y-coordinate in pixels of the top-left corner of the rectangle from 0 to 480.

宽度

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

高度

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

启动时,在屏幕上绘制一个矩形,左上角位于 (50,50),宽度为 130 像素,高度为 60 像素。#
当开始
[Draw two rectangles on the screen.]
在屏幕 [0] [0] [620] [460] 上画矩形
将屏幕上的绘制填充颜色设置为 [绿色 v]
在屏幕 [200] [180] [200] [100] 上画矩形

VEX AIR 无人机控制器屏幕的截图,屏幕中心印有一个带有细白边框的实心绿色矩形,屏幕外缘也印有一个细白边框。

在屏幕上画一个圆#

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

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

参数

描述

x

The x-coordinate in pixels of the center of the circle from 0 to 640.

y

The y-coordinate in pixels of the center of the circle from 0 to 480.

半径

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

例子

启动时,在屏幕上绘制一个圆心为 (120,120) 、半径为 40 像素的圆圈。#
当开始
[Draw one green circle on the screen.]
将屏幕上的绘制填充颜色设置为 [绿色 v]
在屏幕 [320] [240] [200] 上画圆形

VEX AIR 无人机控制器屏幕的截图,屏幕中央绘制了一个带有细白边框的大型实心绿色圆圈。

触碰#

screen pressed#

The screen pressed Boolean block reports whether the controller’s screen is currently being pressed.

  • True - Screen is currently being pressed

  • False - Screen is not being pressed

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

参数

描述

该块没有参数。

例子

当开始
[Play a sound when the screen is pressed.]
永久循环
如果 <屏幕按下了?> 那么
播放音符 [低 v] [C v] [note_eight v] ▶
按下屏幕后,会显示第一条信息。然后,程序会等待屏幕松开,只有在再次按下屏幕后才会继续显示第二条信息。#
当开始
[Display different messages after the screen is pressed.]
等到 <屏幕按下了?>
在屏幕上打印 [First message!]▶
在屏幕上设定光标至下一行
[Lift finger to press the screen again.]
等到 <非 <屏幕按下了?>>
等到 <屏幕按下了?>
在屏幕上打印 [Second message!]▶

屏幕位置#

The screen position reporter block reports the x- or y-coordinate in pixels where the screen was last pressed. The return value for x is between 0 (left) and 640 (right). The return value for y is between 0 (top) and 480 (bottom).

A VEX AIR Drone Controller with the printable area of the screen dimensions labeled and outlined in a red box. The coordinates begin with (0,0) in the upper left corner, and proceed clockwise with (0, 640), (480, 640), and (480,0) to the lower left corner. The center coordinates of the screen are labeled (240, 320).

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

参数

描述

协调

The coordinate of the last screen press in pixels: x reports the horizontal position, and y reports the vertical position.

例子

启动后,持续检测屏幕是否按下。如果按下,则清除屏幕并打印触摸位置的 x 和 y 坐标。#
当开始
[Play high or low note based on where screen is pressed.]
永久循环
如果 <屏幕按下了?> 那么
如果 <(屏幕 [X v] 坐标) [math_greater_than v] [320]> 那么
播放音符 [高 v] [C v] [note_eight v] ▶
否则
播放音符 [低 v] [C v] [note_eight v] ▶

当屏幕事件#

The when screen event hat block runs when the controller screen is pressed or released.

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

参数

描述

行动

Determines when the attached stack of blocks will run: pressed runs when the screen is pressed, and released runs when the screen is released.

例子

当屏幕 [pressed v]
[Play a sound when the screen is pressed.]
播放声音 [成功 v] ▶