基本上,我在圆的轮廓上每隔 3° 绘制一个带有点的多边形,然后我在圆的内部和外部都这样做了,然后所有点都连接起来,形成了一个抗锯齿的粗圆。我也将它用于弧
def arc(center, xradius, yradius, start_angle, stop_angle, color=BLACK)
arc_length = (stop_angle - start_angle) # Arc length
segment_length = math.radians(3) * min(xradius, yradius) # Length of one segment
segment_length = max((segment_length, 2)) # Minimum length of 2
nb_pts = int(arc_length/2*xradius*yradius / segment_length) + 1 # Nb points
angle = arc_length / (nb_pts-1) # Angle between each points
points = []
width = line_width//2 # Line thickness (half on each side of the circle)
for i in range(nb_pts): # Inner border
x = round(math.cos(start_angle + angle*i) * (xradius-width) + center[0])
y = round(-math.sin(start_angle + angle*i) * (yradius-width) + center[1]) # - is for counter clockwise
points.append((x, y)) # Add point
for i in range(nb_pts-1, -1, -1): # Outer border
x = round(math.cos(start_angle + angle*i) * (xradius+width) + center[0])
y = round(-math.sin(start_angle + angle*i) * (yradius+width) + center[1])
points.append((x, y)) # Add point
polygon(points, color, True) # True is for filled polygon
我调用这样的函数来绘制一个圆,将 xradius 和 yradius 更改为椭圆
arc(center, radius, radius, 0, 2*math.pi, color)