Welcome to K210 Module repository
1.Draw graphics
1 Draw graphics
1 Draw graphics1.1 experimental goals1.2 experimental procedure1.3 experimental results1.4 experiment summary
1.1 experimental goals
In this lesson, you will learn how to draw graphics, including drawing lines, circles, and rectangles.
The reference code path for this experiment :CanMV04-GUIgeometric.py
1.2 experimental procedure
The factory firmware of the module has integrated lcd and image modules. If you have downloaded other firmware, please burn it back to the factory firmware before experimenting.
Import lcd and image.
import lcd, image
Initialize the lcd and image, fill the background color with (0, 81, 137)
xxxxxxxxxxlcd.init()img = image.Image(size=(lcd.width(), lcd.height()))img.draw_rectangle((0, 0, lcd.width(), lcd.height()), fill=True, color=(0, 81, 137))
Display the string "Hello Yahboom" at (50,10), draw a line at (50,50), a rectangle at (50,60), and a circle at (125,135).
xxxxxxxxxximg.draw_string(50, 10, "Hello Yahboom", color=(255, 255, 255), scale=2)img.draw_line(50, 50, 200, 50, color=(100, 0, 0), thickness=5)img.draw_rectangle(50, 60, 150, 150, color=(0, 100, 0), thickness=2, fill=True)img.draw_circle(125, 135, 50, color=(255, 255, 255), thickness=2, fill=False)
Finally, img is displayed on the LCD screen.
xxxxxxxxxxlcd.display(img)
1.3 experimental results
Connect the K210 module to the computer through the microUSB data cable, CanMV IDE click the connect button, after the connection is completed click the Run button to run the routine code. You can also download the code as main.py and run it in the K210 module.
You can see the string "Hello Yahboom" on the LCD display, along with a line, a rectangle, and a circle.

1.4 experiment summary
Use CanMV IDE, with the factory firmware write a good MicroPython syntax, can be very convenient to draw a graph out of it.