屏幕#
打印()#
The print(value, format, …)
method prints text on the screen using the current cursor position.
参数 |
描述 |
---|---|
价值 |
要打印的文本。 |
格式 |
打印变量值时使用的格式说明符。 |
… |
要使用格式说明符打印的参数变量列表。 |
**返回:**无。
// Print the number 1 on the Brain's screen at current
// cursor position.
Brain.Screen.print(1);
打印()#
The printAt(text, x, y, format, precision, …)
method prints text at a specific x and y coordinates on the screen.
参数 |
描述 |
---|---|
价值 |
要打印的文本。 |
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);
设置光标()#
The setCursor(x, y)
method sets the cursor position. The row and column spacing will take into account the selected font. The base cell size if 10x20 pixels for the mono20
font. The top, left corner of the screen is position (x=1
, y=1
).
参数 |
描述 |
---|---|
x |
光标的 x 位置。 |
y |
光标的 y 位置。 |
**返回:**无。
设置原点()#
The setOrigin(x, y)
method sets the origin used for drawing graphics on the Brain’s screen. Drawing functions consider the top left corner of the Brain’s screen as the origin. This function can move the origin to an alternate position such as the center of the Brain’s screen.
参数 |
描述 |
---|---|
x |
原点相对于左上角的 x 位置。 |
y |
原点相对于左上角的 y 位置。 |
**返回:**无。
设置字体()#
The setFont(fontname)
method sets the font type used for printing text on the Brain’s screen.
参数 |
描述 |
---|---|
字体名称 |
有效的 fontType。 |
**返回:**无。
// Set the font type to mono40.
Brain.Screen.setFont(mono40);
设置笔宽()#
The setPenWidth(width)
method sets the pen width used for drawing lines, rectangles and circles.
参数 |
描述 |
---|---|
宽度 |
笔的宽度。 |
**返回:**无。
// Set the pen width to 5 pixels.
Brain.Screen.setPenWidth(5);
设置笔颜色()#
画笔颜色可以通过两种方式设置:
The setPenColor(color)
method sets the pen color with the specified color.
参数 |
描述 |
---|---|
颜色 |
先前定义的 color 对象或十六进制代码值。 |
// 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");
The setPenColor(hue)
method sets the pen color with the specified hue.
参数 |
描述 |
---|---|
色调 |
表示颜色色调的整数,范围是 1 - 359。 |
**返回:**无。
设置填充颜色()#
填充颜色可以通过两种方式设置:
The setFillColor(color)
method sets the fill color with the specified color.
参数 |
描述 |
---|---|
颜色 |
先前定义的 color 对象或十六进制值。 |
// 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");
The setFillColor(hue)
method sets the fill color with the specified hue.
参数 |
描述 |
---|---|
色调 |
表示颜色色调的整数,范围是 1 - 359。 |
**返回:**无。
柱子()#
The column()
method returns the current column where text will be printed.
**返回:**当前列位置。
排()#
The row()
method returns the current row where text will be printed.
**返回:**当前行位置。
获取字符串宽度()#
The getStringWidth(string)
method gets the width of a string in pixels as if it was on the Brain’s screen. The width of a string changes based on the length of the string and the size of the font.
参数 |
描述 |
---|---|
细绳 |
要测量的字符串。 |
**返回:**字符串的宽度(整数)。
获取字符串高度()#
The getStringHeight(string)
method gets the height of a string in pixels as if it was on the Brain’s screen. The height of a string changes based on the length of the string and the size of the font.
参数 |
描述 |
---|---|
细绳 |
要测量的字符串。 |
**返回:**字符串的高度(整数)。
清除屏幕()#
大脑的屏幕可以通过三种方式清除:
The clearScreen()
method clears the Brain’s screen to the default color (black).
// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode");
// Clear screen to black.
Brain.Screen.clearScreen();
The clearScreen(color)
method clears the whole Brain’s screen to a specified color.
参数 |
描述 |
---|---|
颜色 |
先前定义的 color 对象或十六进制值。 |
// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode");
// Clear screen to blue using a predefined color.
Brain.Screen.clearScreen(blue);
The clearScreen(hue)
method clears the whole Brain’s screen to a specified hue.
参数 |
描述 |
---|---|
色调 |
表示颜色色调的整数,范围是 1 - 359。 |
**返回:**无。
清除线()#
该方法通过以下方式调用:
The clearLine()
method clears the row where the cursor is currently located.
**返回:**无。
The clearLine(number)
method clears a specified row.
参数 |
描述 |
---|---|
数字 |
要清除的行。 |
**返回:**无。
The clearLine(number, color)
method clears a specified row and sets the row to a specified color.
参数 |
描述 |
---|---|
数字 |
要清除的行。 |
颜色 |
先前定义的 color 对象或十六进制代码值。 |
**返回:**无。
The clearLine(number, hue)
method clears a specified row and sets the row to a specified hue.
参数 |
描述 |
---|---|
数字 |
要清除的行。 |
色调 |
表示颜色色调的整数,范围是 1 - 359。 |
**返回:**无。
新行()#
The newLine()
method moves the cursor to the next row.
**返回:**无。
绘制像素()#
The drawPixel(x, y)
method draws a pixel using the current pen color.
参数 |
描述 |
---|---|
x |
绘制像素的 x 位置参考屏幕原点。 |
y |
绘制像素的 y 位置参考屏幕原点。 |
**返回:**无。
// Draw a red pixel on the Brain's screen.
Brain.Screen.setPenColor(red);
Brain.Screen.drawPixel(10, 10);
绘制线()#
The drawLine(x1, y1, x2, y2)
method draws a line using the current pen color.
参数 |
描述 |
---|---|
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 的屏幕上绘制矩形:
The drawRectangle(x, y, width, height)
method draws a rectangle on the screen using the current pen and fill colors.
参数 |
描述 |
---|---|
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);
The drawRectangle(x, y, width, height, color)
method draws a rectangle on the screen using the current pen and fills the circle with the specified color.
参数 |
描述 |
---|---|
x |
矩形左上角相对于屏幕原点的 x 位置。 |
y |
矩形左上角相对于屏幕原点的 y 位置。 |
宽度 |
矩形的宽度。 |
高度 |
矩形的高度。 |
颜色 |
先前定义的 color 对象或十六进制代码值。 |
**返回:**无。
The drawRectangle(x, y, width, height, hue)
method draws a rectangle on the screen using the current pen and fills the circle with the specified hue.
参数 |
描述 |
---|---|
x |
矩形左上角相对于屏幕原点的 x 位置。 |
y |
矩形左上角相对于屏幕原点的 y 位置。 |
宽度 |
矩形的宽度。 |
高度 |
矩形的高度。 |
色调 |
表示颜色色调的整数,范围是 1 - 359。 |
**返回:**无。
画圆()#
可以用三种方式在大脑的屏幕上绘制圆圈:
The drawCircle(x, y, radius)
method draws a circle using the current pen and fill colors.
参数 |
描述 |
---|---|
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);
The drawCircle(x, y, radius, color)
method draws a circle using the current pen color and fills the circle with the specified color.
参数 |
描述 |
---|---|
x |
圆心相对于屏幕原点的 x 位置。 |
y |
圆心相对于屏幕原点的 y 位置。 |
半径 |
圆的半径(以像素为单位)。 |
颜色 |
先前定义的 color 对象或十六进制代码值。 |
The drawCircle(x, y, radius, hue)
method draws a circle using the current pen color and fills the circle with the specified hue.
参数 |
描述 |
---|---|
x |
圆心相对于屏幕原点的 x 位置。 |
y |
圆心相对于屏幕原点的 y 位置。 |
半径 |
圆的半径(以像素为单位)。 |
色调 |
表示颜色色调的整数,范围是 1 - 359。 |
**返回:**无。
从文件绘制图像()#
The drawImageFromFile(filename, x, y)
method draws an image from the SD card. The filename you put when calling the method must be located on the SD card.
参数 |
描述 |
---|---|
文件名 |
图像的文件名。 |
x |
屏幕上图像左上角的 x 坐标。 |
y |
屏幕上图像左上角的 y 坐标。 |
**返回:**无。
// Draw the vex.bmp image on the Brain's screen at
// coordinate 0, 0.
Brain.Screen.drawImageFromFile('vex.bmp', 0, 0);
使成为()#
屏幕可以通过两种方式缓冲:
The render()
method switches to double buffering or renders the back buffer to the Brain’s screen.
Returns: true
if buffer was successfully rendered to the screen.
The render(bSyncWait, bRunScheduler)
method switches to double buffering or renders the back buffer to the Brain’s screen, with options to wait for the Vsync signal before proceeding and to run the scheduler during the process.
参数 |
描述 |
---|---|
同步等待 |
|
运行调度器 |
|
Returns: true
if buffer was successfully rendered to the screen.
设置剪辑区域()#
The setClipRegion(x, y, width, height)
method sets the clip region for drawing the supplied rectangle.
参数 |
描述 |
---|---|
x |
矩形左上角的 x 位置(参考屏幕原点)。 |
y |
矩形左上角的 y 位置(参考屏幕原点)。 |
宽度 |
矩形的宽度。 |
高度 |
矩形的高度。 |
**返回:**无。