Пример #1
0
def kwadrat(kolor): #kwadrat
    t.fillcolor(kolor)
    t.begin_fill()
    for i in range(4):
        t.fd(B)
        t.rt(90)
    t.end_fill()
Пример #2
0
def drawStar(N, R):
    turtle.reset()
    a = 360/N
    for i in range(N):
        turtle.fd(R)
        turtle.bk(R)
        turtle.left(a)
Пример #3
0
    def drawLine(self,color,coord1,coord2): 
        """
        dessine une ligne entre deux coordonné sur la grille

        :param color: La couleur de la ligne
        :param coord1: La première coordonné en tuple (i,j,"joueur")
        :param coord2: La deuxième coordonné en tuple (i,j,"joueur")
        """
        if coord1[2] == coord2[2] and coord2[2] == "you":
            turtle.goto(38+coord1[1]*25,87-25*coord1[0])
        elif coord1[2] == coord2[2] and coord2[2] == "enemy":
            turtle.goto(-262+(25*coord1[1]),87-25*coord1[0])
        else:
            print('wrong player')
            return 0
        turtle.pensize(20)
        turtle.pencolor(color)
        if coord1[1] == coord2[1]: #Vertical
            turtle.pendown()
            turtle.setheading(270)
            turtle.fd((coord2[0]-coord1[0])*25)
        elif coord1[0] == coord2[0]: #horizontal
            turtle.pendown()
            turtle.setheading(0)
            turtle.fd((coord2[1]-coord1[1])*25)
        else:
            print('Ligne non Hori ou Vert')
            return 0
        turtle.penup()
        return 1
Пример #4
0
def ustDoNastKraw(ile, bokKw=10):
    turtle.pu()
    turtle.lt(90)
    turtle.fd(bokKw)
    turtle.rt(90)
    turtle.rt(180)
    turtle.pd()
Пример #5
0
def drawSootSprite(N, R):
    # reset direction
    turtle.reset()
    # draw star
    drawStar(N, R)
    # draw body
    turtle.dot(0.8*2*R)
    # draw right eyeball
    turtle.fd(0.2*R)
    turtle.dot(0.3*R, 'white')
    # draw right pupil
    turtle.pu()
    turtle.bk(0.1*R)
    turtle.pd()
    turtle.dot(0.05*R)
    turtle.pu()
    # centre
    turtle.setpos(0, 0)
    # draw left eyeball
    turtle.bk(0.2*R)
    turtle.pd()
    turtle.dot(0.3*R, 'white')
    # draw left pupil
    turtle.pu()
    turtle.fd(0.1*R)
    turtle.pd()
    turtle.dot(0.05*R)

    turtle.hideturtle()
Пример #6
0
def elementSowy(r, bokKw, rMalegoKola):
    ##Rysujemy OD ŚRODKA
    turtle.colormode(255)
    turtle.fillcolor(209, 183, 255)
    turtle.begin_fill()
    turtle.circle(r)
    turtle.end_fill()
    turtle.pu()
    turtle.lt(90)
    turtle.fd(r)
    turtle.lt(45)
    turtle.fd(r)
    turtle.lt(45+90)
    turtle.pd()
    turtle.fillcolor(0, 0, 255)
    turtle.begin_fill()
    kwadrat(bokKw)
    turtle.end_fill()
    turtle.pu()
    turtle.fd((bokKw/4)*3)
    turtle.lt(90)
    turtle.fd(bokKw/4)
    turtle.pd()
    turtle.fillcolor(255, 255, 255)
    turtle.begin_fill()
    turtle.circle(rMalegoKola)
    turtle.end_fill()
    turtle.pu()
    turtle.fd(bokKw / 2)
    turtle.pd()
    turtle.begin_fill()
    turtle.circle(rMalegoKola)
    turtle.end_fill()
Пример #7
0
def drawSide(l):
    """
        Draw one side of the hexagon.
        l is side length
    """
    turtle.fd(l)
    turtle.rt(60)
Пример #8
0
def rogi(bok):
    gamma = 90 + 18
    beta = 360 / 5
    alpha = 180 - beta
    romb(bok)
    naGoreRombu(bok)
    turtle.lt(gamma)
    romb(bok)
    naGoreRombu(bok)
    turtle.rt(gamma)
    romb(bok)
    turtle.pu()
    turtle.rt(gamma)
    turtle.fd(bok)
    turtle.lt(beta)
    turtle.fd(60)
    turtle.rt(beta)
    turtle.pd()
    romb(bok)
    naGoreRombu(bok)
    turtle.lt(alpha)
    romb(bok)
    turtle.lt(beta)
    naGoreRombu(bok)
    turtle.lt(beta*1.5)
    naGoreRombu(bok)
    turtle.rt(180)
Пример #9
0
def takieCos(n):
    rotateUpwards = [0, 3, 4]
    rot = -90

    for j in range(0,2):
        # for j in range(0,2):
        turtle.fd(1.5*n)
        turtle.rt(-90)
        turtle.fd(n)
        turtle.rt(90)
        turtle.fd(n)
        turtle.rt(90)
        turtle.fd(n)
        turtle.rt(-90)
        turtle.fd(1.5*n)
        if (j in rotateUpwards):
            turtle.rt(-90)
        else:
            turtle.rt(90)
    turtle.rt((-1)*rot)
    # turtle.rt(180)


    takieCos(n)
    raw_input()
Пример #10
0
def ustNaStart(dlBokKw, ile):
    turtle.pu()
    turtle.bk(dlBokKw * ile / 2 +5)
    turtle.lt(90)
    turtle.fd(dlBokKw * (ile - 2) / 2 - 5)
    turtle.rt(90)
    turtle.pd()
Пример #11
0
def ustNaStart(r):
    turtle.lt(90)
    turtle.pu()
    turtle.rt(90)
    turtle.fd(r)
    turtle.lt(90)
    turtle.pd()
def main():
    turtle.setup(800, 350, 200, 200)
    turtle.penup()
    turtle.fd(-300)
    turtle.pensize(5)
    drawDate(datetime.datetime.now().strftime('%Y%m%d'))
    turtle.hideturtle()
def koch(size, n):
    if n == 0:
        turtle.fd(size)
    else:
        for angle in [0, 60, -120, 60]:
            turtle.left(angle)
            koch(size/3, n-1)
Пример #14
0
def tSquare(size, level):
    """ The T-Square fractal.
    http://en.wikipedia.org/wiki/T-Square_%28fractal%29
    """

    if level < 1:
        drawSquare(size, True)
    else:
        drawSquare(size, True)
        bk(size / 4.0)
        left(90)
        fd(size / 4.0)
        right(90)
        tSquare(size / 2.0, level - 1)
        up()
        fd(size)
        down()
        tSquare(size / 2.0, level - 1)
        right(90)
        fd(size)
        left(90)
        tSquare(size / 2.0, level - 1)
        bk(size)
        tSquare(size / 2.0, level - 1)
        left(90)
        up()
        fd(size * 3 / 4.0)
        down()
        right(90)
        fd(size / 4.0)
Пример #15
0
def draw_l(word):
    turtle.up()
    turtle.clear()
    turtle.setposition(0, 0)
    turtle.setheading(0)
    turtle.bk(INITIAL_POS[0])
    turtle.down()
    turtle.st()
    stack = []
    for char in word:
        if char == '0':
            turtle.fd(SIZE[0])
        if char == '1':
            turtle.fd(SIZE[0])
        if char == '[':
            stack.append((turtle.position(), turtle.heading()))
            turtle.lt(45)
        if char == ']':
            position, heading = stack.pop()
            turtle.up()
            turtle.setposition(position)
            turtle.setheading(heading)
            turtle.rt(45)
            turtle.down()
    turtle.ht()
Пример #16
0
def turmandel(step, zoom, xres, yres, xthresh, ythresh):
  turtle.setheading(0)
  for y in range(yres):
    turtle.pu()
    turtle.setpos(0, y)
    turtle.pd()
    for x in range(xres):
      x = float(x)
      y = float(y)
      u = float(x)/float((xres/zoom))-xthresh
      v = float(y)/float((yres/zoom))-ythresh
      x0 = float(u)
      y0 = float(v)
      a = 0.0
      b = 0.0
      i = step
      while ((i>0) and (a+b<=4.0)):
        a = float(x0*x0)
        b = float(y0*y0)
        y0 = float(2.0*x0*y0+v)
        x0 = float(a-b+u)
        i = i - 1
      color = i % 255
      turtle.pencolor((color, color, color))
      if i < 1:
        turtle.pencolor((0,0,0))
      turtle.fd(1)
Пример #17
0
def jeden():
    turtle.fd(50)
    turtle.fillcolor(randint(0,255),randint(0,255),randint(0,255))
    turtle.begin_fill()
    kwadrat(50)
    turtle.end_fill()
    turtle.bk(50)
Пример #18
0
def naGoreWiezy(bokProst1, bokTroj):
    turtle.pu()
    turtle.fd(bokProst1)
    turtle.rt(30)
    turtle.fd(bokTroj)
    turtle.lt(30)
    turtle.pd()
Пример #19
0
def okoP(a):
    turtle.begin_fill()
    wielokat(6, a *4, 4)
    turtle.end_fill()
    turtle.rt(180)
    turtle.fd(a * 4)
    turtle.lt(360 / 6)
    turtle.fd(a * 4)
    turtle.lt(360 / 6)
    turtle.fd(a * 4)
    turtle.colormode(255)
    turtle.fillcolor(255, 255, 255)
    turtle.rt(180)
    turtle.fd(a)
    turtle.rt(120)
    turtle.begin_fill()
    wielokat(6, 2 * a, 4)
    turtle.end_fill()
    turtle.rt(60)
    turtle.fd(a / 2)
    turtle.rt(120)
    turtle.fillcolor(0, 0, 0)
    turtle.begin_fill()
    wielokat(6, a, 4)
    turtle.end_fill()
Пример #20
0
def drawSquare(myTurtle):
    count = 0
    while count < 4:
        turtle.fd(20)
        turtle.left(90)
        count = count + 1
    turtle.right(90)
Пример #21
0
def rowOfShapes(number):
    for x in xrange(number):
        hexaTrangle(25,90,randomColor(),randomColor())
        turtle.left(90)
        turtle.pu()
        turtle.fd(15)
        turtle.pd()
Пример #22
0
def sier(n,length):
    if (n==0):
        return
    for i in range(3):
        sier(n-1, length/2)
        t.fd(length)
        t.rt(120)
Пример #23
0
def ustDoNastElem(dlBokMalKw):
    turtle.pu()
    turtle.rt(90)
    turtle.fd(dlBokMalKw * 5)
    turtle.lt(90)
    turtle.fd(dlBokMalKw)
    turtle.pd()
Пример #24
0
 def test_zigzag(self):
     """
     Test that a AsyncTurtle ends up in the correct position
     after several concurrent commands in sequence, and draws
     a zigzag line on the canvas.
     """
     turtle = AsyncTurtle(loop=self.loop)
     tasks = [
         asyncio.ensure_future(turtle.fd(10), loop=self.loop),
         asyncio.ensure_future(turtle.lt(90), loop=self.loop),
         asyncio.ensure_future(turtle.fd(10), loop=self.loop),
         asyncio.ensure_future(turtle.rt(90), loop=self.loop),
         asyncio.ensure_future(turtle.fd(10), loop=self.loop)
     ]
     self.loop.run_until_complete(asyncio.wait(tasks, loop=self.loop))
     self.loop.close()
     self.assertEqual(turtle.pos()[0], 20)
     self.assertEqual(turtle.pos()[1], 10)
     expected_coords = [
         0.0, 0.0,
         10.0, 0.0,
         10.0, -10.0,
         20.0, -10.0
     ]
     # Assume the last item id on the canvas is the line
     # drawn by the turtle. Check if this assumption is valid.
     line_id = max(turtle.screen.cv.find_all())
     self.assertEqual(turtle.screen.cv.coords(line_id), expected_coords)
Пример #25
0
def ustDoKwadratu(dlBokKw):
    turtle.pu()
    turtle.fd(dlBokKw * 2)
    turtle.lt(90)
    turtle.fd(dlBokKw * 2)
    turtle.lt(90)
    turtle.pd()
Пример #26
0
def skidMark(lineLength):
    turtle.pensize(2)
    turtle.pencolor(0, 0, 0)
    for x in range(lineLength):
        turtle.pencolor(x,x,x)
        turtle.fd(x)
        turtle.right(90)
Пример #27
0
def ustDoElki(dlBokKw, bokKr):
    turtle.pu()
    turtle.fd(bokKr - dlBokKw)
    turtle.lt(90)
    turtle.fd(dlBokKw)
    turtle.lt(90)
    turtle.pd()
Пример #28
0
def ustDo2Elki(dlBokKw, bokKr, bokDl):
    turtle.pu()
    turtle.fd(bokKr - dlBokKw *2)
    turtle.rt(90)
    turtle.fd(bokDl - dlBokKw*2)
    turtle.rt(90)
    turtle.pd()
Пример #29
0
 def cuadrado(lado, color):
     turtle.color(color)
     turtle.begin_fill()
     for _ in xrange(4):
         turtle.fd(lado)
         turtle.right(90)
     turtle.end_fill()
Пример #30
0
def ustNaStart(a):
    turtle.pu()
    turtle.bk(a)
    turtle.lt(90)
    turtle.fd(a / 2)
    turtle.rt(90)
    turtle.pd()
Пример #31
0
def drawline(draw):
    drawGap()
    turtle.pendown() if draw else turtle.penup()
    turtle.fd(40)
    drawGap()
    turtle.right(90)
Пример #32
0
sides = int(input("How many sides would you like? "))
angle = 360 / sides

import turtle

for count in range(sides):
    turtle.fd(50)
    turtle.lt(angle)

mainloop()
Пример #33
0
def drawGap():
    turtle.penup()
    turtle.fd(7)
Пример #34
0
def zhi():
    for i in range(0,2):
        t.fd(30)
        t.lt(30)
        t.fd(10)
        t.bk(10)
        t.rt(60)
        t.fd(10)
        t.bk(10)
        t.lt(30)
    t.fd(30)
    t.rt(30)
    for i in range(0,2):
        t.fd(10)
        t.lt(60)
        t.fd(10)
        t.lt(120)
    t.lt(30)
    t.bk(90)
    return
Пример #35
0
def draw_bowties(size, depth):
    """
    Takes the parameters size (size of the bow tie) and depth (recursive depth
    of the function) and draws multiple bow ties recursively.
    Pre-Conditions: Turtle is up, facing east. Located at
    the center of the largest bow tie.
    Post-Conditions: Turtle is up, facing east. Located at
    the center of the largest bow tie.
    :param size: Size of the largest drawn bow tie.
    :param depth: Depth of the recursive function.
    :return: 0
    """
    if depth <= 0:
        pass
    else:
        draw_bowtie(size)
        tt.left(30)
        tt.fd(2 * size)
        draw_bowties(size / 3, depth - 1)
        tt.fd(-2 * size)
        tt.left(120)
        tt.fd(2 * size)
        tt.left(180)
        draw_bowties(size / 3, depth - 1)
        tt.fd(2 * size)
        tt.left(30)
        tt.right(30)
        tt.fd(2 * size)
        draw_bowties(size / 3, depth - 1)
        tt.fd(-2 * size)
        tt.right(120)
        tt.fd(2 * size)
        tt.right(180)
        draw_bowties(size / 3, depth - 1)
        tt.fd(2 * size)
        tt.right(30)
Пример #36
0
def draw_bowtie(size):
    """
    Draws one bow tie shape on the canvas.
    Pre-Conditions: Turtle is up, facing east. Located at
    the center of the bow tie about to be drawn. Pen color black.
    Post-Conditions: Turtle is up, facing east. Located at
    the center of the bow tie just drawn. Pen color black, fill color orange.
    :param size: Accepts any number value for the size of the bow tie.
    :return: 0
    """
    tt.down()
    tt.left(30)
    tt.fd(size)
    tt.right(120)
    tt.fd(size)
    tt.right(120)
    tt.fd(2 * size)
    tt.left(120)
    tt.fd(size)
    tt.left(120)
    tt.fd(size)
    tt.right(30)
    tt.up()
    tt.fillcolor("orange")
    tt.right(90)
    tt.fd(size/4)
    tt.left(90)
    tt.down()
    tt.begin_fill()
    tt.circle(size/4)
    tt.end_fill()
    tt.up()
    tt.left(90)
    tt.fd(size/4)
    tt.right(90)
Пример #37
0
def drawline(draw):  #绘制单段数码管
    p.pendown() if draw else p.penup()
    p.fd(40)
    p.right(90)
Пример #38
0
    t.down()
    for i in range(n):
        t.fd(a)
        t.lt(360 / n)
    t.up()
    t.lt(90)
    t.fd(r)


t.color("yellow")
t.begin_fill()
circle(100)
t.end_fill()
t.color("blue")
t.rt(45)
t.fd(70)
t.begin_fill()
circle(8)
t.end_fill()
t.fd(70)
t.lt(90)
t.fd(70)
t.begin_fill()
circle(8)
t.end_fill()
t.fd(70)
t.lt(45)
t.width(10)
t.color("black")
t.pendown()
t.fd(20)
import turtle

#penup画笔提起函数
turtle.penup()
turtle.fd(100)

#pendown画笔放下来的函数,与penup对应使用
turtle.down()
turtle.circle(100, 360)

#pensize()函数主要用来设置画笔的粗细
turtle.pensize(10)
turtle.fd(100)
turtle.pensize(1)
turtle.fd(100)

#color函数用来设置画笔的颜色
turtle.color("red")
turtle.fd(100)

#begin_fill函数用;来填充一定的颜色,它必须和end_fill混合使用才会有效
turtle.begin_fill()
turtle.color("red")
turtle.circle(100)
print(turtle.filling())  #在填充的过程中是填充的状态,所以输出应该为true
turtle.end_fill()
print(turtle.filling())  #画结束之后输出为false
#filling函数的功能是返回填充的状态,true或者false

#clear()函数主要用来清空当前画布的图,但是并不改变画笔当前的位置,只保留下画笔当前的位置
#turtle.clear()
Пример #40
0
import turtle as t
t.color("#2dbb96")
t.goto(100,0)
for i in range(50):
    t.left(80)
    t.fd(100)
    t.left(135)
    t.fd(105)
Пример #41
0
def Abajo():
    t.seth(270)
    t.fd(10)
Пример #42
0
def Izquierda():
    t.seth(180)
    t.fd(10)
Пример #43
0
def Arriba():
    t.seth(90)
    t.fd(10)
Пример #44
0
def Derecha():
    t.seth(0)
    t.fd(10)
Пример #45
0
def main():
    turtle.pensize(2)
    turtle.pencolor("black")
    turtle.up()
    turtle.left(180)
    turtle.fd(50)
    turtle.left(90)
    turtle.fd(200)
    turtle.right(180)
    turtle.down() #all getting into starting position to draw card
    drawCard() #draws first card
    turtle.fd(140)
    turtle.left(90)
    turtle.fd(140)
    turtle.right(90) #centers turtle in order to write letter or number in center
    turtle.down()
    turtle.pencolor("red")
    turtle.write("K", align="center", font=( "Arial", 100, "bold")) #writes K
    turtle.up()
    turtle.fd(200)
    turtle.left(90)
    turtle.fd(120)
    turtle.right(90) #moves to top right corner to draw first diamond
    turtle.fillcolor("red")
    drawDiamond() #draws first diamond
    turtle.right(90)
    turtle.fd(240)
    turtle.right(90)
    turtle.fd(330)
    turtle.right(180)#moves to bottom left corner to draw second diamond
    drawDiamond() #draws second diamond
    turtle.right(180)
    turtle.fd(10)
    turtle.left(90)
    turtle.fd(390)
    turtle.left(90)#moves into position to draw second card
    turtle.down()
    turtle.pencolor("black") #change pen back to black
    drawCard() #draws second card
    turtle.fd(140)
    turtle.left(90)
    turtle.fd(140)
    turtle.right(90)  # centers turtle in order to write letter or number in center
    turtle.down()
    turtle.write("8", align="center", font=("Arial", 100, "bold"))  # writes 8
    turtle.up()
    turtle.fd(190)
    turtle.left(90)
    turtle.fd(100)
    turtle.right(90) #moves turtle to top right to draw first heart
    turtle.fillcolor("black")
    drawTriangle() #draws bottom of heart
    turtle.fd(40)
    drawCircle() #draws left bump of heart
    turtle.right(90)
    turtle.fd(20)
    turtle.left(90) #moves to right to do second bump on heart
    drawCircle() #draws second bump of heart
    turtle.right(90)
    turtle.fd(180)
    turtle.right(90)
    turtle.fd(350)
    turtle.right(180)
    drawTriangle()  # draws bottom of heart
    turtle.fd(40)
    drawCircle()  # draws left bump of heart
    turtle.right(90)
    turtle.fd(20)
    turtle.left(90)  # moves to right to do second bump on heart
    drawCircle()  # draws second bump of heart
    turtle.done()
Пример #46
0
def drawLineRight(draw):
    turtle.right(90)
    drawGap()
    turtle.pendown() if draw else turtle.penup()
    turtle.fd(40)
    drawGap()
Пример #47
0
import turtle as t
import random  # 랜덤함수를 생성
a = random.randint(0, 359)  #a는 0도부터 359도까지 랜덤 설정

#벽만들기
t.speed(0)  #가장 빠르게
t.up()  #꼬리들기
t.goto(-250, -250)  #벽을 그리기 위해 시작점으로 이동
t.down()  #꼬리내리기
for x in range(4):
    t.fd(500)
    t.lt(90)
#거북이 중앙으로 가기
t.up()
t.home()
t.down()
#랜덤 설정된 각도로 회전후 벽까지 이동
t.seth(a)
while -250 < t.xcor() < 250 and -250 < t.ycor() < 250:
    t.fd(1)  # 벽에 부딪히기 전까지 앞으로 1만큼씩 이동
#while True: #아래를 무한 반복
#a=t.heading()
if 0 < a < 45:
    t.lt(180 - 2 * a)
    t.fd(1)
    while -250 < t.xcor() < 250 and -250 < t.ycor() < 250:
        t.fd(1)
if 45 < a < 90:
    t.rt(2 * a)
    t.fd(1)
    while -250 < t.xcor() < 250 and -250 < t.ycor() < 250:
Пример #48
0
""" Нарисуйте, используя модуль turtle число:
3549
"""
import turtle as t

t.setup(800, 800)
t.width(5)
t.color('#ff0004')
t.speed(2)

for three in range(1):
    t.down()
    t.fd(50)
    t.left(60)
    t.bk(60)
    t.right(60)
    t.fd(30)
    t.left(90)
    t.bk(50)
    t.right(90)
    t.bk(50)
    t.up()

for five in range(1):
    t.goto(70, 0)
    t.down()
    t.fd(50)
    t.bk(50)
    t.right(90)
    t.fd(50)
    t.left(90)
Пример #49
0
 def x(n):
     if n == 0:
         return x(n - 1)
     turtle.rt(90)
     y(n - 1)
     turtle.fd(l)
Пример #50
0
# coding: utf-8
# https://blog.csdn.net/qq_38784098/article/details/82017601

import turtle as t

t.pensize(1)

for i in range(1,300,2):
	t.left(90)
	t.fd(i*2)
 
Пример #51
0
# coding:utf-8
import turtle as t

t.title("自动轨迹绘制")
t.setup(800, 600, 0, 0)
t.pencolor("red")
t.pensize(5)

# 数据读取
datas = []
f = open("data.txt")
for line in f:
    line = line.replace("\n", "")
    datas.append(list(map(eval, line.split(","))))
f.close()
# 自动绘制
for i in range(len(datas)):
    t.pencolor(datas[i][3], datas[i][4], datas[i][5])
    t.fd(datas[i][0])
    if datas[i][1]:
        t.right(datas[i][2])
    else:
        t.left(datas[i][2])
t.done()

# 300,0,144,1,0,0
# 300:行进距离,1:转向判断(0:左转,1:右转),144:转向角度1,0,0:RGB三个通道颜色,0~1之间浮点数
Пример #52
0
def drawLineLeft(draw):
    turtle.left(90)
    drawGap()
    turtle.pendown() if draw else turtle.penup()
    turtle.fd(40)
    drawGap()
Пример #53
0
def foot():
    t.pensize(10)
    t.color((240,128,128))
    t.pu()
    t.seth(90)
    t.fd(-75)
    t.seth(0)
    t.fd(-180)
    t.pd()
    t.seth(-90)
    t.fd(40)
    t.seth(-180)
    t.color("black")
    t.pensize(15)
    t.fd(20)
    t.pensize(10)
    t.color((240,128,128))
    t.pu()
    t.seth(90)
    t.fd(40)
    t.seth(0)
    t.fd(90)
    t.pd()
    t.seth(-90)
    t.fd(40)
    t.seth(-180)
    t.color("black")
    t.pensize(15)
    t.fd(20)
Пример #54
0
def eye():
    t.color((255,155,192),"white")
    t.pu()
    t.seth(90)
    t.fd(-20)
    t.seth(0)
    t.fd(-95)
    t.pd()
    t.begin_fill()
    t.circle(15)
    t.end_fill()
    t.color("black")
    t.pu()
    t.seth(90)
    t.fd(12)
    t.seth(0)
    t.fd(-3)
    t.pd()
    t.begin_fill()
    t.circle(3)
    t.end_fill()
    t.color((255,155,192),"white")
    t.pu()
    t.seth(90)
    t.fd(-25)
    t.seth(0)
    t.fd(40)
    t.pd()
    t.begin_fill()
    t.circle(15)
    t.end_fill()
    t.color("black")
    t.pu()
    t.seth(90)
    t.fd(12)
    t.seth(0)
    t.fd(-3)
    t.pd()
    t.begin_fill()
    t.circle(3)
    t.end_fill()
Пример #55
0
def hand():
    t.color((255,155,192))
    t.pu()
    t.seth(90)
    t.fd(-40)
    t.seth(0)
    t.fd(-27)
    t.pd()
    t.seth(-160)
    t.circle(300,15)
    t.pu()
    t.seth(90)
    t.fd(15)
    t.seth(0)
    t.fd(0)
    t.pd()
    t.seth(-10)
    t.circle(-20,90)
    t.pu()
    t.seth(90)
    t.fd(30)
    t.seth(0)
    t.fd(237)
    t.pd()
    t.seth(-20)
    t.circle(-300,15)
    t.pu()
    t.seth(90)
    t.fd(20)
    t.seth(0)
    t.fd(0)
    t.pd()
    t.seth(-170)
    t.circle(20,90)
Пример #56
0
#AutoTraceDraw.py
import turtle as t
t.title('自动归集绘制')
t.setup(800, 600, 0, 0)
t.pencolor("red")
t.pensize(5)
#数据读取
datals = []
f = open("data.txt")
for line in f:
    line = line.replace("\n", "")
    datals.append(list(map(eval, line.split(","))))
f.close()
#自动绘制
for i in range(len(datals)):
    t.pencolor(datals[i][3], datals[i][4], datals[i][5])
    t.fd(data[i][0])
    if datals[i][1]:
        t.right(datals[i][2])
    else:
        t.left(datals[i][2])
Пример #57
0
import turtle
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
turtle.circle(40, 40)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2 / 3)
Пример #58
0
import turtle
turtle.fd(250)
turtle.pendown()
turtle.seth(120)
turtle.fd(250)
turtle.seth(-120)
turtle.fd(250)
Пример #59
0
'''
自动轨迹绘制
1、定义数据文件格式(接口)
2、编写程序,根据文件接口解析参数绘制图形
3、编制数据文件
'''
#autotracedraw.py
import turtle as t
t.title('自动绘制')
t.setup(800, 600, 0, 0)  #绘制窗口的大小
t.pencolor("red")  #画笔的初始颜色
t.pensize(5)  #画笔的大小
#数据文件的读取
datals = []
f = open("data.txt")
for line in f:
    line = line.replace("\n", "")
    datals.append(list(map(eval, line.split(","))))
    #list map eval 作用是去掉字符串中的引号
    #f.close()

#自动绘制
for i in range(len(datals)):
    t.pencolor(datals[i][3], datals[i][4], datals[i][5])
    t.fd(datals[i][0])  #表示一行的第一个元素表示行进距离
    if datals[i][1]:
        t.right(datals[i][2])
    else:
        t.left(datals[i][2])
f.close()
Пример #60
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.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255, 155, 192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160, 82, 45)
t.end_fill()