程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python turtle library drawing (with source code)

編輯:Python

The first 1 Kind of :
Before that you need a picture , Name it img.png( Of course, you can also change the image path in the code ), Pictures and python Code in the same directory ( Or the photo path in the code is an absolute path ).

Complete code 1:

import turtle as t
import cv2
t.getscreen().colormode(255)
img1 = cv2.imread('img.png')[0: -2: 2]
width = len(img1[0])
height = len(img1)
t.setup(width=width / 2 + 100, height=height + 100)
t.pu()
t.goto(-width / 4 + 10, height / 2 - 10)
t.pd()
t.tracer(2000)
for k1, i in enumerate(img1):
for j in i[::2]:
t.pencolor((j[0], j[1], j[2]))
t.fd(1)
t.pu()
t.goto(-width / 4 + 10, height / 2 - 10 - k1 - 1)
t.pd()
t.done()


If this error occurs , Please install opencv-python library .
Can be in terminal Enter the following code , It can also be used. pycharm Direct installation .

pip install opencv-python

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved