基于Python-turtle库绘制路飞的草帽骷髅旗、美国队长的盾牌、高达的源码

源码:

#路飞骷髅
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) #帽子黄底RGB
t.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(221,65,43) #帽子红色带
t.pencolor(0,0,0)
t.seth(80)
t.circle(-130,19)
t.seth(0)
t.fd(225)
t.seth(-59)
t.circle(-130,19)
t.seth(180)
t.fd(255)
t.end_fill()

#帽檐
t.begin_fill()
t.color(242,232,184)
t.pencolor(0,0,0)
t.fd(60)
t.circle(12,180)
t.fd(375)
t.circle(12,180)
t.fd(255 + 60)
t.end_fill()

#脸部下半轮廓
t.pu()
t.setpos(0,-30)
t.seth(-180)
t.circle(-130,-75)
t.pd()
t.circle(-130,150)

#眼睛鼻子
t.pu()
t.color(33,24,24) #眼睛、鼻子RGB
t.setpos(-45,64)
t.seth(-180)
t.pd()
t.begin_fill()
t.circle(33)
t.pu()
t.setpos(45,64)
t.pd()
t.circle(33)
t.end_fill()

t.pu()
t.setpos(0,5)
t.pd()
t.begin_fill()
t.circle(8)
t.end_fill()

#下巴
t.pencolor(0,0,0)
t.pu()
t.setpos(0,0)
t.seth(0)
t.circle(-75,45)
t.pd()
t.circle(-75,270)

#牙齿
t.pu()
t.setpos(0,120)
t.seth(0)
t.circle(-105,136)
t.pd()
t.circle(-105,86)

t.pu()
t.seth(0)
t.goto(0,200)
t.circle(-130,150)
t.pd()
t.circle(-130,60)

t.pu() #牙齿三根竖线
t.setpos(-30,-27)
t.seth(260)
t.pd()
t.fd(52)
t.pu()
t.setpos(30,-27)
t.pd()
t.seth(-260)
t.fd(-52)
t.pu()
t.setpos(0,-30)
t.seth(-90)
t.pd()
t.fd(56)

#上排右侧小爪爪
#释放注释为:上排右侧小爪爪实心金方案
t.pu()
#t.color(255,215,0) #金色的RGB
t.pencolor(0,0,0)
t.setpos(110,145)
t.seth(45)
t.pd()
#t.begin_fill()
t.fd(40)
t.seth(135)
t.circle(-30,235)
t.seth(-20)
t.circle(-30,220)
t.seth(-135)
t.fd(40)
#t.end_fill()

#上排左侧小爪爪
t.pu()
t.pencolor(0,0,0)
t.setpos(-110,145)
t.seth(135)
t.pd()
t.fd(40)
t.seth(45)
t.circle(30,235)
t.seth(-160)
t.circle(30,220)
t.seth(-45)
t.fd(40)

#下排右侧小爪爪
t.pu()
t.setpos(70,-10)
t.seth(-45)
t.pd()
t.fd(70)
t.seth(45)
t.circle(-30,235)
t.seth(-70)
t.circle(-30,255)
t.seth(135)
t.fd(22)

#下排左侧小爪爪
t.pu()
t.setpos(-70,-10)
t.seth(-135)
t.pd()
t.fd(70)
t.seth(135)
t.circle(30,235)
t.seth(-110)
t.circle(30,255)
t.seth(45)
t.fd(22)
t.done()

效果图:

源码:

# -*- coding:utf-8 -*-
import turtle
import math

def shield():
  '''
  该函数的作用是画一个美国队长的盾牌
  '''
  # 设置画布背景
  turtle.bgcolor('#FFFFFF')
  # 设置画笔速度
  turtle.speed(10)
  # 依次填充同心圆
  fill_circle('#FF0000', 230)
  fill_circle('#FFFFFF', 178)
  fill_circle('#FF0000', 129)
  fill_circle('#0000FF', 75)
  # 完成五角星
  draw_five('#FFFFFF', 75)
  # 以下代码,将画好的图案按指定格式保存到当前文件目录
  # windows 可以使用.jpg格式,或.ps,MAC使用eps格式,或.ps
  ts = turtle.getscreen()
  ts.getcanvas().postscript(file="shield.eps")

  # 启动事件循环,必须是乌龟图形程序中的最后一个语句
  # 如果没有这个语句,代码运行完成后,窗口直接消失。
  turtle.done()

def draw_circle(radium):
  '''
  该函数的作用是画一个圆线
  :param radium:半径
  '''
  # 画笔定位到圆点
  turtle.home()
  # 提笔
  turtle.penup()
  # 向前移动指定的半径
  turtle.forward(radium)
  # 落笔
  turtle.pendown()
  # 偏转角度
  turtle.setheading(90)
  # 画一个指定半径的圆
  turtle.circle(radium)
  # 提笔
  turtle.penup()

def fill_circle(color, r1):
  '''
  该函数的作用是,画一个圆环,有指定的填充色和半径
  :param color:颜色
  :param r1:半径
  '''
  # 设置画笔颜色
  turtle.pencolor(color)
  # 设置填充颜色
  turtle.fillcolor(color)
  # 开始填充
  turtle.begin_fill()
  # 画圆线
  draw_circle(r1)
  # 结束填充
  turtle.end_fill()

# 画并填充五角星
def draw_five(color, radium):
  '''
  该函数的作用是画一个五角星
  :param color:颜色
  :para radium:
  '''
  # 画笔定位到圆点
  turtle.home()
  # 提笔
  turtle.penup()
  # 偏转90度
  turtle.setheading(90)
  # 向前移动90个像素
  turtle.forward(radium)
  # 偏转288度
  turtle.setheading(288)
  # 落笔
  turtle.pendown()
  # radians()将角度转换为弧度
  long_side = (math.sin(math.radians(36))*radium)/math.sin(math.radians(126))
  # 设置画笔颜色
  turtle.pencolor(color)
  # 设置填充颜色
  turtle.fillcolor(color)
  # 开始填充
  turtle.begin_fill()
  for i in range(10):
    turtle.forward(long_side)
    if i % 2 == 0:
      turtle.left(72)
    else:
      turtle.right(144)
  # 结束填充
  turtle.end_fill()
  # 提笔
  turtle.penup()

# 运行主函数
shield()

效果图:

源码:

import turtle
t=turtle.Turtle()
turtle.Turtle().screen.delay(0)
tleft=turtle.Turtle()
#第一部分
t.penup()
t.goto(0,0)
t.pendown()
t.left(20)
t.forward(110)
t.left(25)
t.forward(40)
t.left(100)
t.circle(180,20)
t.right(120)
t.forward(250)
t.left(165)
t.forward(250)
t.right(100)
t.forward(35)
t.left(70)
t.forward(45)
t.left(70)
t.forward(120)
t.left(70)
t.forward(80)
t.left(80)
t.forward(80)
t.left(68)
t.forward(120)
t.left(180)
t.forward(78)
t.right(68)
t.forward(60)
t.right(75)
t.forward(60)
t.right(110)
t.forward(15)
t.left(38)
t.forward(65)
t.right(73)#五边形的直边
t.forward(35)
t.right(70)
t.forward(65)
t.right(68)
t.forward(50)
t.right(80)
t.forward(50)
t.penup()
t.goto(-65,68)
t.pendown()
t.right(7)
t.forward(350)
t.right(165)
t.forward(330)
t.penup()
t.goto(64,65)
t.pendown()
t.left(75)
t.forward(350)
t.left(165)
t.forward(330)
t.penup()
t.goto(300,500)
#第二部分
tleft.left(180)
tleft.right(20)
tleft.forward(110)
tleft.right(25)
tleft.forward(40)
tleft.right(100)
tleft.circle(-180,20)
tleft.left(120)
tleft.forward(250)
tleft.right(165)
tleft.forward(250)
tleft.left(100)
tleft.forward(35)
tleft.penup()
tleft.goto(0,0)
tleft.pendown()
tleft.left(20)
tleft.penup()
tleft.forward(18)
tleft.pendown()
tleft.forward(50)#额头竖线
tleft.penup()
tleft.forward(110)#消除竖线
tleft.pendown()
tleft.left(90)
tleft.forward(30)
tleft.right(90)
tleft.forward(60)
tleft.right(90)
tleft.forward(60)
tleft.right(90)
tleft.forward(60)
tleft.right(90)
tleft.forward(40)
tleft.penup()
tleft.forward(30)
tleft.pendown()
tleft.left(90)
tleft.forward(30)
tleft.right(180)
tleft.forward(100)
tleft.right(90)
tleft.forward(80)
tleft.right(90)
tleft.forward(100)
tleft.penup()
tleft.goto(150,70)
tleft.pendown()
tleft.left(100)
tleft.forward(40)
tleft.right(80)
tleft.circle(-333,40)
tleft.right(160)
tleft.forward(230)
#右半部分
tleft.left(100)
tleft.forward(40)
tleft.left(80)
tleft.forward(20)
tleft.left(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
tleft.left(80)
tleft.forward(20)
tleft.left(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
tleft.left(80)
tleft.forward(20)
tleft.left(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
tleft.left(80)
tleft.forward(20)
tleft.left(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
tleft.left(80)
tleft.forward(20)
tleft.left(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
tleft.left(80)
tleft.forward(20)
tleft.left(100)
tleft.forward(30)
tleft.right(100)
tleft.forward(20)
tleft.right(80)
tleft.forward(30)
#右下部分
tleft.left(70)
tleft.forward(30)
tleft.right(110)
tleft.forward(40)
tleft.right(60)
tleft.forward(100)
tleft.right(30)
tleft.circle(200,20)
tleft.left(10)
tleft.forward(80)
#右下部分goto
tleft.penup()
tleft.goto(145,-198)
tleft.pendown()
tleft.left(90)
tleft.forward(30)
tleft.right(30)
tleft.forward(40)
tleft.right(150)
tleft.forward(30)
tleft.backward(30)
tleft.left(90)
tleft.forward(100)
tleft.right(90)
tleft.forward(30)
tleft.backward(30)
tleft.left(90)
tleft.right(30)
tleft.circle(200,20)
tleft.left(10)
tleft.forward(50)
#第三部分脸
t2=turtle.Turtle()
t2.penup()
t2.goto(0,-80)
#尖角
t2.circle(150,extent=90)
t2.pendown()
t2.circle(150,extent=30)
t2.penup()
t2.circle(150,extent=18)
t2.pendown()
t2.circle(150,extent=27)
t2.penup()
t2.circle(150,extent=30)
t2.pendown()
t2.circle(150,extent=27)
t2.penup()
t2.circle(150,extent=18)
t2.pendown()
t2.circle(150,extent=30)
t2.right(100)
t2.forward(40)
#左脸夹
t2.left(80)
t2.circle(333,40)
t2.left(160)
t2.forward(230)
#左半部分
t2.right(100)
t2.forward(40)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
t2.left(100)
t2.forward(20)
t2.left(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
t2.left(100)
t2.forward(20)
t2.left(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
t2.left(100)
t2.forward(20)
t2.left(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
t2.left(100)
t2.forward(20)
t2.left(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
t2.left(100)
t2.forward(20)
t2.left(80)
t2.forward(30)
t2.right(80)
t2.forward(20)
t2.right(100)
t2.forward(30)
t2.left(100)
t2.forward(20)
t2.left(80)
t2.forward(30)
t2.right(70)
t2.forward(30)
t2.left(110)
t2.forward(40)
t2.left(60)
t2.forward(100)
t2.left(30)
t2.circle(-200,20)
t2.right(10)
t2.forward(80)
t2.penup()
t2.goto(-145,-198)#左脸颊
t2.pendown()
t2.right(90)
t2.forward(30)
t2.left(30)
t2.forward(40)
t2.left(150)
t2.forward(30)
t2.right(180)
t2.forward(30)
t2.left(90)
t2.forward(100)
t2.left(90)
t2.forward(30)
t2.left(180)
t2.forward(30)
t2.left(120)
t2.circle(-200,20)
t2.right(10)
t2.forward(50)
#左眼
t2.right(135)
t2.forward(70)
t2.left(50)
t2.forward(40)
t2.left(20)
t2.forward(20)
t2.penup()
t2.goto(-100,28)
t2.pendown()
t2.right(70)
t2.forward(65)
t2.left(50)
t2.forward(40)
t2.left(40)
t2.forward(20)
#左眼带
t2.penup()
t2.goto(-105,-10)
t2.pendown()
t2.right(100)
t2.circle(120,extent=20)
t2.circle(60,extent=80)
t2.penup()
t2.goto(-105,-13)
t2.pendown()
t2.right(100)
t2.circle(120,extent=20)
t2.circle(60,extent=80)
t2.penup()
t2.goto(-70,-40)
t2.pendown()
t2.left(10)
t2.forward(30)
t2.penup()
t2.goto(-10,-40)
t2.pendown()
t2.left(35)
t2.forward(30)
t2.penup()
t2.goto(-80,30)
t2.pendown()
t2.right(130)
t2.forward(47)
t2.left(50)
t2.forward(35)
t2.penup()
t2.goto(-60,-45)
t2.pendown()
t2.right(98)
t2.forward(60)
t2.left(20)
t2.forward(80)
t2.left(70)
t2.forward(10)
t2.left(90)
t2.forward(50)
t2.right(60)
t2.forward(30)
t2.right(60)
t2.forward(30)
t2.right(60)
t2.forward(50)
t2.left(90)
t2.forward(10)
t2.left(75)
t2.forward(80)
t2.left(15)
t2.forward(60)
t2.penup()
t2.goto(-80,-140)
t2.pendown()
t2.right(150)
t2.circle(85,extent=45)
t2.left(15)
t2.forward(70)
t2.left(15)
t2.circle(55,extent=55)
t2.penup()
t2.goto(0,-175)
t2.pendown()
t2.left(18)
t2.forward(170)
#右眼
tleft.left(135)
tleft.forward(70)
tleft.right(50)
tleft.forward(40)
tleft.right(20)
tleft.forward(20)
tleft.penup()
tleft.goto(100,28)
tleft.pendown()
tleft.left(70)
tleft.forward(65)
tleft.right(50)
tleft.forward(40)
tleft.right(40)
tleft.forward(20)
#右眼带
tleft.penup()
tleft.goto(105,-10)
tleft.pendown()
tleft.left(100)
tleft.circle(-120,extent=20)
tleft.circle(-60,extent=80)
tleft.penup()
tleft.goto(105,-13)
tleft.pendown()
tleft.left(100)
tleft.circle(-120,extent=20)
tleft.circle(-60,extent=80)
#右眼睛
tleft.penup()
tleft.goto(70,-40)
tleft.pendown()
tleft.right(10)
tleft.forward(30)
tleft.penup()
tleft.goto(10,-40)
tleft.pendown()
tleft.right(35)
tleft.forward(30)
tleft.penup()
tleft.goto(80,30)
tleft.pendown()
tleft.left(130)
tleft.forward(47)
tleft.right(50)
tleft.forward(35)
#鼻子
tleft.penup()
tleft.goto(0,-70)
tleft.pendown()
tleft.left(30)
tleft.forward(20)
tleft.left(72)
tleft.forward(10)
tleft.left(108)
tleft.forward(20)
tleft.right(42)
tleft.forward(20)
tleft.left(108)
tleft.forward(10)
tleft.left(72)
tleft.forward(20)
tleft.penup()
tleft.goto(0,-90)
tleft.pendown()
tleft.left(42)
tleft.forward(20)
tleft.left(72)
tleft.forward(10)
tleft.left(108)
tleft.forward(20)
tleft.right(42)
tleft.forward(20)
tleft.left(108)
tleft.forward(10)
tleft.left(72)
tleft.forward(20)
tleft.penup()
tleft.goto(200,500)
turtle.done()

效果图:

到此这篇关于基于Python-turtle库绘制路飞的草帽骷髅旗、美国队长的盾牌、高达的文章就介绍到这了,更多相关Python-turtle库美国队长的盾牌内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • 关于Python turtle库使用时坐标的确定方法

    想画一个比较复杂的图像,而且还想用turtle画,最让人想退却的是无规律的笔势和繁多的坐标,但既然没有按奈住冲动的心,那我告诉你一个比较笨的方法吧. 我用到了一个工具Photoshop,就是PS(某逗比公司的产品) PS有标尺工具,可以建立参考线,可以测量线段的长度和角度,更重要的是,PS的图像测量也是以像素为单位. 不过PS的坐标原点是在左上角,而在turtle里坐标是中心.有两种办法,一种是不改变坐标原点,在原点出建立直角坐标系,另 一种方法是改变坐标原点位置 home() #以当前海龟位置

  • python 利用turtle库绘制笑脸和哭脸的例子

    我就废话不多说了,直接上代码吧! import turtle turtle.pensize(5) turtle.pencolor("yellow") turtle.fillcolor("red") turtle.penup() turtle.goto(0,-200) turtle.pendown() turtle.circle(200) turtle.penup() turtle.goto(-100,50) turtle.pendown() turtle.begin

  • Python使用turtle库绘制小猪佩奇(实例代码)

    turtle(海龟)是Python重要的标准库之一,它能够进行基本的图形绘制.turtle图形绘制的概念诞生于1969年,成功应用于LOGO编程语言. turtle库绘制图形有一个基本框架:一个小海龟在坐标系中爬行,其爬行轨迹形成了绘制图形.刚开始绘制时,小海龟位于画布正中央,此处坐标为(0,0),前进方向为水平右方. 在Python3系列版本安装目录的Lib文件夹下可以找到turtle.py文件. 下面通过代码给大家介绍Python使用turtle库绘制小猪佩奇, 具体代码如下所示: # -*

  • Python中turtle库的使用实例

    Turtle库是Python内置的图形化模块,属于标准库之一,位于Python安装目录的lib文件夹下,常用函数有以下几种: 画笔控制函数 penup():抬起画笔: pendown():落下画笔: pensize(width):画笔宽度: pencolor(color):画笔颜色: 运动控制函数 forward(d)/fd(d):直行d个像素: circle(r, extent = None):绘制半径为r,角度为extent的弧形,圆心默认在海龟左侧距离r的位置: 方向控制函数 sethea

  • Python如何使用turtle库绘制图形

    1. 前奏: 在用turtle绘制图形时,需要安装对应python的解释器以及IDE,我安装的是pycharm,在安装完pycharm后,在pycharm安装相应库的模块,绘图可以引入turtle模块,想要进行运算可以引入numpy模块. 需要注意: 在pycharm 中 turtle 是不支持提示的,可能是动态语言的一种毛病吧 turtle绘图常用的函数有: 操纵海龟绘图有着许多的命令,这些命令可以划分为两种:一种为运动命令,一种为画笔控制命令 (1)画笔运动命令: 命令 说明 turtle.

  • 详解python使用turtle库来画一朵花

    看了群主最后成像的图片,应该是循环了36次画方框,每次有10度的偏移. 当然不能提前看答案,自己试着写代码. 之前有用过海龟画图来画过五角星.奥运五环.围棋盘等,所以感觉不难. # !/usr/bin/env python # -*- coding:utf-8 -*- # Author:wxh def run(): ''' 主方法 :return: None ''' import turtle length = 150 # 线段长度 angle = 45 # 角度 offset_angle =

  • 使用python图形模块turtle库绘制樱花、玫瑰、圣诞树代码实例

    今天为大家介绍几个Python"装逼"实例代码,python绘制樱花.玫瑰.圣诞树代码实例,主要使用了turtle库 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:

  • 基于Python-turtle库绘制路飞的草帽骷髅旗、美国队长的盾牌、高达的源码

    源码: #路飞骷髅 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) #帽子黄底RGB t.begin_fill() t.pencolor(0,0,0) t.circle(-130,160) t.seth(180) t.fd(255) t.end_fill() #红色线条 t.begin_fill()

  • 基于Python+Turtle实现绘制简易的大风车

    目录 前言 Turtle绘制大风车 保存为jpg图片 绘制不同角度的图片 图片合成 gif 动图 前言 大风车,吱呀吱呦呦地转, 这里的风景呀真好看!天好看,地好看…… 一首熟悉的歌曲,是否已经把你拉回了童年? 这首歌,估计是每个80后.90后的童年记忆! 小时候守着家里的电视,只要听到这个主题曲,就代表马上会有各种好看的动画片播出. 又是一年6·1儿童节,作为一个Python号,当然又要想想能用python做点什么啦—— Turtle绘制大风车 第一步,先观察风车的重要组成部分,四个扇叶和一个

  • Python turtle库绘制菱形的3种方式小结

    绘制一个菱形四边形,边长为 200 像素.方法1和2绘制了内角为60和120度的菱形,方法3绘制了内角为90度的菱形. 方法1‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‮‬‫ import turtle as t ls = [30,-30,-150,150]#菱形各边的画笔绝对角度列表 for i in range(4): t.seth(ls[i]) #画笔转向相应绝对角度 t.forward(2

  • Python turtle库(绘制螺旋正方形)

    目录 turtle库绘制螺旋正方形 1.螺旋正方形 2.彩色螺旋正方形 第三方库turtle的应用 1.pip安装turtle库 2.绘图坐标系 3.turtle的画笔控制方法 4.turtle的图形绘制方法 5.简单应用示例 turtle库绘制螺旋正方形 1.螺旋正方形 import turtle #导入turtle库 turtle.pensize(2) #设置画笔的宽度(2) for i in range(100): #循环(画)100次 turtle.fd(i + (i * 2)) #每次

  • Python利用turtle库绘制彩虹代码示例

    语言:Python IDE:Python.IDE 需求 做出彩虹效果 颜色空间 RGB模型:光的三原色,共同决定色相 HSB/HSV模型:H色彩,S深浅,B饱和度,H决定色相 需要将HSB模型转换为RGB模型 代码示例: #-*- coding:utf-8 –*- from turtle import * def HSB2RGB(hues): hues = hues * 3.59 #100转成359范围 rgb=[0.0,0.0,0.0] i = int(hues/60)%6 f = hues/

  • python使用turtle库绘制树

    本文实例为大家分享了python使用turtle库绘制树的具体代码,供大家参考,具体内容如下 # -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import turtle, datetime def drawGap(): #绘制数码管间隔 turtle.penup() turtle.fd(5) def drawLine(draw): #绘制

  • Python使用Turtle库绘制一棵西兰花

    Turtle库是Python中一个强大的绘制图像的函数库,灵活使用Turtle库可以绘制各种好看的图像. 下面介绍使用Turtle库绘制一棵西兰花. 绘制一棵西兰花,从主干出发以一定的角度向左向右生成对称的枝干,再从每个枝干出发向左向右生成对称的枝干,循环此动作,并最终绘制出一棵漂亮的西兰花. 首先导入Turtle库,并设置画笔大小.画笔速度及颜色,并隐藏画笔 from turtle import Turtle p=Turtle() p.pensize(5) p.color(clr) p.hid

  • 使用Python的Turtle库绘制森林的实例

    这是由一个小作业引发的对Python的Turtle库的学习 下面是官方手册: Turtle官方手册 1.配置编程环境 由于现在的笔记本是临时借的,编程环境不是熟悉的环境,又由于种种原因没有安装成功Anaconda,就尝试了下其他的IDE: 最早接触的Enthought Canopy跑示例程序时各种报错无法解决(Python Kernal Crashed): 最著名的Python IDE是JetBeans的Pycharm,装好以后啥都没跑就占了1G内存(虽然舍友电脑上的没问题): 好在之前装了No

  • 利用Python的turtle库绘制玫瑰教程

    turtle的文档:https://docs.python.org/3/library/turtle.html 用Python的turtle库绘图是很简单的,闲来无事就画了一个玫瑰花,下面奉上源码.... 源码: ''' Created on Nov 18, 2017 @author: QiZhao ''' import turtle # 设置初始位置 turtle.penup() turtle.left(90) turtle.fd(200) turtle.pendown() turtle.ri

随机推荐