使用python画一颗圣诞树】的更多相关文章

# -*- coding: utf-8 -*- # @Time : 18-12-26 上午9:32 # @Author : Felix Wang import turtle # 定义圣诞树的绿叶函数 def tree(d, s): if d <= 0: return turtle.forward(s) tree(d - 1, s * .8) turtle.right(120) tree(d - 3, s * .5) turtle.right(120) tree(d - 3, s * .5) tu…
用上turtle库后,各种画,今天画个拳头大的爱心@.@. 下面贴下代码: # -*- coding: utf-8 -*- # Nola import pygame import time import turtle as t def heart(): # 添加播放音乐功能 file = 'Walk Off the Earth.Jocelyn Alice.Krnfx - Havana.mp3' #mp3的路径 pygame.mixer.init() # 初始化音频 track = pygame.…
import numpy as np import matplotlib.pyplot as plt x_coords = np.linspace(-100, 100, 500) y_coords = np.linspace(-100, 100, 500) points = [] for y in y_coords: for x in x_coords: if ((x * 0.03) ** 2 + (y * 0.03) ** 2 - 1) ** 3 - (x * 0.03) ** 2 * (y…
因python自带有海龟画图库,尝试给爱猫的小仙女来画个猫咪. 1.代码如下 from turtle import * #两个函数用于画心 def curvemove(): for i in range(200): right(1) forward(0.1) def heart(x,y,s): pu() goto(x,y) seth(s) pendown() begin_fill() left(140) forward(11.1) curvemove() left(120) curvemove(…
沉淀再出发:用python画各种图表 一.前言 最近需要用python来做一些统计和画图,因此做一些笔记. 二.python画各种图表 2.1.使用turtle来画图 import turtle as t #turtle库是python的内部库,直接import使用即可 import time def draw_diamond(turt): for i in range(1,3): turt.forward(100) #向前走100步 turt.right(45) #海龟头向右转45度 turt…
用python画简单的樱花 代码如下: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): time.sleep(0.0005) if branch > 3: if 8 <= branch <= 12: if random.randint(0, 2) == 0: t.color('snow') # 白 else: t.color('lightcoral') # 淡珊瑚色 t.pe…
转自:python画个小猪佩奇 # -*- coding: utf-8 -*- """ Created on Mon May 20 11:36:03 2019 @author: epsoft """ import turtle as t def nose(x,y):#鼻子 t.pu() t.goto(x,y) t.pd() t.seth(-30) t.begin_fill() a=0.4 for i in range(120): if 0<…
用python画 pareto front 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2D pf import os import matplotlib.pyplot as plt import numpy as np def Read_Files(filename): X_axis = [] # X Y_axis = [] # Y with open(filename, 'r') as f: for line in f.readlines(): x = line.split("…
用python画3D的高斯曲线,我想如果有多个峰怎么画? import numpy as npimport matplotlib.pyplot as pltimport mathimport mpl_toolkits.mplot3d x, y = np.mgrid[-2:2:200j, -2:2:200j]z=(1/2*math.pi*3**2)*np.exp(-(x**2+y**2)/2*3**2)ax = plt.subplot(111, projection='3d')ax.plot_su…
用python画一只佩奇 from turtle import* def nose(x,y):#鼻子 penup()#提起笔 goto(x,y)#定位 pendown()#落笔,开始画 setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东.90-北.180-西.270-南) begin_fill()#准备开始填充图形 a=0.4 for i in range(120): if 0<=i<30 or 60<=i<90: a=a+0.08 left(3)…