class Circle – display circle
Circle is the basic object type used to display text.
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8import time 9 10 11circle0 = None 12title0 = None 13 14 15import random 16 17 18def setup(): 19 global circle0, title0 20 21 M5.begin() 22 Widgets.fillScreen(0x222222) 23 circle0 = Widgets.Circle(63, 111, 15, 0xFFFFFF, 0xFFFFFF) 24 title0 = Widgets.Title("Circle Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18) 25 26 circle0.setVisible(True) 27 28 29def loop(): 30 global circle0, title0 31 M5.update() 32 circle0.setRadius(r=(random.randint(1, 30))) 33 circle0.setColor( 34 color=0x000000, 35 fill_c=(random.randint(0, 255) << 16) 36 | (random.randint(0, 255) << 8) 37 | random.randint(0, 255), 38 ) 39 circle0.setCursor(x=(random.randint(1, 320)), y=(random.randint(1, 240))) 40 time.sleep(0.5) 41 42 43if __name__ == "__main__": 44 try: 45 setup() 46 while True: 47 loop() 48 except (Exception, KeyboardInterrupt) as e: 49 try: 50 from utility import print_error_msg 51 52 print_error_msg(e) 53 except ImportError: 54 print("please update to latest firmware")
UIFLOW2 Example:
Constructors
- class Widgets.Circle(x: int, y: int, r: int, fg_color: int = 0xffffff, bg_color: int = 0xffffff)
Create a Circle object. It accepts the following parameters:
x
is the starting X-axis coordinate displayed.y
is the starting Y-axis coordinate displayed.r
is the radius of the circle.fg_color
is the foreground color of the displayed circle.bg_color
is the background color of the displayed circle.
Methods
- Widgets.setColor(fg_color: int = 0xffffff, bg_color: int = 0x000000)
Set the color of the Circle object. Accept the following parameters:
fg_color
is the foreground color of the displayed circle.bg_color
is the background color of the displayed circle.
UIFLOW2:
- Widgets.setCursor(x: int, y: int)
Set the position of the Circle object. Accept the following parameters:
x
is the starting X-axis coordinate displayed.y
is the starting Y-axis coordinate displayed.
UIFLOW2: