python turtle我想用五种颜色画五个圆,并且用画圆周的颜色填充,老是出问题,怎么回事,怎么修改? Python中用turtle画的两条线围成的图形怎么填充颜色...
python turtle\u4f5c\u56fe\u95ee\u9898\u7b80\u4ecb\uff1aturtle\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u7ed8\u56fe\u5de5\u5177\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6d77\u9f9f\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u7406\u89e3\u4e3a\u4e00\u4e2a\u673a\u5668\u4eba\uff0c\u53ea\u542c\u5f97\u61c2\u6709\u9650\u7684\u6307\u4ee4\u3002
1.\u5728\u6587\u4ef6\u5934\u5199\u4e0a\u5982\u4e0b\u884c\uff0c\u8fd9\u80fd\u8ba9\u6211\u4eec\u5728\u8bed\u53e5\u4e2d\u63d2\u5165\u4e2d\u6587
#-*- coding: utf-8 -*-
2.\u7528import turtle\u5bfc\u5165turtle\u5e93
3.\u7ed8\u56fe\u7a97\u53e3\u7684\u539f\u70b9(0,0)\u5728\u6b63\u4e2d\u95f4\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6d77\u9f9f\u5411\u6b63\u53f3\u65b9\u79fb\u52a8\u3002
4.\u64cd\u7eb5\u6d77\u9f9f\u7ed8\u56fe\u6709\u7740\u8bb8\u591a\u7684\u547d\u4ee4,\u8fd9\u4e9b\u547d\u4ee4\u53ef\u4ee5\u5212\u5206\u4e3a\u4e24\u79cd:\u4e00\u79cd\u4e3a\u8fd0\u52a8\u547d\u4ee4\uff0c\u4e00\u79cd\u4e3a\u753b\u7b14\u63a7\u5236\u547d\u4ee4
(1)\u8fd0\u52a8\u547d\u4ee4:
forward(d)
\u5411\u524d\u79fb\u52a8\u8ddd\u79bbd\u4ee3\u8868\u8ddd\u79bb
backward(d)
\u5411\u540e\u79fb\u52a8\u8ddd\u79bbd\u4ee3\u8868\u8ddd\u79bb
right(degree)
\u5411\u53f3\u8f6c\u52a8\u591a\u5c11\u5ea6
left(degree)
\u5411\u5de6\u8f6c\u52a8\u591a\u5c11\u5ea6
goto(x,y)
\u5c06\u753b\u7b14\u79fb\u52a8\u5230\u5750\u6807\u4e3a(x,y)\u7684\u4f4d\u7f6e
stamp()
\u7ed8\u5236\u5f53\u524d\u56fe\u5f62
speed(speed)
\u753b\u7b14\u7ed8\u5236\u7684\u901f\u5ea6\u8303\u56f4[0,10]\u6574\u6570
(2)\u753b\u7b14\u63a7\u5236\u547d\u4ee4:
down()
\u753b\u7b14\u843d\u4e0b\uff0c\u79fb\u52a8\u65f6\u7ed8\u5236\u56fe\u5f62
up()
\u753b\u7b14\u62ac\u8d77\uff0c\u79fb\u52a8\u65f6\u4e0d\u7ed8\u5236\u56fe\u5f62
setheading(degree)
\u6d77\u9f9f\u671d\u5411\uff0cdegree\u4ee3\u8868\u89d2\u5ea6
reset()
\u6062\u590d\u6240\u6709\u8bbe\u7f6e
pensize(width)
\u753b\u7b14\u7684\u5bbd\u5ea6
pencolor(colorstring)
\u753b\u7b14\u7684\u989c\u8272
fillcolor(colorstring)
\u7ed8\u5236\u56fe\u5f62\u7684\u586b\u5145\u989c\u8272
fill(Ture)
fill(False)
circle(radius, extent)
\u7ed8\u5236\u4e00\u4e2a\u5706\u5f62\uff0c\u5176\u4e2dradius\u4e3a\u534a\u5f84\uff0cextent\u4e3a\u5ea6\u6570\uff0c\u4f8b\u5982\u82e5extent\u4e3a180\uff0c\u5219\u753b\u4e00\u4e2a\u534a\u5706\uff1b\u5982\u8981\u753b\u4e00\u4e2a\u5706\u5f62\uff0c\u53ef\u4e0d\u5fc5\u5199\u7b2c\u4e8c\u4e2a\u53c2\u6570
5.\u51e0\u4e2a\u4f8b\u5b50
1\uff09\u753b\u4e00\u4e2a\u8fb9\u957f\u4e3a60\u7684\u4e09\u89d2\u5f62
#-*- coding: utf-8 -*-
importturtle
a=60
turtle.forward(a)
turtle.left(120)
turtle.forward(a)
turtle.left(120)
turtle.forward(a)
turtle.left(120)
2\uff09\u753b\u4e00\u4e2a\u8fb9\u957f\u4e3a60\u7684\u6b63\u65b9\u5f62\uff0c\u5e76\u586b\u5145\u4e3a\u7ea2\u8272\uff0c\u8fb9\u6846\u4e3a\u84dd\u8272
#-*- coding: utf-8 -*-
importturtle
turtle.reset()
a= 60
turtle.fillcolor("red")
turtle.pencolor("blue")
turtle.pensize(10)
turtle.fill(True)
turtle.left(90)
turtle.forward(a)
turtle.left(90)
turtle.forward(a)
turtle.left(90)
turtle.forward(a)
turtle.left(90)
turtle.forward(a)
turtle.fill(False)
6.\u7ec3\u4e60\uff1a
1\uff09\u753b\u4e00\u4e2a\u4e94\u8fb9\u5f62
2\uff09\u753b\u4e00\u4e2a\u516d\u8fb9\u5f62
3\uff09\u4efb\u610f\u8f93\u5165\u4e00\u4e2a\u6b63\u6574\u6570m(>=3)\uff0c\u753b\u4e00\u4e2a\u591a\u8fb9\u5f62(m\u6761\u8fb9)
4\uff09\u753b\u4e00\u4e2a\u4e94\u89d2\u661f\uff0c\u5982\u4e0b\u6240\u793a\uff0c\u6ce8\u610f\u586b\u5145\u4e3a\u7ea2\u8272
5\uff09\u753b\u4e00\u4e2a\u4e2d\u56fd\u8c61\u68cb\u68cb\u76d8\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5176\u4e2d\u6c49\u5b57\u4e0d\u5fc5\u663e\u793a\u51fa\u6765\uff1a
6\uff09\u7ed8\u5236\u5965\u8fd0\u4e94\u73af\u56fe\uff0c\u5176\u4e2d\u4e94\u79cd\u989c\u8272\u5206\u522b\u4e3a\u84dd\u8272\u3001\u9ed1\u8272\u3001\u7ea2\u8272\u3001\u9ec4\u8272\u548c\u7eff\u8272\u3002\u6ce8\u610f\u6839\u636e\u5b9e\u9645\u6548\u679c\u8c03\u6574\u5706\u5f62\u7684\u5927\u5c0f\u548c\u4f4d\u7f6e\u3002
\u4f60\u597d\uff0c\u7b54\u6848\u5982\u4e0b\u6240\u793a\u3002
\u586b\u5145\u4e3a\u9ec4\u8272
\u586b\u5145\u6548\u679c
\u5e0c\u671b\u4f60\u80fd\u591f\u8be6\u7ec6\u67e5\u770b\u3002\u5982\u679c\u4f60\u6709\u4e0d\u4f1a\u7684\uff0c\u4f60\u53ef\u4ee5\u63d0\u95ee\u6211\u6709\u65f6\u95f4\u5c31\u4f1a\u5e2e\u4f60\u89e3\u7b54\u3002\u5e0c\u671b\u4f60\u597d\u597d\u5b66\u4e60\u3002\u6bcf\u4e00\u5929\u90fd\u8fc7\u5f97\u5145\u5b9e\u3002
from turtle import *
colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple']
def circle():
for i in range(36):
forward(20)
left(10)
for i in colors:
color(i)
begin_fill()
circle()
end_fill()
left(60)
turtle import *colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple']def circle(): for i in range(36): forward(20) left(10)for i in colors: color(i) begin_fill() circle() end_fill() left(60)
学习学习!
扩展阅读:python turtle graphics ... python turtle 用法 ... python turtle fd ... python turtle 填充 ... python turtle 绘图 ... python turtle库color ... python网站 ... python turtle代码大全 ... python turtle画熊 ...