文章目录
前言
今天我们来画一朵玫瑰花。
一、第一种画法
这应该是最好看玫瑰花了。
from turtle import *#设置绘制起点setup (700,700)#画笔颜色pencolor("red")hideturtle()penup()goto(0,280)pendown()left(135)speed(0)#左侧弧形绘制a=0.2for i in range (80): if i < 50: pensize(a) forward(2) a+=0.15 if i<10: left(0.7) elif 10=50: pensize(a) forward(2.2) a-=0.25 if 50=60: pensize(a) forward(2.4) a-=0.15 if 60=60: pensize(a) forward(2.4) a-=0.16 if 60=60: pensize(a) forward(3) a-=0.15 if 60=40: pensize(a) forward(1.2) a-=0.15 if 40=40: pensize(a) forward(1.2) a-=0.16 if 40=50: pensize(a) forward(3) a-=0.15 if 50=60: pensize(a) forward(3) a-=0.15 if 50=40: pensize(a) forward(2.4) a-=0.15 if 40=40: pensize(a) forward(3) a-=0.15 if 40=20: pensize(a) forward(1.3) a-=0.15 if 20=40: pensize(a) forward(2.5) a-=0.15 if 40=40: pensize(a) forward(3) a-=0.15 if 40=30: pensize(a) forward(2.5) a-=0.15 if 30=40: pensize(a) forward(2.5) a-=0.15 if 40=60: pensize(a) forward(3.5) a-=0.08setheading(0)penup()goto(-16,-70)pendown()right(91)a=1for i in range (120): if i < 60: pensize(a) forward(3.5) a+=0.08 elif i >=60: pensize(a) forward(3.5) a-=0.08setheading(0)speed(1)penup()goto(-16,-150)pendown()pensize(3)left(35)forward(15)setheading(0)right(115)forward(34)setheading(180)penup()goto(-49,-250)pendown()pensize(3)right(35)forward(15)setheading(180)left(115)forward(34)input()done
二、第二种画法
第二种就稍逊一筹了,但也挺好看。
import turtle # 设置初始位置turtle.penup()turtle.left(90)turtle.fd(200)turtle.pendown()turtle.right(90) # 花蕊turtle.fillcolor("red")turtle.begin_fill()turtle.circle(10,180)turtle.circle(25,110)turtle.left(50)turtle.circle(60,45)turtle.circle(20,170)turtle.right(24)turtle.fd(30)turtle.left(10)turtle.circle(30,110)turtle.fd(20)turtle.left(40)turtle.circle(90,70)turtle.circle(30,150)turtle.right(30)turtle.fd(15)turtle.circle(80,90)turtle.left(15)turtle.fd(45)turtle.right(165)turtle.fd(20)turtle.left(155)turtle.circle(150,80)turtle.left(50)turtle.circle(150,90)turtle.end_fill() # 花瓣1turtle.left(150)turtle.circle(-90,70)turtle.left(20)turtle.circle(75,105)turtle.setheading(60)turtle.circle(80,98)turtle.circle(-90,40) # 花瓣2turtle.left(180)turtle.circle(90,40)turtle.circle(-80,98)turtle.setheading(-83) # 叶子1turtle.fd(30)turtle.left(90)turtle.fd(25)turtle.left(45)turtle.fillcolor("green")turtle.begin_fill()turtle.circle(-80,90)turtle.right(90)turtle.circle(-80,90)turtle.end_fill() turtle.right(135)turtle.fd(60)turtle.left(180)turtle.fd(85)turtle.left(90)turtle.fd(80) # 叶子2turtle.right(90)turtle.right(45)turtle.fillcolor("green")turtle.begin_fill()turtle.circle(80,90)turtle.left(90)turtle.circle(80,90)turtle.end_fill() turtle.left(135)turtle.fd(60)turtle.left(180)turtle.fd(60)turtle.right(90)turtle.circle(200,60)
总结
所画玫瑰花的库用的只是turtle,但代码却很多。
来源地址:https://blog.csdn.net/we123aaa4567/article/details/128258616