使用python画一个**10环圆靶**

10环圆靶

使用python画一个10环圆靶

在这里插入图片描述

import cv2
import numpy as np
i=11
dot_red=(300,300)   #圆心
black=(0,0,0)       #黑色
red = (0, 0, 255)   #红色
white=(255,255,255) #白色
blue=(255,0,0)      #蓝色
green=(0,255,0)      #绿色
gray=(185,188,178)  #灰色
font = cv2.FONT_HERSHEY_SIMPLEX #字体
yuan = np.zeros((600, 600, 3), np.uint8)
yuan[:]=255

while i>1:
    i=i-1
    #print(i)
    radius = (i*30)
    if i==10:
        cv2.circle(yuan, dot_red, radius, black, -1)
    elif i==9:
        cv2.circle(yuan, dot_red, radius, white, 1)
    elif i==8:
        cv2.circle(yuan, dot_red, radius, gray, -1)
    elif i==7:
        cv2.circle(yuan, dot_red, radius, black, 1)
    elif i==6:
        cv2.circle(yuan, dot_red, radius, blue, -1)
    elif i==5:
        cv2.circle(yuan, dot_red, radius, white, 1)
    elif i==4:
        cv2.circle(yuan, dot_red, radius, red, -1)
    elif i==3:
        cv2.circle(yuan, dot_red, radius, white, 1)
    elif i==2:
        cv2.circle(yuan, dot_red, radius, green, -1)
    elif i==1:
        cv2.circle(yuan, dot_red, radius, red, 1)

#显示字
a=1
b=1
x1 = 9
y1 = 310
x2=290
y2=27
while a>0:
    text = '%d' % a
    cv2.putText(yuan, text=text, org=(x1, y1), fontFace=font, fontScale=0.9, color=(255, 255, 255),
                thickness=1)  # text,
    if a == 10:
        a=a+0
    else:
        cv2.putText(yuan, text=text, org=(x2, y2), fontFace=font, fontScale=0.9, color=(255, 255, 255),
                thickness=1)  # text,
    x1=x1+30
    y2=y2+30
    if a==10:
        b=-1
        x1=x1+24
        y2=y2+24
    a = a + b

cv2.imshow('yuan', yuan)  # 显示图片
cv2.waitKey(0)
cv2.destroyAllWindows()
  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值