1. Drawing Experiment
About 1 min
Routine Code
import lcd, image
lcd.init()
img = image.Image(size=(lcd.width(), lcd.height()))
img.draw_rectangle((0, 0, lcd.width(), lcd.height()), fill=True, color=(0, 81, 137))
img.draw_string(50, 10, "Hello", 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)
lcd.display(img)Experiment Preparation
- Connect the K210 to your computer via USB.
- Open CanMV IDE and run the routine code above.
Experiment Results
After running, the K210 LCD screen displays the following pattern:

Routine Code Explanation
- Import the modules required to run the routine.
import lcd, image- Initialize the LCD screen.
lcd.init()- Create an image object the same size as the LCD screen.
img = image.Image(size=(lcd.width(), lcd.height()))- Draw a filled rectangle covering the entire image area. Parameters: (top-left x, top-left y, bottom-right x, bottom-right y).
fill=Truemeans fill the shape;colorspecifies the color (RGB value (0, 81, 137) here).
- Draw a filled rectangle covering the entire image area. Parameters: (top-left x, top-left y, bottom-right x, bottom-right y).
img.draw_rectangle((0, 0, lcd.width(), lcd.height()), fill=True, color=(0, 81, 137))- Draw the string "Hello" at position (x=50, y=10).
colorsets the text color to white (RGB (255, 255, 255));scale=2sets the font scale factor to 2.
- Draw the string "Hello" at position (x=50, y=10).
img.draw_string(50, 10, "Hello", color=(255, 255, 255), scale=2)- Draw a line on the image. Parameters: (start x, start y, end x, end y).
coloris RGB (100, 0, 0);thickness=5sets line width to 5 pixels.
- Draw a line on the image. Parameters: (start x, start y, end x, end y).
img.draw_line(50, 50, 200, 50, color=(100, 0, 0), thickness=5)- Draw a rectangle on the image. Parameters: (top-left x, top-left y, bottom-right x, bottom-right y).
coloris RGB (0, 100, 0);thickness=2sets border width to 2 pixels;fill=Truefills the shape.
- Draw a rectangle on the image. Parameters: (top-left x, top-left y, bottom-right x, bottom-right y).
img.draw_rectangle(50, 60, 150, 150, color=(0, 100, 0), thickness=2, fill=True)- Draw a circle on the image. Parameters: (center x, center y, radius).
coloris white (RGB (255, 255, 255));thickness=2sets border width to 2 pixels;fill=Falseleaves the interior unfilled.
- Draw a circle on the image. Parameters: (center x, center y, radius).
img.draw_circle(125, 135, 50, color=(255, 255, 255), thickness=2, fill=False)- Display the drawn image on the LCD screen.
lcd.display(img)