猫史档案馆


【Python作品分享】3D 【作品秀】

用户:描绘彩虹描绘彩虹查看:0 回复:0 评论:0 创建时间:2023-01-16T19:20:08


【作品展示】

center_image

 

【作品介绍】

海龟画图

 

【作品源代码】

import turtle
import random
import time


turtle.pensize(3)
turtle.pencolor('blue')
焦距 = 100
tz = random.randint(27, 喵)
ty = random.randint((-100), 100)
tx = random.randint((-100), 100)

def 去到(x, y, z):

    turtle.goto((焦距 * ((x + tx) / (z + tz))), (焦距 * ((y + ty) / (z + tz))))

def 渲染():

    turtle.penup()
    去到((-50), (-50), 30)
    turtle.pendown()
    去到(50, (-50), 30)
    去到(50, 50, 30)
    去到((-50), 50, 30)
    去到((-50), (-50), 30)
    turtle.penup()
    去到((-50), (-50), 0)
    turtle.pendown()
    去到(50, (-50), 0)
    去到(50, 50, 0)
    去到((-50), 50, 0)
    去到((-50), (-50), 0)
    turtle.penup()
    去到((-50), (-50), 0)
    turtle.pendown()
    去到((-50), (-50), 30)
    turtle.penup()
    去到(50, (-50), 0)
    turtle.pendown()
    去到(50, (-50), 30)
    turtle.penup()
    去到(50, 50, 0)
    turtle.pendown()
    去到(50, 50, 30)
    turtle.penup()
    去到((-50), 50, 0)
    turtle.pendown()
    去到((-50), 50, 30)
    turtle.penup()


渲染()
turtle.hideturtle()
time.sleep(5)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页