描画#
導入#
VRロボットは、移動しながらペンを使って遊び場に絵を描く。ロボットのペンは太さや色を変えることができ、遊び場全体を塗りつぶすことも可能だ。
以下は利用可能なブロックの一覧です。
アクション – ペンの状態や、遊び場やその他の絵の塗りつぶしの色を変更します。
ミューテーター – ペンの色と幅を変更します。
set_pen_color– ロボットのペンの色をプリセットオプションから設定します。set_pen_width– ロボットのペンの幅を設定します。set_pen_color_rgb– ロボットのペンの色を赤、緑、青の値で設定します。
行動#
move#
move はVRペンの位置を設定します。
Usage:
pen.move(action)
パラメータ |
説明 |
|---|---|
|
VRペンの設定位置:
|
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ペンが置かれているものの形状に合わせて塗りつぶします。例:
グリッド線 |
グリッドスクエア |
格子状のレイアウトがない遊び場では、遊び場の床面全体を覆う。 |
Usage:
pen.fill(red, green, blue, opacity)
パラメータ |
説明 |
|---|---|
|
RGB値における赤色の強度を表し、0から255までの範囲をとります。 |
|
RGB値における緑色の強度。0から255までの範囲で表されます。 |
|
RGB値における青色の強度。0から255までの範囲で表されます。 |
|
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)
パラメータ |
説明 |
|---|---|
|
The color of the VR Pen: |
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)
パラメータ |
説明 |
|---|---|
|
VRペンの幅:
|
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)
パラメータ |
説明 |
|---|---|
|
RGB値における赤色の強度を表し、0から255までの範囲をとります。 |
|
RGB値における緑色の強度。0から255までの範囲で表されます。 |
|
RGB値における青色の強度。0から255までの範囲で表されます。 |
|
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)


