Coding the Pen of the VR Robot

VEXcode VR workspace showing the VR Robot, code blocks, and pen controls for drawing on the Playground

There are many commands used to code the Pen of the VR Robot:

  • Set Pen color
  • Set Pen width
  • Fill area with color

Set Pen Color

VEXcode VR showing pen blocks and the VR Robot on the Playground

The Set Pen color command sets the color of the VR Pen.

VEXcode VR workspace with pen-related blocks and the VR Robot configuration options

VEXcode VR Blocks

Using the sliders, select the red, green, and blue values for the color you want to create. The numeric value will be listed next to the color (0 to 255).

Opacity describes the transparency of the color. The opacity of the pen color can be selected using the bottom slider.

The color window will update to show the final color the pen will draw on the Playground. In this example, the pen would draw a red color with a lower opacity.

The color will also appear at the top of the pen once the project is run.

VEXcode VR workspace showing the VR Robot and coding blocks used to control the pen tool

VEXcode VR Python

The color of the pen is specified with: rgb values (red, green, blue).

Each parameter (red, green, and blue) defines the intensity of the color as an integer between 0 and 255.

The opacity describes the transparency of the color. Opacity is set using a value from 0 to 100 percent. This command will default to 100 percent for the opacity.

The color will also appear at the top of the pen once the project is run. In this example, the pen would draw a red color with a lower opacity.

VEXcode VR workspace with the Pen category open, showing pen control blocks for the VR Robot

Note that you cannot draw on the gray border on all four sides of the Art Canvas+ Playground. If you try to draw on this border, the line or patch of color will be cut off where the border is.


Set Pen Width

Comparison of pen width settings showing thin, medium, and thick lines drawn by the VR Robot

The Set Pen width command sets the width of the line the VR Pen will draw on the canvas.

This example was created using all five pen widths. It begins with the 'extra thin' at the left and moves in order through the 'extra wide' at the right.

VEXcode VR workspace showing the VR Robot pen controls and coding blocks for drawing on the playground

VEXcode VR Blocks

Select the dropdown on the block to choose between the five Pen widths.

The default width is 'thin,' which is the blue line in this example.

VEXcode VR workspace showing block-based and Python coding options for controlling the VR Robot pen

VEXcode VR Python

Select one of the following five values for the VR Pen width.

  • EXTRA_THIN
  • THIN
  • MEDIUM
  • WIDE
  • EXTRA_WIDE

The default width is 'thin,' which is the blue line in this example.


Fill Area With Color

VEXcode VR interface showing the VR Robot and coding blocks for controlling the pen tool

The Fill area with color command uses the VR Pen to fill an area of the Playground with a specified color.

VEXcode VR workspace showing the Art Canvas playground and pen blocks for drawing with the VR Robot

VEXcode VR Blocks

Using the sliders, select the red, green, and blue values for the fill color you want to create. The numeric value will be listed next to the color (0 to 255).

Opacity describes the transparency of the color. The opacity of the fill color can be selected using the bottom slider.

The color window will update to show the fill color on the Playground. In this example, the pen would fill the Playground with a teal color.

Note that the Pen does not have to be set to 'down' in order to use the [Fill area with color] block.

VEXcode VR Playground with the VR Robot and pen controls visible

VEXcode VR Python

The color of the fill is specified with rgb values (red, green, blue) and opacity.

Each parameter (red, green, and blue) defines the intensity of the color as an integer between 0 and 255.

The opacity describes the transparency of the color. Opacity is set using a value from 0 to 100 percent. This command will default to 100 percent for the opacity.

Note that the Pen does not have to be set to 'DOWN' in order to use the fill command.

VEXcode VR workspace showing the Pen blocks and the VR Robot in the playground.

The Fill area with color command can also be used with different images on the Playground canvas to color in separate areas with different colors. 

All of the examples here have been shown on the Art Canvas+ Playground. For more information on using the Playground Window in Art Canvas+, view this article

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: