Display Functions The EV3 display (an LCD panel) is 178 pixels wide by 128 pixels tall. The origin point (0, 0) is at the upper left corner. The following functions allow you to draw text and shapes at specific locations on the EV3 display.
The display functions include:
clearScreen()
Parameters: None
Action Performed: Clears the screen
Example:
clearScreen()
drawText(20, 50, 'Hello World!', 2)
sleep(4000)
drawText()
Required parameters: x, y, text
Optional parameter: font size (0, 1, 2)
Action Performed: Draws text on the screen at the specified x and y coordinate
Example:
clearScreen()
drawText(20, 20, 'Hello World!', 2)
drawText(20, 50, 'This is a test', 1)
drawText(20, 80, 'This is small text')
sleep(4000)
Example 2:
// This is an example of a count down timer
clearScreen()
for(i=10; i<=0; i--) {
drawText(20, 20, i, 2)
sleep(1000)
}
drawText(5, 20, 'Blast Off', 2)
sleep(4000)
circle()
Required parameters: x, y, radius
Action Performed: Draws a circle on the screen at the specified
x and y coordinate with the specified radius
Example:
clearScreen()
circle(85, 65, 20)
sleep(4000)
fillCircle()
Required parameters: x, y, radius
Action Performed: Draws a filled circle on the screen at the specified
x and y coordinate with the specified radius
Example:
clearScreen()
fillCircle(85, 65, 20)
sleep(4000)
clearCircle()
Required parameters: x, y, radius
Action Performed: Erases the screen in the shape of a circle at the specified
x and y coordinate with the specified radius
Example:
clearScreen()
fillCircle(85, 65, 20)
clearCircle(105, 65, 20)
sleep(4000)
rect()
Required parameters: x, y, width, height
Action Performed: Draws a rectangle with the specified
x and y coordinate in the upper left corner.
Example:
clearScreen()
rect(30, 30, 90, 60)
sleep(4000)
fillRect()
Required parameters: x, y, width, height
Action Performed: Draws a filled rectangle with the specified
x and y coordinate in the upper left corner.
Example:
clearScreen()
fillRect(30, 30, 90, 60)
sleep(4000)
clearRect()
Required parameters: x, y, width, height
Action Performed: Clears the screen in the shape of a rectangle with the specified
x and y coordinate in the upper left corner.
Example:
clearScreen()
fillRect(30, 30, 90, 60)
clearRect(30, 30, 20, 10)
clearRect(85, 65, 90, 20)
sleep(4000)
line()
Required parameters: x1, y1, x2, y2
Action Performed: Draws a line from coordinate (x1, y1) to (x2, y2).
Example:
clearScreen()
line(30, 30, 90, 60)
line(50, 30, 120, 60)
line(85, 65, 90, 20)
sleep(4000)