Pantalla#
Introducción#
La pantalla cerebral VEX IQ (2.ª generación) ofrece una variedad de métodos para mostrar información, dibujar formas y controlar los elementos visuales de la pantalla.
Para los ejemplos siguientes, el cerebro construido incluye acceso a los métodos de Pantalla y se utilizará en todos los ejemplos posteriores en esta documentación de API cuando se haga referencia a esos métodos.
A continuación se muestra una lista de todos los métodos:
Cursor – Métodos para posicionar y visualizar texto
print
– Prints text at the current cursor position.setCursor
– Sets the cursor to a specific row and column.newLine
– Moves the cursor to column 1 of the next row.clearLine
– Clears a row of text.row
– Returns the current cursor row.column
– Returns the current cursor column.printAt
– Prints text at a specific x and y location.setClipRegion
– Restricts where drawings and text can appear.getStringWidth
– Returns the width of a string in pixels.getStringHeight
– Returns the height of a string in pixels.
Mutadores: métodos para configurar las propiedades de la pantalla
clearScreen
– Clears the screen of all drawings and text.setFont
– Sets the font for printed text.setPenWidth
– Sets the thickness for drawn shapes and lines.setPenColor
– Sets the color for outlines and text.setFillColor
– Sets the fill color for shapes and backgrounds.setOrigin
– Sets a new origin for printing and drawing.
Dibujar – Métodos para dibujar formas y gráficos
drawPixel
– Draws a pixel at a specific x and y position.drawLine
– Draws a line between two points.drawRectangle
– Draws a rectangle.drawCircle
– Draws a circle.render
– Updates the Brain’s screen with text and drawings only when called.
Cursor#
print#
print
displays text on the Brain’s screen at the current cursor position and font.
Usage:
Brain.Screen.print(value);
Parámetros |
Descripción |
---|---|
|
El texto que se mostrará en pantalla. Use formato de cadena de C++ para imprimir la variable. |
// example coming soon
setCursor#
setCursor
sets the cursor at a specific row and column on the Brain’s screen. How many rows and columns can comfortably fit depends on the selected font.
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, setCursor
positions the cursor based on row and column size, not font style. The font size can be adjusted using setFont
.
Usage:
Brain.Screen.setCursor(row, col);
Parámetros |
Descripción |
---|---|
|
La fila del cursor. |
|
La columna del cursor. |
// example coming soon
newLine#
newLine
moves the cursor to column 1 on the next row on the Brain’s screen.
Usage:
Brain.Screen.newLine();
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// example coming soon
clearLine#
clearLine
clears a row of drawings and text on the Brain’s screen.
Usage:
Brain.Screen.clearLine(row, color);
Parámetros |
Descripción |
---|---|
|
Opcional. La fila que se va a borrar. El valor predeterminado es la fila actual del cursor. |
|
Optional. Sets the pen color. Options include:
|
// example coming soon
row#
row
returns the current row where text will be printed as an integer.
Usage:
Brain.Screen.row()
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// example coming soon
column#
column
returns the current column where text will be printed as an integer.
Usage:
Brain.Screen.column()
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// example coming soon
printAt#
printAt
displays text on the Brain’s screen at a specified x and y-coordinate (in pixels) with the current font and origin. This method disregards the current cursor position.
Usage:
Brain.Screen.printAt(x, y, value);
Parámetros |
Descripción |
---|---|
|
The x position to print at as a keyword argument, ie: |
|
The y position to print at as a keyword argument, ie: |
|
El texto que se imprimirá en pantalla. Utilice el formato de cadena de C++ para imprimir la variable. |
// example coming soon
setClipRegion#
setClipRegion
defines a rectangular area on the screen where all drawings and text will be confined. Any content outside this region will not be displayed.
Usage:
Brain.Screen.setClipRegion(x, y, width, height);
Parámetro |
Descripción |
---|---|
|
La coordenada x de la esquina superior izquierda de la región de recorte, expresada como un número entero o flotante de 0 a 160. |
|
La coordenada y de la esquina superior izquierda de la región de recorte, expresada como un número entero o flotante de 0 a 108. |
|
El ancho de la región de recorte en píxeles, expresado como un número entero o flotante de 0 a 160. |
|
La altura de la región de recorte en píxeles, expresada como un entero o un punto flotante entre 0 y 108. |
// example coming soon
getStringWidth#
getStringWidth
returns the width of a string in pixels, as it would appear on the Brain’s screen. The width varies depending on the string’s length and the current font.
Usage:
Brain.Screen.getStringWidth(string);
Parámetros |
Descripción |
---|---|
|
La cuerda a medir. |
// example coming soon
getStringHeight#
get_string_height
returns the height of a string in pixels, as it would appear on the Brain’s screen. The width varies depending on the string’s length and the current font.
Usage:
Brain.Screen.getStringHeight(string);
Parámetros |
Descripción |
---|---|
|
La cuerda a medir. |
// example coming soon
Mutadores#
clearScreen#
clearScreen
clears all drawings and text from the Brain’s screen.
Usage:
Brain.Screen.clearScreen();
Parámetros |
Descripción |
---|---|
|
Optional. Sets the pen color. Options include:
|
// example coming soon
setFont#
setFont
sets the font used for displaying text on the Brain’s screen. This font will apply to all text printed with print
or printAt
. The default font at the start of a project is mono20
.
Usage:
Brain.Screen.setFont(type);
Parámetro |
Descripción |
---|---|
|
Sets the font to one of the following:
|
|
|
|
---|---|---|
|
|
|
|
|
|
|
// example coming soon
setPenWidth#
setPenWidth
sets the pen width used for drawing lines and shapes.
Usage:
Brain.Screen.setPenWidth(value);
Parámetro |
Descripción |
---|---|
|
El ancho del lápiz, expresado como un número entero en píxeles en un rango de 0 a 32. |
// example coming soon
setPenColor#
setPenColor
sets the pen color used for drawing lines, shapes, and text.
Usage:
Brain.Screen.setPenColor(color);
Parámetro |
Descripción |
---|---|
|
Optional. Sets the pen color. Options include:
|
// example coming soon
setFillColor#
setFillColor
method sets the fill color used when shapes are drawn.
Usage:
Brain.Screen.setFillColor(color);
Parámetro |
Descripción |
---|---|
|
Optional. Sets the pen color. Options include:
|
// example coming soon
setOrigin#
setOrigin
sets the origin (0,0) used for drawing or printing on the Brain’s screen. By default, drawing or printing methods consider the top left corner of the screen as the origin. This method can reset the origin to an alternate (x, y) screen coordinate location.
Usage:
Brain.Screen.setOrigin(x, y);
Parámetro |
Descripción |
---|---|
|
La nueva coordenada x que se establecerá como origen, expresada como un número entero de 0 a 160. |
|
La nueva coordenada y que se establecerá como origen, expresada como un número entero de 0 a 108. |
// example coming soon
Dibujar#
drawPixel#
drawPixel
draws a pixel at the specified (x, y) screen coordinate with the current pen color.
Usage:
Brain.Screen.drawPixel(x, y);
Parámetro |
Descripción |
---|---|
|
La coordenada x donde se dibujará el píxel, expresada como un número entero de 0 a 160. |
|
La coordenada y donde se dibujará el píxel, expresada como un número entero de 0 a 108. |
// example coming soon
drawLine#
drawLine
draws a line from the first specified screen coordinate (x1, y1)
to the second specified screen coordinate (x2, y2)
. It uses the current pen width and pen color.
The x and y-coordinates use the default origin of (0, 0) unless a different origin has been set using setOrigin
.
Usage:
Brain.Screen.drawLine(x1, y1, x2, y2);
Parámetro |
Descripción |
---|---|
|
La coordenada x inicial de la línea, expresada como un número entero de 0 a 160. |
|
La coordenada y inicial de la línea, expresada como un número entero entre 0 y 108. |
|
La coordenada x final de la línea, expresada como un número entero de 0 a 160. |
|
La coordenada y final de la línea, expresada como un número entero entre 0 y 108. |
// example coming soon
drawRectangle#
drawRectangle
draws a rectangle with its top-left corner at the specified (x, y)
coordinate and a size determined by the given width and height, all measured in pixels. The rectangle’s outline is drawn using the current pen width and pen color. The interior is filled with the current fill color.
The x and y-coordinates use the default origin of (0,0) unless a different origin has been set using setOrigin
.
Usage:
Brain.Screen.drawRectangle(x, y, width, height, color);
Parámetro |
Descripción |
---|---|
|
La coordenada x de la esquina superior izquierda del rectángulo, expresada como un número entero de 0 a 160. |
|
La coordenada y de la esquina superior izquierda del rectángulo, expresada como un número entero de 0 a 108. |
|
El ancho del rectángulo, expresado como un número entero de 0 a 160. |
|
La altura del rectángulo, expresada como un número entero de 0 a 108. |
|
Optional. Sets the pen color. Options include:
|
// example coming soon
drawCircle#
drawCircle
draws a circle with its center at the specified (x, y)
coordinate and a size determined by the given radius, all measured in pixels. The circle’s outline is drawn using the current pen width and pen color. The interior is filled with the current fill color.
The x and y-coordinates use the default origin of (0,0) unless a different origin has been set using setOrigin
.
Usage:
Brain.Screen.drawCircle(x, y, radius, color);
Parámetro |
Descripción |
---|---|
|
La coordenada x del centro del círculo, expresada como un número entero de 0 a 160. |
|
La coordenada y del centro del círculo, expresada como un número entero de 0 a 160. |
|
El radio del círculo, expresado como un número entero de 0 a 108 píxeles. |
|
Optional. Sets the pen color. Options include:
|
// example coming soon
render#
render
enables double buffering for the Brain’s screen. Once called, any drawing commands (like text, shapes, or images) will no longer appear immediately for the rest of the project. Instead, updates will only be shown when render
is used again. This allows for smoother and more controlled screen updates, but means nothing will be visible until render
is used.
Usage:
Brain.Screen.render();
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// example coming soon