python画图玫瑰花

1.

import turtle as t
t.penup()
t.left(90)
t.fd(200)
t.pendown()
t.right(90)

t.fillcolor("red")
t.begin_fill()
t.circle(10,180)
t.circle(25,110)
t.left(50)
t.circle(60,45)
t.circle(20,170)
t.right(24)
t.fd(30)
t.left(10)
t.circle(30,110)
t.fd(20)
t.left(40)
t.circle(90,70)
t.circle(30,150)
t.right(30)
t.fd(15)
t.circle(80,90)
t.left(15)
t.fd(45)
t.right(165)
t.fd(20)
t.left(155)
t.circle(150,80)
t.left(50)
t.circle(150,90)
t.end_fill()

t.left(150)
t.circle(-90,70)
t.left(20)
t.circle(75,105)
t.setheading(60)
t.circle(80,98)
t.circle(-90,40)


t.left(180)
t.circle(90,40)
t.circle(-80,98)
t.setheading(-83)

t.fd(30)
t.left(90)
t.fd(25)
t.left(45)
t.fillcolor("green")
t.begin_fill()
t.circle(-80,90)
t.right(90)
t.circle(-80,90)
t.end_fill()

t.right(135)
t.fd(60)
t.left(180)
t.fd(85)
t.left(90)
t.fd(80)

t.right(90)
t.right(45)
t.fillcolor("green")
t.begin_fill()
t.circle(80,90)
t.left(90)
t.circle(80,90)
t.end_fill()

t.left(135)
t.fd(60)
t.left(180)
t.fd(60)
t.right(90)
t.circle(200,60)


 
 

 2.

 

#第一种:画玫瑰的方法
from turtle import *
import time
 
#初始化玫瑰
#画布大小
setup(600,800,0,0) 
speed(0)
penup() # 提起画笔
seth(90) #朝向90度
fd(340)  #向前移动指定的距离
seth(0)
pendown()  #放下画笔
 
#开始画
speed(5)      #画笔移动速度为5秒
begin_fill()  #开始填充
fillcolor('red') #为红色
circle(50,30)    #画一个半径为50,弧度为30的圆
  
for i in range(10):
    fd(1)
    left(10)    #逆时针转动画笔10度
circle(40,40)
  
for i in range(6):
    fd(1)
    left(3)
circle(80,40)
  
for i in range(20):
    fd(0.5)
    left(5)
circle(80,45)
  
for i in range(10):
    fd(2)
    left(1)
circle(80,25)
  
for i in range(20):
    fd(1)
    left(4)
circle(50,50)
  
time.sleep(0.1)
  
circle(120,55)
  
speed(3)
  
seth(-90)
fd(70)
  
right(150)   #顺时针转动画笔150度
fd(20)
  
left(140)
circle(140,90)
  
left(30)
circle(160,100)
  
left(130)
fd(25)
  
penup()
right(150)
circle(40,80)
pendown()
  
left(115)
fd(60)
  
penup()
left(180)
fd(60)
pendown()
  
end_fill()
  
right(120)
circle(-50,50)
circle(-20,90)
  
speed(1)
fd(75)
  
speed(1)
circle(90,110)
  
penup()
left(162)
fd(185)
left(170)
pendown()
circle(200,10)
circle(100,40)
circle(-52,115)
left(20)
circle(100,20)
circle(300,20)
speed(1)
fd(250)
  
penup()
speed(2)
left(180)
fd(250)
circle(-300,7)
right(80)
circle(200,5)
pendown()
  
left(60)
begin_fill()
fillcolor('green')
circle(-80,100)
right(90)
fd(10)
left(20)
circle(-63,127)
end_fill()
  
penup()
left(50)
fd(20)
left(180)
  
pendown()
circle(200,25)
  
penup()
right(150)
  
fd(180)
  
right(40)
pendown()
begin_fill()
fillcolor('green')
circle(-100,80)
right(150)
fd(10)
left(60)
circle(-80,98)
end_fill()
  
penup()
left(60)
fd(13)
left(180)
  
pendown()
speed(1)
circle(-200,23)
  
exitonclick() #当点击时退出

3.

 

#首先代码一开始要引入turtle库
#第二种:这个画在画布中间了比上面的好
import turtle as t
 
#定义一个曲线绘制函数,定义一个简单的绘制曲线的函数
def DegreeCurve(n, r, d = 1):
    for i in range(n):
        t.left(d)
        t.circle(r, abs(d))
    
#初始位置设定,对绘制的初始值进行相关设定
s = 0.2  #size
t.setup(450 * 5 * s, 750 * 5 * s)
t.pencolor('black')
t.fillcolor('red')
t.speed(100)
t.penup()
t.goto(0, 900 * s)
t.pendown()
 
#绘制花朵形状,此时开始绘制花的主体部分
t.begin_fill()
t.circle(200 * s, 30)
DegreeCurve(60, 50 * s)
t.circle(200 * s, 30)
DegreeCurve(4, 100 * s)
t.circle(200 * s, 50)
DegreeCurve(50, 50 *s)
t.circle(350 * s, 65)
DegreeCurve(40, 70 * s)
t.circle(150 *s, 50)
DegreeCurve(20, 50 *s, -1)
t.circle(400 * s, 60)
DegreeCurve(18, 50 * s)
t.fd(250 * s)
t.right(150)
t.circle(-500 * s, 12)
t.left(140)
t.circle(550 * s, 110)
t.left(27)
t.circle(650 * s, 100)
t.left(130)
t.circle(-300 * s, 20)
t.right(123)
t.circle(220 * s, 57)
t.end_fill()
 
#绘制花枝形状,绘制花的枝叶部分
t.left(120)
t.fd(280 * s)
t.left(115)
t.circle(300 * s, 33)
t.left(180)
t.circle(-300 * s, 33)
DegreeCurve(70, 225 * s, -1)
t.circle(350 * s, 104)
t.left(90)
t.circle(200 * s, 105)
t.circle(-500 * s, 63)
t.penup()
t.goto(170 * s, -30 * s)
t.pendown()
t.left(160)
DegreeCurve(20, 2500 * s)
DegreeCurve(220, 250 * s, -1)
 
#绘制一个绿色叶子
t.fillcolor('green')
t.penup()
t.goto(670 * s, -180 * s)
t.pendown()
t.right(140)
t.begin_fill()
t.circle(300 * s, 120)
t.left(60)
t.circle(300 * s, 120)
t.end_fill()
t.penup()
t.goto(180 * s, -550 * s)
t.pendown()
t.right(85)
t.circle(600 * s, 40)
 
#绘制另一个叶子
t.penup()
t.goto(-150 * s, -1000 * s)
t.pendown()
t.begin_fill()
t.rt(120)
t.circle(300 * s, 115)
t.left(75)
t.circle(300 * s, 100)
t.end_fill()
t.penup()
t.goto(430 * s, -1070 * s)
t.pendown()
t.right(30)
t.circle(-600 * s, 35)
t.done()
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值