show | version | enable_checker |
---|---|---|
step |
1.0 |
true |
- 上次研究了
- 多边形的绘制与填色
- 还可以绘制各种字符效果
- 甚至可以加上衬线🤔
- 对了 好像我们也
- 可以直接输出字符的😳
- 直接输出字符会有什么好玩的吗?
- 以前的浏览器分辨率为640 * 480
- 字符数量为 80 * 24
- 80 来自于 IBM 打孔卡
- 80 * 24 来自于 VT-100的默认设置
import numpy as np
import cv2
canvas = np.zeros((480,640,3), np.uint8)
for x in range(81):
for y in range(25):
cv2.putText(canvas,"0",(x*8,y*20-1),cv2.FONT_HERSHEY_DUPLEX,0.4,(0,255,0),1)
cv2.imshow("PolyLines",canvas)
cv2.waitKey()
cv2.destroyAllWindows()
- 效果
- 可以显示其他数字吗?
import numpy as np
import cv2
canvas = np.zeros((480,640,3), np.uint8)
for x in range(81):
for y in range(25):
cv2.putText(canvas,str((y+x)%10),(x*8,y*20-1),cv2.FONT_HERSHEY_DUPLEX,0.4,(0,255,0),1)
cv2.imshow("PolyLines",canvas)
cv2.waitKey()
cv2.destroyAllWindows()
- 显示数字
- 可以让数字随机一点吗?
import numpy as np
import cv2
from random import randint
canvas = np.zeros((480,640,3), np.uint8)
for x in range(81):
for y in range(25):
r = randint(ord('0'),ord('0')+9)
cv2.putText(canvas,chr(r),(x*8,y*20-1),cv2.FONT_HERSHEY_DUPLEX,0.4,(0,255,0),1)
cv2.imshow("PolyLines",canvas)
cv2.waitKey()
cv2.destroyAllWindows()
- 效果
- 随机的可以是字母吗?
import numpy as np
import cv2
from random import randint
canvas = np.zeros((480,640,3), np.uint8)
for x in range(81):
for y in range(25):
r = randint(ord('a'),ord('a')+25)
cv2.putText(canvas,chr(r),(x*8,y*20-1),cv2.FONT_HERSHEY_DUPLEX,0.4,(0,255,0),1)
cv2.imshow("PolyLines",canvas)
cv2.waitKey()
cv2.destroyAllWindows()
- 字幕效果
- 可以显示符号吗?
import numpy as np
import cv2
from random import randint
canvas = np.zeros((480,640,3), np.uint8)
for x in range(81):
for y in range(25):
r = randint(20,127)
cv2.putText(canvas,chr(r),(x*8,y*20-1),cv2.FONT_HERSHEY_DUPLEX,0.4,(0,255,0),1)
cv2.imshow("PolyLines",canvas)
cv2.waitKey()
cv2.destroyAllWindows()
- 这次除了字母之外
- 还有符号
- 可以换颜色吗?
import numpy as np
import cv2
from random import randint
canvas = np.zeros((480,640,3), np.uint8)
for x in range(81):
for y in range(25):
r = randint(20,127)
color = np.random.randint(256,size=(3),dtype=np.uint8).tolist()
print(color)
cv2.putText(canvas,chr(r),(x*8,y*20-1),cv2.FONT_HERSHEY_DUPLEX,0.4,color,1)
cv2.imshow("PolyLines",canvas)
cv2.waitKey()
cv2.destroyAllWindows()
- 效果
- 可以试试做出黑客帝国中
- 字符雨的效果吗?
- 这次研究了面向传统终端的图片生成效果
- 80 * 24 字符
- 640 * 480 像素
- 其中
- 字体、颜色都可以进行修改
- 除了终端显示其之外
- 可以让鼠标键盘参与图像生成吗?🤡
- 下次再说👋