Pantalla#
imprimir()#
The print(value, format, …)
method prints text on the screen using the current cursor position.
Parámetros |
Descripción |
---|---|
valor |
El texto a imprimir. |
formato |
Opcional. Un especificador de formato que se utilizará al imprimir el valor de las variables. |
… |
Opcional. Una lista variable de parámetros que se imprimirán con el especificador de formato. |
Devoluciones: Ninguna.
// Print the number 1 on the Brain's screen at current
// cursor position.
Brain.Screen.print(1)
imprimirEn()#
The printAt(text, x, y, format, precision, …)
method prints text at a specific x and y coordinates on the screen.
Parámetros |
Descripción |
---|---|
valor |
El texto a imprimir. |
incógnita |
La posición x para imprimir como argumento de palabra clave (x=), referenciada al origen de la pantalla. |
y |
La posición y para imprimir como argumento de palabra clave (y=), referenciada al origen de la pantalla. |
formato |
Opcional. Un especificador de formato que se utilizará al imprimir el valor de las variables. |
… |
Opcional. Una lista variable de parámetros que se imprimirán con el especificador de formato. |
Devoluciones: Ninguna.
// Print the number 1 on the Brain's screen at
position (100, 40).
Brain.Screen.printAt(1, x=100, y=40)
establecerCursor()#
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
).
Parámetros |
Descripción |
---|---|
incógnita |
La posición x del cursor. |
y |
La posición y del cursor. |
Devoluciones: Ninguna.
establecerOrigen()#
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.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x del origen relativa a la esquina superior izquierda. |
y |
La posición y del origen con respecto a la esquina superior izquierda. |
Devoluciones: Ninguna.
establecerFuente()#
The setFont(fontname)
method sets the font type used for printing text on the Brain’s screen.
Parámetros |
Descripción |
---|---|
nombre de fuente |
Un FontType válido. |
Devoluciones: Ninguna.
// Set the font type to MONO40.
Brain.Screen.setFont(FontType.MONO40)
establecerAnchoDePluma()#
The setPenWidth(width)
method sets the pen width used for drawing lines, rectangles and circles.
Parámetros |
Descripción |
---|---|
ancho |
El ancho del bolígrafo. |
Devoluciones: Ninguna.
// Set the pen width to 5 pixels.
Brain.Screen.setPenWidth(5)
establecerColorDePluma()#
El color del lápiz se puede configurar de dos maneras:
The setPenColor(color)
method sets the pen color with the specified color.
Parámetros |
Descripción |
---|---|
color |
O bien un objeto color definido previamente o un valor hexadecimal. |
// Set pen color red using a Hex value.
Brain.Screen.setPenColor(0xFF0000)
// Set pen color blue using a predefined color.
Brain.Screen.setPenColor(Color.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.
Parámetros |
Descripción |
---|---|
matiz |
Un número entero que representa el tono del color, de 1 a 359. |
Devoluciones: Ninguna.
establecerColorDeRelleno()#
El color de relleno se puede configurar de dos maneras:
The setFillColor(color)
method sets the fill color with the specified color.
Parámetros |
Descripción |
---|---|
color |
O bien un objeto color definido previamente o un valor hexadecimal. |
// Set pen color red using a hex value.
Brain.Screen.setFillColor(0xFF0000)
// Set pen color blue using a predefined color.
Brain.Screen.setFillColor(Color.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.
Parámetros |
Descripción |
---|---|
matiz |
Un número entero que representa el tono del color, de 1 a 359. |
Devoluciones: Ninguna.
columna()#
The column()
method returns the current column where text will be printed.
Devuelve: La posición actual de la columna.
fila()#
The row()
method returns the current row where text will be printed.
Devuelve: La posición de la fila actual.
obtenerAnchoDeCadena()#
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.
Parámetros |
Descripción |
---|---|
cadena |
La cuerda a medir. |
Devuelve: El ancho de la cadena como un entero.
obtenerAlturaDeCadena()#
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.
Este es un método sin espera y permite que el siguiente método se ejecute sin demora.
Parámetros |
Descripción |
---|---|
cadena |
La cuerda a medir. |
Devuelve: La altura de la cadena como un entero.
Borrar pantalla()#
La pantalla del cerebro se puede limpiar de tres maneras:
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.
Parámetros |
Descripción |
---|---|
color |
O bien un objeto color definido previamente o un valor hexadecimal. |
// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode")
// Clear screen to blue using a predefined color.
Brain.Screen.clearScreen(Color.BLUE)
The clearScreen(hue)
method clears the whole Brain’s screen to a specified hue.
Parámetros |
Descripción |
---|---|
matiz |
Un número entero que representa el tono del color, de 1 a 359. |
Devoluciones: Ninguna.
clearLine()#
Las líneas se pueden borrar en la pantalla del Cerebro de cuatro maneras:
The clearLine()
method clears the row where the cursor is currently located.
The clearLine(number)
method clears a specified row.
Parámetros |
Descripción |
---|---|
número |
La fila a despejar. |
The clearLine(number, color)
method clears a specified row and sets the row to a specified color.
Parámetros |
Descripción |
---|---|
número |
La fila a despejar. |
color |
O bien un objeto color definido previamente o un valor hexadecimal. |
The clearLine(number, hue)
method clears a specified row and sets the row to a specified hue.
Parámetros |
Descripción |
---|---|
número |
La fila a despejar. |
matiz |
Un número entero que representa el tono del color, de 1 a 359. |
Devoluciones: Ninguna.
nuevaLínea()#
The newLine()
method moves the cursor to the next row.
Devoluciones: Ninguna.
apretado()#
The pressed(callback)
method registers a function to be called when the screen is pressed.
Parámetros |
Descripción |
---|---|
llamar de vuelta |
Una función que se llamará cuando se presione la pantalla. |
Devuelve: Una instancia de la clase Event.
// Define the screenPressed function with a void return type,
// showing it doesn't return a value.
void screenPressed() {
// The Brain will print that the screen was pressed on
// the Brain's screen.
Brain.Screen.print("screen pressed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run screenPressed when the screen is pressed on
// the Brain.
Brain.Screen.pressed(screenPressed);
}
liberado()#
The released(callback)
method sets the function to be called when the screen is released after being pressed.
Parámetros |
Descripción |
---|---|
llamar de vuelta |
Una referencia a una función. |
Devuelve: Una instancia de la clase Event.
// Define the screenReleased function with a void return
// type, showing it doesn't return a value.
void screenReleased() {
// The Brain will print that the Brain's screen was
// released on the Brain's screen.
Brain.Screen.print("screen released");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run screenReleased when the Brain's screen is released on
// the Brain.
Brain.Screen.released(screenReleased);
}
xPosición()#
The xPosition()
method returns the last x location pressed on the Brain’s screen.
Devuelve: La última ubicación x presionada en la pantalla.
yPosition()#
The yPosition()
method returns the last y location pressed on the Brain’s screen.
Devuelve: La última ubicación y presionada en la pantalla.
prensado()#
The pressing()
method returns whether the Brain’s screen is currently being pressed.
Returns: true
if the screen is being pressed. false
if it is not.
dibujarPixel()#
The drawPixel(x, y)
method draws a pixel using the current pen color.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x para dibujar el píxel referenciado al origen de la pantalla. |
y |
La posición y para dibujar el píxel referenciado al origen de la pantalla. |
Devoluciones: Ninguna.
// Draw a red pixel on the Brain's screen.
Brain.Screen.setPenColor(Color.RED)
Brain.Screen.drawPixel(10, 10)
dibujarLínea()#
The drawLine(x1, y1, x2, y2)
method draws a line using the current pen color.
Parámetros |
Descripción |
---|---|
x1 |
La posición x del inicio de la línea referenciada al origen de la pantalla. |
año1 |
La posición y del inicio de la línea referenciada al origen de la pantalla. |
x2 |
La posición x del final de la línea referenciada al origen de la pantalla. |
Año 2 |
La posición y del final de la línea referenciada al origen de la pantalla. |
Devoluciones: Ninguna.
// Draw a red line on the Brain's screen.
Brain.Screen.setPenColor(Color.RED)
Brain.Screen.drawLine(10, 10, 20, 20)
dibujarRectángulo()#
Se puede dibujar un rectángulo en la pantalla del Cerebro de tres maneras:
The drawRectangle(x, y, width, height)
method draws a rectangle on the screen using the current pen and fill colors.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x de la esquina superior izquierda del rectángulo referenciada al origen de la pantalla. |
y |
La posición y de la esquina superior izquierda del rectángulo referenciada al origen de la pantalla. |
ancho |
El ancho del rectángulo. |
altura |
La altura del rectángulo. |
// Draw a green rectangle on the screen that is
// filled using blue.
Brain.Screen.setPenColor(Color.GREEN)
Brain.Screen.setFillColor(Color.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.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x de la esquina superior izquierda del rectángulo referenciada al origen de la pantalla. |
y |
La posición y de la esquina superior izquierda del rectángulo referenciada al origen de la pantalla. |
ancho |
El ancho del rectángulo. |
altura |
La altura del rectángulo. |
color |
O bien un objeto color definido previamente o un valor hexadecimal. |
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.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x de la esquina superior izquierda del rectángulo referenciada al origen de la pantalla. |
y |
La posición y de la esquina superior izquierda del rectángulo referenciada al origen de la pantalla. |
ancho |
El ancho del rectángulo. |
altura |
La altura del rectángulo. |
matiz |
Un número entero que representa el tono del color, de 1 a 359. |
Devoluciones: Ninguna.
dibujarCírculo()#
Se puede dibujar un círculo en la pantalla del Cerebro de tres maneras:
The drawCircle(x, y, radius)
method draws a circle using the current pen and fill colors.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x del centro del círculo referenciado al origen de la pantalla. |
y |
La posición y del centro del círculo referenciada al origen de la pantalla. |
radio |
El radio del círculo en píxeles. |
// Draw a green circle on the Brain's screen that is
// filled using blue.
Brain.Screen.setPenColor(Color.GREEN)
Brain.Screen.setFillColor(Color.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.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x del centro del círculo referenciado al origen de la pantalla. |
y |
La posición y del centro del círculo referenciada al origen de la pantalla. |
radio |
El radio del círculo en píxeles. |
color |
O bien un objeto color definido previamente o un valor hexadecimal. |
The drawCircle(x, y, radius, hue)
method draws a circle using the current pen color and fills the circle with the specified hue.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x del centro del círculo referenciado al origen de la pantalla. |
y |
La posición y del centro del círculo referenciada al origen de la pantalla. |
radio |
El radio del círculo en píxeles. |
matiz |
Un número entero que representa el tono del color, de 1 a 359. |
Devoluciones: Ninguna.
dibujarImagenDesdeArchivo()#
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.
Parámetros |
Descripción |
---|---|
Nombre del archivo |
El nombre del archivo de la imagen. |
incógnita |
La coordenada x de la esquina superior izquierda de la imagen en la pantalla. |
y |
La coordenada y de la esquina superior izquierda de la imagen en la pantalla. |
Devoluciones: Ninguna.
// Draw the vex.bmp image on the Brain's screen at
// coordinate 0, 0.
Brain.Screen.drawImageFromFile('vex.bmp', 0, 0)
prestar()#
La pantalla se puede almacenar en búfer de dos maneras:
The render()
method switches to double buffering or renders the back buffer to the Brain’s 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.
Parámetros |
Descripción |
---|---|
bSyncEspera |
|
bRunScheduler |
Optional. |
Returns: True
if buffer was successfully rendered to the screen.
establecerRegiónDeClip()#
The setClipRegion(x, y, width, height)
method sets the clip region for drawing the supplied rectangle.
Parámetros |
Descripción |
---|---|
incógnita |
La posición x de la esquina superior izquierda del rectángulo, referenciada al origen de la pantalla. |
y |
La posición y de la esquina superior izquierda del rectángulo, referenciada al origen de la pantalla. |
ancho |
El ancho del rectángulo. |
altura |
La altura del rectángulo. |
Devoluciones: Ninguna.