Screen#
print()#
The print(value, format, ...)
method prints text on the screen using the current cursor position.
Parameters |
Description |
---|---|
value |
The text to print. |
format |
A format specifier to be used when printing the value of variables. |
… |
A variable list of parameters to be printed with the format specifier. |
Returns: None.
// Print the number 1 on the Brain's screen at current
// cursor position.
Brain.Screen.print(1);
printAt()#
The printAt(text, x, y, format, precision, ...)
method prints text at a specific x and y coordinates on the screen.
Parameters |
Description |
---|---|
value |
The text to print. |
x |
The x position to print at as a keyword argument (x=), referenced to the screen origin. |
y |
The y position to print at as a keyword argument (y=), referenced to the screen origin. |
format |
A format specifier to be used when printing the value of variables. |
… |
A variable list of parameters to be printed with the format specifier. |
Returns: None.
// Print the number 1 on the Brain's screen at
// position (100, 40).
Brain.Screen.printAt(1, x=100, y=40);
setCursor()#
The setCursor(x, y)
method sets the cursor position. The row and column spacing will take into account the selected font. The base cell size if 10x20 pixels for the MONO20
font. The top, left corner of the screen is position (x=1
, y=1
).
Parameters |
Description |
---|---|
x |
The x position of the cursor. |
y |
The y position of the cursor. |
Returns: None.
setOrigin()#
The setOrigin(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.
Parameters |
Description |
---|---|
x |
The origin’s x position relative to top left corner. |
y |
The origin’s y position relative to top left corner. |
Returns: None.
setFont()#
The setFont(fontname)
method sets the font type used for printing text on the Brain’s screen.
Parameters |
Description |
---|---|
fontname |
A valid FontType. |
Returns: None.
// Set the font type to mono40.
Brain.Screen.setFont(fontType::mono40);
setPenWidth()#
The setPenWidth(width)
method sets the pen width used for drawing lines, rectangles and circles.
Parameters |
Description |
---|---|
width |
The pen width. |
Returns: None.
// Set the pen width to 5 pixels.
Brain.Screen.setPenWidth(5);
setPenColor()#
The pen color can be set in two ways:
The setPenColor(color)
method sets the pen color with the specified color.
Parameters |
Description |
---|---|
color |
Either a previously defined colorType object or a Hex value. |
Returns: None.
// Set pen color red using a Hex value.
Brain.Screen.setPenColor(0xFF0000);
// Set pen color blue using a predefined color.
Brain.Screen.setPenColor(blue);
// Set pen color green using a web string.
Brain.Screen.setPenColor("#00FF00");
The setPenColor(hue)
method sets the pen color with the specified hue.
Parameters |
Description |
---|---|
hue |
An integer representing the hue of the color, from 1 - 359. |
Returns: None.
setFillColor()#
The fill color can be set in two ways:
The setFillColor(color)
method sets the fill color with the specified color.
Parameters |
Description |
---|---|
color |
Either a previously defined colorType object or a Hex value. |
Returns: None.
// Set pen color red using a hex value.
Brain.Screen.setFillColor(0xFF0000);
// Set pen color blue using a predefined color.
Brain.Screen.setFillColor(blue);
// Set pen color green using a web string.
Brain.Screen.setFillColor("#00FF00");
The setFillColor(hue)
method sets the fill color with the specified hue.
Parameters |
Description |
---|---|
hue |
An integer representing the hue of the color, from 1 - 359. |
Returns: None.
column()#
The column()
method returns the current column where text will be printed.
Returns: The current column position.
row()#
The row()
method returns the current row where text will be printed.
Returns: The current row position.
getStringWidth()#
The getStringWidth(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.
Parameters |
Description |
---|---|
string |
The string to measure. |
Returns: The width of the string as an integer.
getStringHeight()#
The getStringHeight(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.
Parameters |
Description |
---|---|
string |
The string to measure. |
Returns: The height of the string as an integer.
clearScreen()#
The Brain’s screen can be cleared in three ways:
The clearScreen()
method clears the Brain’s screen to the default color (black).
Returns: None.
// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode");
// Clear screen to black.
Brain.Screen.clearScreen();
The clearScreen(color)
method clears the whole Brain’s screen to a specified color.
Parameters |
Description |
---|---|
color |
Either a previously defined colorType object or a Hex value. |
Returns: None.
// Print VEXcode on the Brain's screen.
Brain.Screen.print("VEXcode");
// Clear screen to blue using a predefined color.
Brain.Screen.clearScreen(blue);
The clearScreen(hue)
method clears the whole Brain’s screen to a specified hue.
Parameters |
Description |
---|---|
hue |
An integer representing the hue of the color, from 1 - 359. |
Returns: None.
clearLine()#
Lines can be cleared on the Brain’s screen in four ways:
The clearLine()
method clears the row where the cursor is currently located.
Returns: None.
The clearLine(number)
method clears a specified row.
Parameters |
Description |
---|---|
number |
The row to clear. |
Returns: None.
The clearLine(number, color)
method clears a specified row and sets the row to a specified color.
Parameters |
Description |
---|---|
number |
The row to clear. |
color |
Either a previously defined color object or a Hex value. |
Returns: None.
The clearLine(number, hue)
method clears a specified row and sets the row to a specified hue.
Parameters |
Description |
---|---|
number |
The row to clear. |
hue |
An integer representing the hue of the color, from 1 - 359. |
Returns: None.
newLine()#
The newLine()
method moves the cursor to the next row.
Returns: None.
drawPixel()#
The drawPixel(x, y)
method draws a pixel using the current pen color.
Parameters |
Description |
---|---|
x |
The x position to draw the pixel referenced to the screen origin. |
y |
The y position to draw the pixel referenced to the screen origin. |
Returns: None.
// Draw a red pixel on the Brain's screen.
Brain.Screen.setPenColor(red);
Brain.Screen.drawPixel(10, 10);
drawLine()#
The drawLine(x1, y1, x2, y2)
method draws a line using the current pen color.
Parameters |
Description |
---|---|
x1 |
The x position of the start of the line referenced to the screen origin. |
y1 |
The y position of the start of the line referenced to the screen origin. |
x2 |
The x position of the end of the line referenced to the screen origin. |
y2 |
The y position of the end of the line referenced to the screen origin. |
Returns: None.
// Draw a red line on the Brain's screen.
Brain.Screen.setPenColor(red);
Brain.Screen.drawLine(10, 10, 20, 20);
drawRectangle()#
A rectangle can be drawn on the Brain’s screen in three ways:
The drawRectangle(x, y, width, height)
method draws a rectangle on the screen using the current pen and fill colors.
Parameters |
Description |
---|---|
x |
The x position of the top-left corner of the rectangle referenced to the screen origin. |
y |
The y position of the top-left corner of the rectangle referenced to the screen origin. |
width |
The width of the rectangle. |
height |
The height of the rectangle. |
Returns: None.
// Draw a green rectangle on the screen that is
// filled using blue.
Brain.Screen.setPenColor(green);
Brain.Screen.setFillColor(blue);
Brain.Screen.drawRectangle(10, 10, 20, 20);
The drawRectangle(x, y, width, height, color)
method draws a rectangle on the screen using the current pen and fills the circle with the specified color.
Parameters |
Description |
---|---|
x |
The x position of the top-left corner of the rectangle referenced to the screen origin. |
y |
The y position of the top-left corner of the rectangle referenced to the screen origin. |
width |
The width of the rectangle. |
height |
The height of the rectangle. |
color |
Either a previously defined color object or a Hex value. |
Returns: None.
The drawRectangle(x, y, width, height, hue)
method draws a rectangle on the screen using the current pen and fills the circle with the specified hue.
Parameters |
Description |
---|---|
x |
The x position of the top-left corner of the rectangle referenced to the screen origin. |
y |
The y position of the top-left corner of the rectangle referenced to the screen origin. |
width |
The width of the rectangle. |
height |
The height of the rectangle. |
hue |
An integer representing the hue of the color, from 1 - 359. |
Returns: None.
drawCircle()#
A circle can be drawn on the Brain’s screen in three ways:
The drawCircle(x, y, radius)
method draws a circle using the current pen and fill colors.
Parameters |
Description |
---|---|
x |
The x position of the circle center referenced to the screen origin. |
y |
The y position of the circle center referenced to the screen origin. |
radius |
The radius of the circle in pixels. |
Returns: None.
// Draw a green circle on the Brain's screen that is
// filled using blue.
Brain.Screen.setPenColor(green);
Brain.Screen.setFillColor(blue);
Brain.Screen.drawCircle(50, 50, 10);
The drawCircle(x, y, radius, color)
method draws a circle using the current pen color and fills the circle with the specified color.
Parameters |
Description |
---|---|
x |
The x position of the circle center referenced to the screen origin. |
y |
The y position of the circle center referenced to the screen origin. |
radius |
The radius of the circle in pixels. |
color |
Either a previously defined color object or a Hex value. |
Returns: None.
The drawCircle(x, y, radius, hue)
method draws a circle using the current pen color and fills the circle with the specified hue.
Parameters |
Description |
---|---|
x |
The x position of the circle center referenced to the screen origin. |
y |
The y position of the circle center referenced to the screen origin. |
radius |
The radius of the circle in pixels. |
hue |
An integer representing the hue of the color, from 1 - 359. |
Returns: None.
drawImageFromBuffer()#
The drawImageFromBuffer(buffer, x, y, width, height)
method draws an image on the screen using the contents of the memory buffer.
Parameters |
Description |
---|---|
buffer |
A pointer to a buffer containing raw 32-bit per pixel image data. |
x |
The x-coordinate at which the left edge of the image will be drawn. |
y |
The y-coordinate at which the top edge of the image will be drawn. |
width |
The width of the image. |
height |
The height of the image. |
Returns: A boolean indicating if the image was successfully drawn on the screen.
drawImageFromFile()#
The drawImageFromFile(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.
Parameters |
Description |
---|---|
filename |
The filename of the image. |
x |
The x coordinate for the top-left corner of the image on the screen. |
y |
The y coordinate for the top-left corner of the image on the screen. |
Returns: None.
// Draw the vex.bmp image on the Brain's screen at
// coordinate 0, 0.
Brain.Screen.drawImageFromFile('vex.bmp', 0, 0);
render()#
The screen can be buffered in two ways:
The render()
method switches to double buffering or renders the back buffer to the Brain’s screen.
Returns: true
if buffer was successfully rendered to the screen.
The render(bSyncWait, bRunScheduler)
method switches to double buffering or renders the back buffer to the Brain’s screen, with options to wait for the Vsync signal before proceeding and to run the scheduler during the process.
Parameters |
Description |
---|---|
bSyncWait |
|
bRunScheduler |
|
Returns: true
if buffer was successfully rendered to the screen.
setClipRegion()#
The setClipRegion(x, y, width, height)
method sets the clip region for drawing the supplied rectangle.
Parameters |
Description |
---|---|
x |
The x position of the top-left corner of the rectangle, referenced to the screen origin. |
y |
The y position of the top-left corner of the rectangle, referenced to the screen origin. |
width |
The width of the rectangle. |
height |
The height of the rectangle. |
Returns: None.