Python_Draw
Z0o1010
这个作者很懒,什么都没留下…
展开
-
发射爱心
from turtle import *from time import sleep def go_to(x, y): up() goto(x, y) down() def head(x,y,r): go_to(x,y) speed(1) circle(r) leg(x,y) def leg(x,y): right(90) forward(180) right(30) forward(100) le.原创 2020-10-13 20:17:21 · 785 阅读 · 0 评论 -
画圆圈
import turtledef draw_spiral(t, n, length=3, a=0.1, b=0.0002): theta = 0.0 for i in range(n): t.fd(length) dtheta = 1 / (a + b * theta) t.lt(dtheta) theta += dthetabob = turtle.Turtle()draw_spiral(bob, n=1000)turtle.原创 2020-10-12 23:04:01 · 80 阅读 · 0 评论 -
五角星(循环)
import turtle as tt.goto(100,0)for i in range(50): t.left(80) t.fd(100) t.left(135) t.fd(105)原创 2020-10-12 23:01:39 · 424 阅读 · 0 评论 -
路飞骷髅头
#路飞骷髅import turtle as t#黄底帽子t.pu()t.goto(0,200)t.circle(-130,-80)t.pd()t.colormode(255)t.pensize(5)t.color(242,232,184) #帽子黄底RGBt.begin_fill()t.pencolor(0,0,0)t.circle(-130,160)t.seth(180)t.fd(255)t.end_fill() #红色线条t.begin_fill()t.color(原创 2020-10-12 23:01:01 · 429 阅读 · 0 评论 -
向日葵
import turtle turtle.setup(800, 800, 200, 200) turtle.pencolor("yellow") turtle.pensize(4) turtle.penup() #turtle库准备 turtle.fd(-150) turtle.pendown() '''花的绘制, (旋转角度)100*18(旋转次数),刚好为360度的5倍,因而能够闭合。大家也可以尝试改变这两个值,得到不同效果。'''for i in range(18)原创 2020-10-12 22:56:41 · 133 阅读 · 0 评论 -
绘制樱花树
import turtleimport randomfrom turtle import *from time import sleep # 画樱花的躯干(60,t)def tree(branchLen,t): sleep(0.0005) if branchLen >3: if 8<= branchLen <=12: if random.randint(0,2) == 0: t.colo原创 2020-10-12 22:47:39 · 852 阅读 · 0 评论 -
小猪佩奇
import turtle as t t.pensize(4)t.hideturtle()t.colormode(255)t.color((255,155,192),"pink")t.setup(840,500)t.speed(10) #鼻子t.pu()t.goto(-100,100)t.pd()t.seth(-30)t.begin_fill()a=0.4for i in range(120): if 0<=i<30 or 60<=i<90:原创 2020-10-12 22:46:20 · 652 阅读 · 0 评论 -
树
from turtle import *import randomdef drawTree(length): if length > 1: # 缩小树干 if 14 < length < 30: pensize(4) # 长度这个范围内为绿叶 elif 5 < length < 15: color('#04B486') pens原创 2020-10-12 22:37:58 · 124 阅读 · 0 评论 -
彩色圆圈
import turtlecolors = ["red","orange","yellow","green","blue","indigo","purple",'black']#颜色for i in range(len(colors)):#循环画8个 c = colors[i] turtle.color(c)#显示颜色 turtle.begin_fill() turtle.circle(100) turtle.rt(360/len(colors))#分割八次原创 2020-09-25 10:13:15 · 123 阅读 · 0 评论 -
大风车
import turtle as tt.goto(100,0)for i in range(100): t.left(80) t.fd(100) t.left(135) t.fd(165) t.left(125) t.fd(115)原创 2020-09-25 10:12:22 · 116 阅读 · 0 评论 -
小企鹅
import turtle as tdef infoPrt(): print('coordinate: ' + str(t.pos())) print('angle: ' + str(t.heading()))t.pensize(3)t.hideturtle()t.colormode(255)t.color("gray")t.setup(700, 650)t.speed(10)t.st()t.pu()t.goto(-210,86)t.pd()infoPrt()原创 2020-09-25 10:00:21 · 206 阅读 · 0 评论 -
穿雨靴的小黄鸭
#穿雨鞋的小鸭from turtle import * #扁嘴pensize(2) pu()goto(-100,100)#上嘴最高顶点seth(-50)pd()color('#6C3100','#FADD77')begin_fill()fd(16)vertex_right = pos()#嘴最右顶点rt(50)fd(12)vertex_down = pos()#下嘴最低顶点rt(80)fd(30)circle(-3,200)vertex_left = pos()#嘴.原创 2020-09-25 09:42:18 · 362 阅读 · 0 评论 -
八卦图
from turtle import * def yin(radius, color1, color2): width(3) color("black", color1) begin_fill() circle(radius/2., 180) circle(radius, 180) left(180) circle(-radius/2., 180) end_fill() left(90) up() forward(r原创 2020-09-25 09:39:13 · 289 阅读 · 0 评论 -
时钟
from turtle import *from datetime import *def Skip(step): penup() forward(step) pendown()def mkHand(name, length): #注册Turtle形状,建立表针Turtle reset() Skip(-length*0.1) begin_poly() forward(length*1.1) end_poly() handForm = get_poly() #原创 2020-09-25 09:36:43 · 136 阅读 · 0 评论 -
小心心送给你
# -*- coding:utf-8 -*- import turtleimport time # 画心形圆弧def hart_arc(): for i in range(200): turtle.right(1) turtle.forward(2) def move_pen_position(x, y): turtle.hideturtle() # 隐藏画笔(先) turtle.up() # 提笔 tu原创 2020-09-14 15:12:47 · 92 阅读 · 0 评论 -
Shield
# -- * -- coding : utf-8 -- * --import turtle# 设置光标起点位置turtle.penup()turtle.goto(0, -120)turtle.pendown()# 绘制圆并填充红色turtle.pensize(1)turtle.pencolor('red')turtle.fillcolor('red')turtle.begin_fill()turtle.circle(205)turtle.end_fill()# 提笔tur原创 2020-09-14 15:09:39 · 186 阅读 · 0 评论 -
泡泡屏保
import randomimport tkinter'''要求,1 建立屏保程序,2. 屏保是随机球,自己运动3. 鼠标移动则清除分析:1, 需要一个ScreenSaver类,一个Ball的类2. ScreenSaver: 1.1: 需要一个canvas, 大小与屏幕一致 1.2:程序已启动,就开始在屏幕上画小球,小球位置随机,会动,速度,方向随机 1.3: 鼠标一移动,则程序退出 1.4: 多少个小球,建议允许输入2. RandomBall: 2.1: 大小,颜色,出现位原创 2020-09-25 09:37:43 · 257 阅读 · 0 评论