立体多层玫瑰绘图源码__玫瑰花python 绘图源码集锦
目 录:
这篇文章是python 绘制玫瑰花的源码集锦合集,每篇都附有原作者的名字博客链接。使用时将代码复制后在相关的编程语言环境下运行。
代码仅供学习参考,请尊重原作者的创作和版权!
如果代码作者转载地址有错,请原作者留言,我会更正相应的代码原作者博客链接。
有些绘图效果一样,但代码有不同。效果图片列表如下,代码在后面。请按图片序号查看自己想看的代码。
(1)立体多层玫瑰 | (2)红玫瑰 | (3)红玫瑰 |
(4)红玫瑰 | (5)红玫瑰 | (6)红玫瑰 |
(1)python 玫瑰画法1——立体多层玫瑰 |
此玫瑰花我是画“草莓熊python turtle绘图代码(玫瑰花版)附源代码”时画的,玫瑰在左侧,右边可以绘制其他的图案,或者写文字也可。 |
#-*- coding: UTF-8 -*-import turtle as t """=================================================@Project ->Adversity Awake 玫瑰花系列@类别 : 玫瑰花->玫瑰花之1@Author : 逆境清醒@Date : 2022/11/10 1:46@Desc :https://blog.csdn.net/weixin_69553582================================================="""# 设置背景颜色,窗口位置以及大小 t.colormode(255)# 颜色模式t.speed(0)t.screensize(800,760,"white")#画布大小背景颜色t.setup(width=800, height=760,startx=None, starty=None) #绘图窗口的大小和起始坐标#t.bgpic("ditu3.gif")t.title("逆境清醒玫瑰花!")#设置绘图窗口的t.resizemode('noresize') #大小调整模式:auto,user,noresizet.tracer(0) def mlingpen(x, y): t.penup() t.goto(x, y) t.pendown()def rose(): #rose t.seth(75) mlingpen(-235, -150) t.pensize(10) t.pencolor("#035025") t.circle(300,40) mlingpen(-240, 70) t.pensize(2) t.color("#000000", "#22ac38") t.seth(12) mlingpen(-235,40) t.lt(40) t.fd(50) t.begin_fill() t.circle(-150,30) t.circle(-2,140) t.circle(-150,43) t.up() t.end_fill() mlingpen(-235,40) t.lt(330) t.fd(50) t.begin_fill() t.circle(-150,30) t.circle(-2,140) t.circle(-150,43) t.up() t.end_fill() mlingpen(-235,40) t.lt(260) t.fd(50) t.begin_fill() t.circle(-150,30) t.circle(-2,140) t.circle(-150,43) t.up() t.end_fill() t.pensize(2) t.seth(12) mlingpen(-210,60) t.begin_fill() t.color("#000000", "#f8c0c8") t.circle(50,150) t.rt(20) t.fd(40) t.rt(40) t.circle(15,130) t.fd(50) t.circle(15,80) t.up() t.end_fill() t.pensize(2) t.seth(12) mlingpen(-210,65) t.begin_fill() t.color("#f5aab5", "#f5aab5") t.circle(34,150) t.rt(20) t.fd(30) t.rt(40) t.circle(10,130) t.fd(50) t.circle(15,80) t.up() t.end_fill() t.pensize(2) t.seth(12) mlingpen(-210,65) t.begin_fill() t.color("#f198a5", "#f198a5") t.circle(30,150) t.rt(20) t.fd(30) t.rt(40) t.circle(10,130) t.fd(50) t.circle(15,80) t.up() t.end_fill() t.pensize(2) t.seth(12) mlingpen(-210,65) t.begin_fill() t.color("#ee8998", "#ee8998") t.circle(20,150) t.rt(20) t.fd(30) t.rt(40) t.circle(10,130) t.fd(50) t.circle(15,80) t.up() t.end_fill() mlingpen(-220,80) t.begin_fill() t.color("#e56e7f", "#e56e7f") t.circle(15,200) t.rt(20) t.fd(30) t.rt(40) t.circle(10,130) t.fd(50) t.circle(15,80) t.up() t.end_fill() t.seth(35) mlingpen(-230,90) t.begin_fill() t.color("#000000", "#fda7b5") t.circle(50,50) t.rt(40) t.circle(25,200) t.up() t.end_fill() t.seth(130) mlingpen(-294.51,142.14) #内4 t.begin_fill() t.color("#000000", "#fdadb8") t.circle(20,100) t.rt(90) t.circle(10,180) t.rt(90) t.circle(15,130) t.rt(110) t.circle(30,130) t.rt(50) t.circle(50,80) t.up() t.end_fill() t.seth(80) mlingpen(-240,140) t.begin_fill() t.color("#000000", "#fe8e9e") t.circle(10,100) t.rt(90) t.circle(12,150) t.rt(90) t.circle(15,130) t.rt(50) t.circle(50,80) t.rt(10) t.circle(50,80) t.goto(-240,140) t.up() t.end_fill() t.seth(80) mlingpen(-250,140) t.begin_fill() t.color("#f9788b", "#f9788b") t.circle(5,130) t.rt(90) t.circle(10,170) t.rt(100) t.circle(10,130) t.rt(70) t.circle(40,80) t.rt(40) t.circle(30,30) t.goto(-250,140) t.up() t.end_fill() t.seth(10) mlingpen(-245, 80) t.begin_fill() t.color("#000000", "#ef5f7a") t.seth(35) t.circle(30,80) t.rt(80) t.circle(10,150) t.rt(80) t.circle(17,200) t.rt(60) t.circle(29,120) t.goto(-245, 80) t.up() t.end_fill() t.seth(10) mlingpen(-250, 85) t.begin_fill() t.color("#ef758c", "#ef758c") t.seth(35) t.circle(25,80) t.rt(80) t.circle(6,150) t.rt(80) t.circle(12,210) t.rt(60) t.circle(23,120) t.goto(-250, 85) t.up() t.end_fill() t.seth(0) mlingpen(-250,125) t.pensize(5) t.dot("#ff4969") t.pensize(2) mlingpen(-266.97,121.26) t.pencolor("#321320") t.fillcolor("#f04969") t.begin_fill() t.rt(80) t.circle(12,150) t.rt(80) t.circle(6,270) t.rt(150) t.circle(10,180) t.up() t.end_fill() #t.color("#000000", "#f04969") t.seth(-70) mlingpen(-210,100) t.begin_fill() t.color("#000000", "#f04969") t.rt(20) t.fd(30) t.circle(-40,170) t.lt(20) t.fd(20) t.goto(-210,100) t.up() t.end_fill() t.seth(-70) mlingpen(-215,90) t.begin_fill() t.color("#ee627d", "#ee627d") t.rt(20) t.fd(20) t.circle(-35,170) t.lt(20) t.fd(15) t.goto(-220,90) t.up() t.end_fill() t.seth(-70) mlingpen(-220,80) t.begin_fill() t.color("#f47a91", "#f47a91") t.rt(20) t.fd(10) t.circle(-28,170) t.lt(20) t.fd(10) t.goto(-220,90) t.up() t.end_fill() t.seth(150) mlingpen(-220,100) t.begin_fill() t.color("#000000", "#f7cad1") t.circle(20,80) t.rt(10) t.circle(-40,70) t.rt(10) t.circle(20,80) t.rt(5) t.circle(5,180) t.rt(80) t.circle(20,70) t.rt(80) t.circle(40,60) t.rt(10) t.circle(40,110) t.goto(-220,100) t.up() t.end_fill() t.seth(150) mlingpen(-220,98) t.begin_fill() t.color("#ffe9f2", "#ffe9f2") t.circle(15,80) t.rt(7) t.circle(-45,75) t.rt(8) t.circle(20,50) t.rt(5) t.circle(2,200) t.rt(80) t.circle(15,85) t.rt(80) t.circle(40,60) t.rt(20) t.circle(30,70) t.goto(-220,98) t.up() t.end_fill() t.seth(150) mlingpen(-180,55) t.begin_fill() t.color("#000000", "#f7cad1") t.circle(30,80) t.rt(10) t.circle(-60,70) t.rt(5) t.circle(30,80) t.rt(5) t.circle(5,180) t.rt(90) t.circle(30,80) t.rt(80) t.circle(40,70) t.circle(20,50) t.rt(90) t.circle(20,95) t.goto(-180,55) t.up() t.end_fill() t.seth(150) mlingpen(-190,50) t.begin_fill() t.color("#f7e0e3", "#f7e0e3") t.circle(25,80) t.rt(8) t.circle(-55,75) t.rt(3) t.circle(25,60) t.rt(6) t.circle(5,200) t.rt(90) t.circle(30,80) t.rt(80) t.circle(22,80) t.circle(20,40) t.rt(80) t.circle(15,90) t.goto(-190,50) t.up() t.end_fill() rose()t.hideturtle()t.done()
(2)python 玫瑰画法2 |
转载地址:https://blog.csdn.net/qq_55342245/article/details/120904578 |
# 绘制玫瑰花并添加文字import turtle# 设置画布大小# turtle.screensize(canvwidth=None, canvheight=None, bg=None)turtle.setup(width=0.6, height=0.6)# 设置初始位置turtle.penup()turtle.left(90)turtle.fd(200)turtle.pendown()turtle.right(90)# 输出文字printer = turtle.Turtle()printer.hideturtle()printer.penup()printer.back(200)printer.write("赠给亲爱的 XX\n\n", align="right", font=("楷体", 16, "bold"))printer.write("from XXX", align="center", font=("楷体", 12, "normal"))# 花蕊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.done()
(3) python玫瑰画法3 |
#第一种:画玫瑰的方法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() #当点击时退出
(4) python玫瑰画法4 |
https://blog.csdn.net/gb4215287/article/details/124312484 |
#第三种:画法的玫瑰没有第二种的好看import turtle def initialization(): turtle.setup(width=0.9, height=0.9) turtle.speed(10) def flower(): turtle.goto(0, 200) 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() def peta1(): turtle.left(150) turtle.circle(-90, 70) turtle.left(20) turtle.circle(75, 105) turtle.setheading(60) turtle.circle(80, 98) turtle.circle(-90, 40) def peta2(): turtle.left(180) turtle.circle(90, 40) turtle.circle(-80, 98) turtle.setheading(-83) def leaf1(): turtle.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) def leaf2(): turtle.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) if __name__ == '__main__': initialization() flower() peta1() peta2() leaf1() leaf2() turtle.done()
(5) python玫瑰画法5 |
#首先代码一开始要引入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 #sizet.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()
(6) python玫瑰画法6 |
#下面看第四种:据说最好看import turtle as t t.setup(800,800)t.hideturtle()t.speed(11)t.penup()t.goto(50,-450)t.pensize(5)t.pencolor("black")t.seth(140)t.pendown()t.speed(10)t.circle(-300,60)t.fd(100)#jiaodu80#1yet.seth(10)t.fd(50)t.fillcolor("green")t.begin_fill()t.right(40)t.circle(120,80)t.left(100)t.circle(120,80)t.end_fill()t.seth(10)t.fd(90)t.speed(11)t.penup()t.fd(-140)t.seth(80)#2yet.pendown()t.speed(10)t.fd(70)t.seth(160)t.fd(50)t.fillcolor("green")t.begin_fill()t.right(40)t.circle(120,80)t.left(100)t.circle(120,80)t.end_fill()t.seth(160)t.fd(90)t.speed(11)t.penup()t.fd(-140)t.seth(80)t.pendown()t.speed(10)#t.fd(100)#1bant.seth(-20)t.fillcolor("crimson")t.begin_fill()t.circle(100,100)t.circle(-110,70)t.seth(179)t.circle(223,76)t.end_fill()#2bant.speed(11)t.fillcolor("red")t.begin_fill() t.left(180)t.circle(-223,60)t.seth(70)t.speed(10)t.circle(-213,15)#55t.left(70)#125t.circle(200,70)t.seth(-80)t.circle(-170,40)t.circle(124,94)t.end_fill()#t.speed(11)t.penup()t.right(180)t.circle(-124,94)t.circle(170,40)t.pendown()t.speed(10) t.seth(-60)t.circle(175,70) t.seth(235)t.circle(300,12)t.right(180)t.circle(-300,12) t.seth(125)t.circle(150,60) t.seth(70)t.fd(-20)t.fd(20) t.seth(-45)t.circle(150,40)t.seth(66)t.fd(-18.5)t.fd(18.5) t.seth(140)t.circle(150,27)t.seth(60)t.fd(-8) t.speed(11)t.penup()t.left(20.8)t.fd(-250.5) #3ban t.pendown()t.speed(10)t.fillcolor("crimson")t.begin_fill()t.seth(160) t.circle(-140,85)t.circle(100,70)t.right(165)t.circle(-200,32)t.speed(11)t.seth(-105)t.circle(-170,14.5)t.circle(123,94)t.end_fill()t.done()
推荐阅读:
2023年春节祝福第二弹——送你一只守护兔,让它温暖每一个你【html5 css3】画会动的小兔子 | ||
25 | | 2023春节祝福系列第一弹(放飞祈福孔明灯,祝福大家身体健康)(附完整源代码及资源免费下载) |
24 | | |
23 | | |
22 | | |
21 | | python爱心源代码集锦 |
20 | | 巴斯光年python turtle绘图__附源代码 |
19 | | Three.js实例详解___旋转的精灵女孩(附完整代码和资源) |
18 | | |
17 | | |
16 | | |
15 | | |
14 | | |
13 | | |
12 | | |
11 | | 用代码写出浪漫__合集(python、matplotlib、Matlab、java绘制爱心、玫瑰花、前端特效玫瑰、爱心) |
10 | | |
9 | | |
8 | | |
7 | | |
6 | | |
5 | | |
4 | | |
3 | | |
2 | | |
1 | |
来源地址:https://blog.csdn.net/weixin_69553582/article/details/127799004