代码如下: import turtle def main(): t = turtle.Turtle() t.hideturtle() lengthOfSize = 200 drawFivePointStar(t,0,0,lengthOfSize) def drawFivePointStar(t,x,y,lengthOfSize): t.up() t.goto(x,y) t.left(36) t.down() for i in range(5): t.forward(lengthOfSize) t
1.#Python的turtle绘制正六边形 代码: len=100 #表示边长像素 import turtle as t #正六边形内角都是120度,外角60度 for i in range(6): t.left(60) t.fd(len) t.done() 结果: 2.#Python123 turtle叠边形绘制 Len=150 import turtle as t #叠边形内角为100度,外角就是80度 t.width(10) for i in range(10): t.fd(Len) t
Example1: import turtle as t #初始设置画笔的宽度(size).颜色(color) t.pensize(5) t.pencolor("black") #循环结构,减少代码 for i in range(4): t.forward(200) t.left(90) Example2: 方法一:把上面绘制四边形的代码:行6中的4改为6即可 #方法二 import turtle as t t.pensize(5) t.pencolor("black&quo
代码实现: #绘制彩色螺旋线 import turtle import time turtle.pensize(2) turtle.bgcolor("black") colors = ["red","yellow","purple","blue"] turtle.tracer(False) for x in range(400): turtle.forward(2*x) turtle.color(color
Html5+JavaScript 在Canvas上绘制五星红旗,具体思路如下图所示: 绘制思路在上图中已有说明,具体代码如下: <script type="text/javascript"> //绘制五角星,其中一点垂直向上,相隔的点相连,即可绘制. function drawStar(ctx,starCenterX,starCenterY,starRadius) { var aX = starCenterX; var aY = starCenterY - starRadi