繪畫#

介紹#

這款VR機器人使用一支筆在遊樂場上移動邊作畫。機器人的筆可以改變粗細、顏色,並能覆蓋整個遊樂場。

以下是所有可用模組的清單:

操作-改變畫筆狀態以及遊樂場和其他圖畫的填滿顏色。

  • move – 升高或降低機器人的圍籬。

  • fill – 以指定的顏色填滿操場或封閉區域。

修改器 – 修改畫筆的顏色和粗細。

行動#

move#

move 設定 VR 筆的位置。

Usage:
pen.move(action)

參數

描述

action

VR筆的設定位置:

  • DOWN – 允許筆在遊樂場上繪製。 4
  • UP – 停止筆在遊樂場上繪製

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 填滿 VR 筆所在物體的形狀,例如:

​VR 機器人位於一個有小網格的表面上,機器人後面可以看到一條藍色的網格線。

​VR 遊樂場的一角,圖中顯示了藍色填充的角落網格方格,旁邊方格內是 VR 機器人。

​一個虛擬實境機器人站在純藍色的地板上。

網格線

網格方塊

在沒有格子的操場上,它會鋪滿整個操場地面。

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

參數

描述

red

RGB 值中紅色顏色的強度,範圍從 0 到 255。

green

RGB 值中綠色的強度,範圍從 0 到 255。

blue

RGB 值中藍色的強度,範圍從 0 到 255。

opacity

VR筆顏色的透明度,範圍從0%到100%。

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)

變異體#

set_pen_color#

set_pen_color 從預設選項中設定 VR 筆的顏色。

Usage:
pen.set_pen_color(color)

參數

描述

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 方法用來設定 VR 筆的寬度。

Usage:
pen.set_pen_width(width)

參數

描述

width

VR筆的寬度:

  • EXTRA_THIN
  • THIN (預設)
  • 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 方法用於設定 VR 筆顏色的 RGB 和不透明度值。

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

參數

描述

red

RGB 值中紅色顏色的強度,範圍從 0 到 255。

green

RGB 值中綠色的強度,範圍從 0 到 255。

blue

RGB 值中藍色的強度,範圍從 0 到 255。

opacity

VR筆顏色的透明度,範圍從0%到100%。

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)