首页 > 分享 > 【python】turtle龟绘制开了花朵的树,程序画图

【python】turtle龟绘制开了花朵的树,程序画图

天啊,没想到python龟绘制的图居然这么美腻!

代码传送门:

import turtle

import random

from turtle import *

from time import sleep

t = turtle.Turtle()

w = turtle.Screen()

def tree(branchLen, t):

if branchLen > 3:

if 8 <= branchLen <= 12:

if random.randint(0, 2) == 0:

t.color('snow')

else:

t.color('lightcoral')

t.pensize(branchLen / 3)

elif branchLen < 8:

if random.randint(0, 1) == 0:

t.color('snow')

else:

t.color('lightcoral')

t.pensize(branchLen / 2)

else:

t.color('sienna')

t.pensize(branchLen / 10)

t.forward(branchLen)

a = 1.5 * random.random()

t.right(20*a)

b = 1.5 * random.random()

tree(branchLen-10*b, t)

t.left

相关知识

python turtle玫瑰花绘制效果和源代码
python 玫瑰花程序
【Python实用工具】(情人节献礼)turtle函数绘制动态玫瑰花
python玫瑰花代码讲解
python玫瑰花代码简单
玫瑰花的python程序代码
海龟画图 python太阳花
python 3:turtle图形库,绘制简单的图形
Python编程实现花卉图案绘制与色彩搭配技巧详解
python画玫瑰花代码简单

网址: 【python】turtle龟绘制开了花朵的树,程序画图 https://m.huajiangbk.com/newsview467133.html

所属分类:花卉
上一篇: 【喀喇沁旗世杰花卉种子繁育基地招
下一篇: 花种,花籽,花种批发,花卉种子,