效果图如上:
# 画圆和画椭圆的联合作战
WINDOW_WIDTH = 200 #定义窗口大小
def DrawDilledCircle(img,center):
thickness = -1
lineType=8
color = (0, 0, 255) #BGR
cv.circle(img, center, WINDOW_WIDTH//32, color, thickness, lineType)
def DrawEllipse(img,angle):
thickness = 2
lineType = 8
color = (255, 129, 0)
pt =(WINDOW_WIDTH//2, WINDOW_WIDTH//2)
size=(WINDOW_WIDTH//4, WINDOW_WIDTH//16)
cv.ellipse(img, pt, size, angle, 0, 360, color, thickness, lineType)
h = WINDOW_WIDTH
w = WINDOW_WIDTH
atomImage=np.zeros((h, w, 3), np.int8)
rookImage=np.zeros((h, w, 3), np.int8)
# 绘制椭圆
DrawEllipse(atomImage, 90)
DrawEllipse(atomImage, 0)
DrawEllipse(atomImage, 45)
DrawEllipse(atomImage, -45)
# 绘制圆心
DrawDilledCircle(atomImage, (WINDOW_WIDTH//2, WINDOW_WIDTH//2))
cv.imshow('result', atomImage)
cv.waitKey(0)