pantalla#

imprimir()#

The print(text, sep, precision) method prints text on the screen using the current cursor position.

Parámetros

Descripción

text

El texto a imprimir.

sep

Optional. A string to inset between values. This must be written as a keyword argument (sep=). The default is “”.

precision

Optional. The number of decimal places to display when printing simple numbers. This must be written as a keyword argument(precision=). The default is 2.

Devoluciones: Ninguna.

# Print the number 1 on the Brain's screen at current
# cursor position.
brain.screen.print(1)

# Print the numbers 1, 2, 3 and 4 on the Brain's screen at
# current cursor position separated by a '-'.
brain.screen.print(1, 2, 3, 4, sep='-')

establecer_cursor()#

The set_cursor(row, column) method sets the cursor position. The row and column spacing will take into account the selected font. The default cursor position is Row 1, Column 1.

Parámetros

Descripción

row

La fila donde colocar el cursor.

column

La columna donde colocar el cursor.

Devoluciones: Ninguna.

establecer_origen()#

The set_origin(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

x

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.

establecer_fuente()#

The set_font(fontname) method sets the font type used for printing text on the Brain’s screen.

Parámetros

Descripción

fontname

A valid FontType.

Devoluciones: Ninguna.

# Set the font type to MONO40.
brain.screen.set_font(FontType.MONO40)

establecer_ancho_de_pluma()#

The set_pen_width(width) method sets the pen width used for drawing lines, rectangles and circles.

Parámetros

Descripción

width

El ancho del bolígrafo.

Devoluciones: Ninguna.

# Set the pen width to 5 pixels.
brain.screen.set_pen_width(5)

establecer_color_del_bolígrafo()#

The set_pen_color(color) method sets the pen color used for drawing lines, rectangles and circles.

Parámetros

Descripción

color

A valid ColorType, a hex value, or a web string.

Devoluciones: Ninguna.

# Set pen color red using a hex value.
brain.screen.set_pen_color(0xFF0000)

# Set pen color blue using predefined color.
brain.screen.set_pen_color(Color.BLUE)

# Set pen color green using web string.
brain.screen.set_pen_color("#00FF00")

establecer_color_de_relleno()#

The set_fill_color(color) method sets the fill color used for drawing rectangles and circles.

Parámetros

Descripción

color

A valid ColorType, a hex value, or a web string.

Devoluciones: Ninguna.

# Set pen color red using a hex value.
brain.screen.set_fill_color(0xFF0000)

# Set pen color blue using predefined color.
brain.screen.set_fill_color(Color.BLUE)

# Set pen color green using web string.
brain.screen.set_fill_color("#00FF00")

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.

obtener_ancho_de_cadena()#

The get_string_width(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

string

La cuerda a medir.

Devuelve: El ancho de la cadena como un entero.

obtener_altura_de_cadena()#

The get_string_height(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

string

La cuerda a medir.

Devuelve: La altura de la cadena como un entero.

borrar_pantalla()#

The clear_screen(color) method clears the whole Brain’s screen to a single color.

Este es un método sin espera y permite que el siguiente método se ejecute sin demora.

Parámetros

Descripción

color

Optional. A valid ColorType, a hex value, or a web string.

Devoluciones: Ninguna.

# Print VEXcode on the Brain's screen.
brain.screen.print("VEXcode")

# Clear screen to black.
brain.screen.clear_screen()

# Print VEXcode on the Brain's screen.
brain.screen.print("VEXcode")

# Clear screen to blue using predefined color.
brain.screen.clear_screen(Color.BLUE)

línea clara()#

The clear_line() method clears a line of text.

Devoluciones: Ninguna.

borrar_fila()#

The clear_row(row, color) method clears a row to a single color.

Parámetros

Descripción

row

Opcional. La fila que se va a borrar. El valor predeterminado es la fila actual del cursor.

color

Optional. A valid ColorType, a hex value, or a web string.

Devoluciones: Ninguna.

# Clear Brain's screen to black.
brain.screen.clear_row()

# Clear Brain's screen to blue using predefined color.
brain.screen.clear_row(2, Color.BLUE)

nueva_línea()#

The new_line() method moves the cursor to a new line.

Devoluciones: Ninguna.

siguiente_fila()#

The next_row() method moves the cursor to the next row.

Devoluciones: Ninguna.

dibujar_píxel()#

The draw_pixel(x, y) method draws a pixel using the current pen color.

Parámetros

Descripción

x

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.set_pen_color(Color.RED)
brain.screen.draw_pixel(10, 10)

dibujar_línea()#

The draw_line(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.

y1

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.

y2

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.set_pen_color(Color.RED)
brain.screen.draw_line(10, 10, 20, 20)

dibujar_rectángulo()#

The draw_rectangle(x, y, width, height) method draws a rectangle on the screen using the current pen and fill colors.

Parámetros

Descripción

x

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.

width

El ancho del rectángulo.

height

La altura del rectángulo.

color

Optional. A valid ColorType, a hex value, or a web string. This is the fill color of the rectangle.

Devoluciones: Ninguna.

# Draw a green rectangle on the screen that is filled using blue.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_rectangle(10, 10, 20, 20)

# Draw a green rectangle on the screen that is filled using red.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.draw_rectangle(50, 50, 20, 20, Color.RED)

dibujar_círculo()#

The draw_circle(x, y, radius, color) method draws a circle using the current pen and fill colors.

Parámetros

Descripción

x

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.

radius

El radio del círculo.

color

Optional. A valid ColorType, a hex value, or a web string. This is the fill color of the circle.

Devoluciones: Ninguna.

# Draw a green circle on the Brain's screen that is filled using blue.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.set_fill_color(Color.BLUE)
brain.screen.draw_circle(50, 50, 10)

# Draw a green circle on the Brain's screen that is filled using red.
brain.screen.set_pen_color(Color.GREEN)
brain.screen.draw_circle(100, 50, 10, Color.RED)

dibujar_imagen_del_archivo()#

The draw_image_from_file(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

filename

El nombre del archivo de la imagen.

x

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.draw_image_from_file('vex.bmp', 0, 0)

pantalla.render()#

The render() method switches drawing to double buffered and renders the Brain’s screen. Once called, further drawing will not appear on the Brain’s screen until the next time render is called.

Devuelve: Verdadero si el búfer se representó correctamente en la pantalla.

establecer_región_de_clip()#

The set_clip_region(x, y, width, height) method sets the clip region for drawing the supplied rectangle.

Parámetros

Descripción

x

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.

width

El ancho del rectángulo.

height

La altura del rectángulo.

Devoluciones: Ninguna.