屏幕#

打印()#

print(value, format, ...) 方法使用当前光标位置在屏幕上打印文本。

参数

描述

价值

要打印的文本。

格式

打印变量值时使用的格式说明符。

要使用格式说明符打印的参数变量列表。

**返回:**无。

// Print the number 1 on the Brain's screen at current
// cursor position.
Brain.Screen.print(1);

打印()#

printAt(text, x, y, format, precision, ...) 方法在屏幕上特定的 x 和 y 坐标处打印文本。

参数

描述

价值

要打印的文本。

x

作为关键字参数 (x=) 打印的 x 位置,参考屏幕原点。

y

作为关键字参数 (y=) 打印的 y 位置,参考屏幕原点。

格式

打印变量值时使用的格式说明符。

要使用格式说明符打印的参数变量列表。

**返回:**无。

// Print the number 1 on the Brain's screen at
// position (100, 40).
Brain.Screen.printAt(1, x=100, y=40);

设置光标()#

setCursor(x, y) 方法设置光标位置。行距和列距会考虑所选字体。对于 MONO20 字体,基本单元格大小为 10x20 像素。屏幕左上角为位置 (x=1, y=1)。

参数

描述

x

光标的 x 位置。

y

光标的 y 位置。

**返回:**无。

设置原点()#

setOrigin(x, y) 方法设置 Brain 屏幕上用于绘制图形的原点。绘图函数将 Brain 屏幕的左上角视为原点。此函数可以将原点移动到其他位置,例如 Brain 屏幕的中心。

参数

描述

x

原点相对于左上角的 x 位置。

y

原点相对于左上角的 y 位置。

**返回:**无。

设置字体()#

setFont(fontname) 方法设置在 Brain 屏幕上打印文本所使用的字体类型。

参数

描述

字体名称

有效的 fontType

**返回:**无。

// Set the font type to mono40.
Brain.Screen.setFont(fontType::mono40);

设置笔宽()#

setPenWidth(width) 方法设置用于绘制线条、矩形和圆形的笔宽。

参数

描述

宽度

笔的宽度。

**返回:**无。

// Set the pen width to 5 pixels.
Brain.Screen.setPenWidth(5);

设置笔颜色()#

画笔颜色可以通过两种方式设置:

setPenColor(color) 方法将笔的颜色设置为指定的颜色。

参数

描述

颜色

先前定义的 colorType 对象或十六进制值。

**返回:**无。

// Set pen color red using a Hex value.
Brain.Screen.setPenColor(0xFF0000);

// Set pen color blue using a predefined color.
Brain.Screen.setPenColor(blue);

// Set pen color green using a web string.
Brain.Screen.setPenColor("#00FF00");

setPenColor(hue) 方法使用指定的色调设置笔的颜色。

参数

描述

色调

表示颜色色调的整数,范围是 1 - 359。

**返回:**无。

设置填充颜色()#

填充颜色可以通过两种方式设置:

setFillColor(color) 方法使用指定的颜色设置填充颜色。

参数

描述

颜色

先前定义的 colorType 对象或十六进制值。

**返回:**无。

// Set pen color red using a hex value.
Brain.Screen.setFillColor(0xFF0000);

// Set pen color blue using a predefined color.
Brain.Screen.setFillColor(blue);

// Set pen color green using a web string.
Brain.Screen.setFillColor("#00FF00");

setFillColor(hue) 方法使用指定的色调设置填充颜色。

参数

描述

色调

表示颜色色调的整数,范围是 1 - 359。

**返回:**无。

柱子()#

column() 方法返回将打印文本的当前列。

**返回:**当前列位置。

排()#

row() 方法返回将打印文本的当前行。

**返回:**当前行位置。

获取字符串宽度()#

getStringWidth(string) 方法获取字符串的宽度(以像素为单位),就像它在 Brain 屏幕上一样。字符串的宽度会根据字符串的长度和字体的大小而变化。

参数

描述

细绳

要测量的字符串。

**返回:**字符串的宽度(整数)。

获取字符串高度()#

getStringHeight(string) 方法获取字符串的高度(以像素为单位),就像它在 Brain 屏幕上一样。字符串的高度会根据字符串的长度和字体的大小而变化。

参数

描述

细绳

要测量的字符串。

**返回:**字符串的高度(整数)。

清除屏幕()#

大脑的屏幕可以通过三种方式清除:

clearScreen() 方法将 Brain 的屏幕清除为默认颜色(黑色)。

**返回:**无。

// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode");

// Clear screen to black.
Brain.Screen.clearScreen();

clearScreen(color) 方法将整个 Brain 的屏幕清除为指定的颜色。

参数

描述

颜色

先前定义的 colorType 对象或十六进制值。

**返回:**无。

// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode");

// Clear screen to blue using a predefined color.
Brain.Screen.clearScreen(blue);

clearScreen(hue) 方法将整个 Brain 的屏幕清除为指定的色调。

参数

描述

色调

表示颜色色调的整数,范围是 1 - 359。

**返回:**无。

清除线()#

可以通过四种方式清除大脑屏幕上的线条:

clearLine() 方法清除光标当前所在的行。

**返回:**无。

clearLine(number) 方法清除指定的行。

参数

描述

数字

要清除的行。

**返回:**无。

clearLine(number, color) 方法清除指定的行并将该行设置为指定的颜色。

参数

描述

数字

要清除的行。

颜色

先前定义的 color 对象或十六进制值。

**返回:**无。

clearLine(number, hue) 方法清除指定的行并将该行设置为指定的色调。

参数

描述

数字

要清除的行。

色调

表示颜色色调的整数,范围是 1 - 359。

**返回:**无。

新行()#

newLine() 方法将光标移动到下一行。

**返回:**无。

绘制像素()#

drawPixel(x, y) 方法使用当前笔颜色绘制一个像素。

参数

描述

x

绘制像素的 x 位置参考屏幕原点。

y

绘制像素的 y 位置参考屏幕原点。

**返回:**无。

// Draw a red pixel on the Brain's screen.
Brain.Screen.setPenColor(red);
Brain.Screen.drawPixel(10, 10);

绘制线()#

drawLine(x1, y1, x2, y2) 方法使用当前笔颜色绘制一条线。

参数

描述

x1

线的起点相对于屏幕原点的 x 位置。

y1

线的起点相对于屏幕原点的 y 位置。

x2

线尾相对于屏幕原点的 x 位置。

y2

线末端相对于屏幕原点的 y 位置。

**返回:**无。

// Draw a red line on the Brain's screen.
Brain.Screen.setPenColor(red);
Brain.Screen.drawLine(10, 10, 20, 20);

绘制矩形()#

可以用三种方式在 Brain 的屏幕上绘制矩形:

drawRectangle(x, y, width, height) 方法使用当前的画笔和填充颜色在屏幕上绘制一个矩形。

参数

描述

x

矩形左上角相对于屏幕原点的 x 位置。

y

矩形左上角相对于屏幕原点的 y 位置。

宽度

矩形的宽度。

高度

矩形的高度。

**返回:**无。

// Draw a green rectangle on the screen that is
// filled using blue.
Brain.Screen.setPenColor(green);
Brain.Screen.setFillColor(blue);
Brain.Screen.drawRectangle(10, 10, 20, 20);

drawRectangle(x, y, width, height, color) 方法使用当前笔在屏幕上绘制一个矩形,并用指定的颜色填充圆圈。

参数

描述

x

矩形左上角相对于屏幕原点的 x 位置。

y

矩形左上角相对于屏幕原点的 y 位置。

宽度

矩形的宽度。

高度

矩形的高度。

颜色

先前定义的 color 对象或十六进制值。

**返回:**无。

drawRectangle(x, y, width, height, hue) 方法使用当前笔在屏幕上绘制一个矩形,并用指定的色调填充圆圈。

参数

描述

x

矩形左上角相对于屏幕原点的 x 位置。

y

矩形左上角相对于屏幕原点的 y 位置。

宽度

矩形的宽度。

高度

矩形的高度。

色调

表示颜色色调的整数,范围是 1 - 359。

**返回:**无。

画圆()#

可以用三种方式在大脑的屏幕上绘制圆圈:

drawCircle(x, y, radius) 方法使用当前的画笔和填充颜色绘制一个圆圈。

参数

描述

x

圆心相对于屏幕原点的 x 位置。

y

圆心相对于屏幕原点的 y 位置。

半径

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

**返回:**无。

// Draw a green circle on the Brain's screen that is
// filled using blue.
Brain.Screen.setPenColor(green);
Brain.Screen.setFillColor(blue);
Brain.Screen.drawCircle(50, 50, 10);

drawCircle(x, y, radius, color) 方法使用当前笔颜色绘制一个圆圈,并用指定的颜色填充圆圈。

参数

描述

x

圆心相对于屏幕原点的 x 位置。

y

圆心相对于屏幕原点的 y 位置。

半径

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

颜色

先前定义的 color 对象或十六进制值。

**返回:**无。

drawCircle(x, y, radius, hue) 方法使用当前笔颜色绘制一个圆圈,并用指定的色调填充圆圈。

参数

描述

x

圆心相对于屏幕原点的 x 位置。

y

圆心相对于屏幕原点的 y 位置。

半径

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

色调

表示颜色色调的整数,范围是 1 - 359。

**返回:**无。

反转圆()#

invertCircle(x, y, radius) 方法使用参数中设置的指定点和属性反转屏幕的圆形区域。

参数

描述

x

圆的中心 x 位置。

y

圆的中心 y 位置。

半径

设置屏幕上要绘制的圆的半径。

// Invert a circle at (30, 30) with radius 10.
Brain.Screen.invertCircle(30, 30, 10);

反转矩形()#

invertRectangle(x, y, width, height) 方法使用参数中设置的指定点和属性反转屏幕的矩形区域。

参数

描述

x

矩形左边缘在屏幕上绘制的 x 坐标。

y

矩形顶边在屏幕上绘制的 y 坐标。

宽度

矩形的宽度。

高度

矩形的高度。

// Invert a rectangle at (10, 10) with width 50 and height 20.
Brain.Screen.invertRectangle(10, 10, 50, 20);

设置AspectCompensation()#

setAspectCompensation(value) 方法在绘制时补偿非方形像素。

范围

描述

价值

truefalse

// Set aspect compensation to true.
Brain.Screen.setAspectCompensation(true);