1.求问怎样用python/python turtle画“心”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import turtle a = turtle.Turtle() def drawlove(): a.left(45) a.forward(30) a.right(45) a.forward(30) a.right(120) a.forward(110) a.penup() a.right(150) a.forward(75) a.pendown() a.left(45) a.forward(30) a.left(45) a.forward(30) a.left(120) a.forward(110) drawlove() 在这个基础上计算的再精密一点就好了,必要的话可以用到circle()。
2.如何用python turtle画心
是要表白么,嘿嘿,希望这个代码能帮到你哦~(参数不满意可以自己调)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
importturtle
importmath
wn =turtle.Screen()
wn.setworldcoordinates(-2, -2, 2, 2)
alex =turtle.Turtle()
alex.color("red")
alex.pensize(2)
alex.penup()
alex.speed(0)
walkStart =-1
walkEnd =1
i =walkStart
j =walkEnd
whilei <=0andj >=0:
y1 =math.sqrt(1-i *i) +(i *i) **(1/3.0)
y2 =-math.sqrt(1-i *i) +(i *i) **(1/3.0)
y3 =math.sqrt(1-j *j) +(j *j) **(1/3.0)
y4 =-math.sqrt(1-j *j) +(j *j) **(1/3.0)
alex.setx(i)
alex.sety(y1)
alex.dot()
alex.sety(y2)
alex.dot()
alex.setx(j)
alex.sety(y3)
alex.dot()
alex.sety(y4)
alex.dot()
i +=0.01
j -=0.01
wn.exitonclick()
3.python turtle画4个同心圆方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
importturtle
#draw first circle
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
#draw second circle
turtle.penup()
turtle.goto(0,-150)
turtle.pendown()
turtle.circle(150)
#draw third circle
turtle.penup()
turtle.goto(0,-100)
turtle.pendown()
turtle.circle(100)
#draw fourth circle
turtle.penup()
turtle.goto(0,-50)
turtle.pendown()
turtle.circle(50)
画笔的坐标默认在0,0,就以它为圆心。
因为turtle画圆的时候是从圆的底部开始画的,所以需要找到四个圆底部的坐标
比如:
第一个半径为200的圆,底部为(0,-200)
第二个半径为150的圆,底部为(0,-150)
第三个半径为100的圆,底部为(0,-100)
第四个半径为 50的圆,底部为(0, -50)
画的时候按下面的步骤:
1. 抬起画笔:turtle.penup()
2. 移动到相应坐标:turtle.goto(坐标)
3. 放下画笔:turtle.pendown()
4. 画圆:turtle.circle(半径)
效果如下图所示:
4.如何用python画一个同心圆,外环为红色
# encoding: utf-8
# Python 3.6.0
import turtle
for i in range(1,3):
if i==2:
turtle.pencolor("red")
turtle.pensize(10)
turtle.penup()
turtle.goto(0,-60*i)
turtle.pendown()
turtle.circle(60*i)
5.怎么用python画玫瑰花,求大神贴代码,感激不尽
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)运行结果:。
6.如何用python turtle画玫瑰花
操纵海龟绘图有着许多的命令,这些命令可以划分为两种:一种为运动命令,一种为画笔控制命令1. 运动命令:forward(degree) #向前移动距离degree代表距离backward(degree) #向后移动距离degree代表距离right(degree) #向右移动多少度left(degree) #向左移动多少度goto(x,y) #将画笔移动到坐标为x,y的位置stamp() #复制当前图形speed(speed) #画笔绘制的速度范围[0,10]整数2. 画笔控制命令:down() #移动时绘制图形,缺省时也为绘制up() #移动时不绘制图形pensize(width) #绘制图形时的宽度color(colorstring) #绘制图形时的颜色fillcolor(colorstring) #绘制图形的填充颜色fill(Ture)fill(false)lucy : 梦想照进现实;露茜;青春风采;draw_flower1.py[python] view plain copy# -*- coding: cp936 -*- import turtle import math def p_line(t, n, length, angle): """Draws n line segments.""" for i in range(n): t.fd(length) t.lt(angle) def polygon(t, n, length): """Draws a polygon with n sides.""" angle = 360/n p_line(t, n, length, angle) def arc(t, r, angle): """Draws an arc with the given radius and angle.""" arc_length = 2 * math.pi * r * abs(angle) / 360 n = int(arc_length / 4) + 1 step_length = arc_length / n step_angle = float(angle) / n # Before starting reduces, making a slight left turn. t.lt(step_angle/2) p_line(t, n, step_length, step_angle) t.rt(step_angle/2) def petal(t, r, angle): """Draws a 花瓣 using two arcs.""" for i in range(2): arc(t, r, angle) t.lt(180-angle) def flower(t, n, r, angle, p): """Draws a flower with n petals.""" for i in range(n): petal(t, r, angle) t.lt(p/n) def leaf(t, r, angle, p): """Draws a 叶子 and fill it.""" t.begin_fill() # Begin the fill process. t.down() flower(t, 1, 40, 80, 180) t.end_fill() def main(): window=turtle.Screen() #creat a screen window.bgcolor("blue") lucy=turtle.Turtle() lucy.shape("turtle") lucy.color("red") lucy.width(5) lucy.speed(0) # Drawing flower flower(lucy, 7, 60, 100, 360) # Drawing pedicel lucy.color("brown") lucy.rt(90) lucy.fd(200) # Drawing leaf lucy.rt(270) lucy.color("green") leaf(lucy, 40, 80, 180) lucy.ht() window.exitonclick() main()。
7.怎么用python的turtle库画出这个图案,要代码
import turtle as t
def quad(color):
t.begin_fill()
t.color(color)
t.forward(100)
t.left(36)
t.forward(100)
t.left(36*4)
t.forward(100)
t.left(36)
t.forward(100)
t.end_fill()
t.left(36*3)
for i in range(10):
if i%2:
quad('#99c8de')
else:
quad('#e5b9c4')
两三年没碰海龟了,觉得没啥用,看你赏金又提了就回去学了学
转载请注明出处编程代码网 » pythonturtle画爱心(求问怎样用python/pythonturtle画“心”)