Dibujo#

Introducción#

El robot de realidad virtual usa un lápiz para dibujar en un área de juego mientras se mueve. El lápiz del robot puede cambiar de ancho y color, y llenar áreas de juego enteras.

A continuación se muestra una lista de todos los bloques disponibles:

Acciones: Cambiar el estado del lápiz y los colores de relleno de los patios de juegos y otros dibujos.

  • move – Raise or lower the robot’s pen.

  • fill – Fill a playground or an enclosed area with a specified color.

Mutadores: modifican el color y el ancho del lápiz.

  • set_pen_color – Set the color of the robot’s pen from preset options.

  • set_pen_width – Set the width of the robot’s pen.

  • set_pen_color_rgb – Set the color of the robot’s pen with red, green, and blue values.

Comportamiento#

move#

move sets the position of the VR Pen.

Usage:
pen.move(action)

Parámetros

Descripción

action

The set position of the VR Pen:

  • DOWN – Allows the pen to draw on the playground.
  • UP – Stops the pen from drawing on the playground.
def main():
    # Draw a straight line.
    pen.move(DOWN)
    drivetrain.drive_for(FORWARD, 400, MM)

# VR threads — Do not delete
vr_thread(main)

fill#

fill fills in the shape of whatever the VR Pen is on top of, for example:

El robot de realidad virtual está situado sobre una superficie con pequeñas cuadrículas, de las que se ve una línea azul detrás del robot.

Una esquina de un entorno de juego de realidad virtual, donde se ve el cuadrado de la cuadrícula de la esquina relleno de azul, con el robot de realidad virtual en el cuadrado contiguo.

Un robot de realidad virtual sobre un suelo azul sólido.

Líneas de cuadrícula

Cuadrícula

En los patios de juego sin cuadrícula, ocupa todo el piso del patio de juegos.

Usage:
pen.fill(red, green, blue, opacity)

Parámetros

Descripción

red

La intensidad del color rojo en el valor RGB, que va de 0 a 255.

green

La intensidad del color verde en el valor RGB, que va de 0 a 255.

blue

La intensidad del color azul en el valor RGB, que va de 0 a 255.

opacity

La transparencia del color del VR Pen, que varía entre 0 y 100 por ciento.

def main():
    # Fill the playground's floor with blue at full opacity.
    pen.fill(43, 162, 202, 100)

# VR threads — Do not delete
vr_thread(main)

Mutadores#

set_pen_color#

set_pen_color sets the color of the VR Pen from preset options.

Usage:
pen.set_pen_color(color)

Parámetros

Descripción

color

The color of the VR Pen: BLACK, RED, GREEN, or BLUE.

def main():
    # Draw a blue line
    pen.move(DOWN)
    pen.set_pen_color(BLUE)
    drivetrain.drive_for(FORWARD, 400, MM)

# VR threads — Do not delete
vr_thread(main)

set_pen_width#

set_pen_width method is used to set the width of the VR Pen.

Usage:
pen.set_pen_width(width)

Parámetros

Descripción

width

The width of the VR Pen:

  • EXTRA_THIN
  • THIN (default)
  • MEDIUM
  • WIDE
  • EXTRA-WIDE
def main():
    # Draw a straight line of medium width
    pen.move(DOWN)
    pen.set_pen_width(MEDIUM)
    drivetrain.drive_for(FORWARD, 400, MM)

# VR threads — Do not delete
vr_thread(main)

set_pen_color_rgb#

set_pen_color_rgb method is used to set the RGB and opacity values for the VR Pen’s color.

Usage:
pen.set_pen_color_rgb(red, green, blue, opacity)

Parámetros

Descripción

red

La intensidad del color rojo en el valor RGB, que va de 0 a 255.

green

La intensidad del color verde en el valor RGB, que va de 0 a 255.

blue

La intensidad del color azul en el valor RGB, que va de 0 a 255.

opacity

La transparencia del color del VR Pen, que varía entre 0 y 100 por ciento.

def main():
    # Draw an orange line
    pen.move(DOWN)
    pen.set_pen_color_rgb(225, 112, 52, 100)
    drivetrain.drive_for(FORWARD, 400, MM)

# VR threads — Do not delete
vr_thread(main)