예제 #1
0
def plansza(bok):
    bokMalKw = bok/7
    rDuzKol = bokMalKw
    rMalKol = bokMalKw/2
    numPowPlus = 1
    numPowKola = 1
    ustNaStart(bok)
    turtle.pu() ##W figurach nie ma krawędzi
    duzyKwadrat(bok)
    ustDoPlusa(bokMalKw)
    while numPowPlus <= 4:
        plus(bokMalKw, rMalKol)
        turtle.rt(90)
        turtle.fd(bokMalKw)
        numPowPlus = numPowPlus + 1
    ustDoKol(bokMalKw)
    turtle.fillcolor(250, 250, 0)
    while numPowKola <= 4:
        turtle.rt(90)
        turtle.fd(bokMalKw)
        turtle.lt(180)
        turtle.begin_fill()
        turtle.circle(rDuzKol)
        turtle.end_fill()
        turtle.lt(180)
        turtle.fd(bokMalKw * 6)
        numPowKola = numPowKola + 1
    turtle.pd()
예제 #2
0
def ustNaStart(r):
    turtle.lt(90)
    turtle.pu()
    turtle.rt(90)
    turtle.fd(r)
    turtle.lt(90)
    turtle.pd()
예제 #3
0
def circle(x,y,size):
	turtle.pu()
	turtle.goto(x,y)
	turtle.pd()
	turtle.begin_fill()
	turtle.circle(size)
	turtle.end_fill()
def line(a1,b1,a2,b2,c):
    turtle.pu()
    turtle.goto(a1,b1)
    turtle.color(c)
    turtle.pd()
    turtle.pensize(10)
    turtle.goto(a2,b2)
예제 #5
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()
예제 #6
0
def ustDoPOka(a):
    turtle.rt(60)
    turtle.bk(a * 1.5)
    turtle.lt(60)
    turtle.pu()
    turtle.rt(180)
    turtle.fd(4 * a)
    turtle.lt(60)
    turtle.fd(4 * a)
    turtle.lt(60)
    turtle.fd(4 * a)
    turtle.rt(60)
    turtle.fd(4 * a)
    turtle.lt(60)
    turtle.lt(360 / 12)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.lt(60)
    turtle.fd(4 * a)
    turtle.lt(60)
    turtle.fd(a * 4)
    turtle.pd()
예제 #7
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)
예제 #8
0
def ustDoElki(dlBokKw, bokKr):
    turtle.pu()
    turtle.fd(bokKr - dlBokKw)
    turtle.lt(90)
    turtle.fd(dlBokKw)
    turtle.lt(90)
    turtle.pd()
예제 #9
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()
예제 #10
0
def ustNaStartKwiatki(rozmKanwy, segment):
    turtle.pu()
    turtle.bk(225)
    turtle.lt(90)
    turtle.bk(225)
    turtle.rt(90)
    turtle.pd()
예제 #11
0
def draw_triangle(x,y):
	turtle.penup()
	turtle.goto(x,y)
	turtle.pd()
	turtle.goto(x+25,y+50)
	turtle.goto(x+50,y)
	turtle.goto(x,y)
예제 #12
0
def ustNaStart(a):
    turtle.pu()
    turtle.bk(a)
    turtle.lt(90)
    turtle.fd(a / 2)
    turtle.rt(90)
    turtle.pd()
예제 #13
0
def draw_triangle(x,y):
	turtle.pu()
	turtle.goto(x,y)
	turtle.pd()
	turtle.goto(x+60,y+85)
	turtle.goto(x+85,y)
	turtle.goto(x,y)
예제 #14
0
def ustDoNastKraw(ile, bokKw=10):
    turtle.pu()
    turtle.lt(90)
    turtle.fd(bokKw)
    turtle.rt(90)
    turtle.rt(180)
    turtle.pd()
예제 #15
0
def rowOfShapes(number):
    for x in xrange(number):
        hexaTrangle(25,90,randomColor(),randomColor())
        turtle.left(90)
        turtle.pu()
        turtle.fd(15)
        turtle.pd()
예제 #16
0
def ustDoKwadratu(dlBokKw):
    turtle.pu()
    turtle.fd(dlBokKw * 2)
    turtle.lt(90)
    turtle.fd(dlBokKw * 2)
    turtle.lt(90)
    turtle.pd()
예제 #17
0
def linha(x1,y1,x2,y2):
    """ Traça uma linha entre dois pontos."""
    turtle.up()
    turtle.goto(x1,y1)
    turtle.pd()
    turtle.goto(x2,y2)
    turtle.up()
예제 #18
0
def stam(x,y):
    turtle.begin_fill()
    turtle.pu()
    turtle.goto(x,y)
    turtle.pd()
    turtle.circle(10)
    turtle.end_fill()
예제 #19
0
def ustDoNosa(a):
    turtle.pu()
    turtle.rt(60)
    turtle.bk(1.5 * a)
    turtle.fd(4 * a)
    turtle.lt(360 / 6)
    turtle.fd(4 * a)
    turtle.lt(360 / 6)
    turtle.fd(4 * a)
    turtle.lt(360 / 6)
    turtle.rt(180)
    turtle.lt(60)
    turtle.fd(a * 4)
    turtle.lt(120)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.fd(a * 8)
    turtle.lt(360 / 12)
    turtle.lt(60)
    turtle.fd(8 * a)
    turtle.lt(30)
    turtle.lt(360 / 6)
    turtle.fd(2 * a)
    turtle.rt(360 / 6)
    turtle.fd(2 * a)
    turtle.rt(360/ 6)
    turtle.fd(a * 2)
    turtle.lt(360 / 6)
    turtle.pd()
예제 #20
0
def ustDoNastElem(dlBokMalKw):
    turtle.pu()
    turtle.rt(90)
    turtle.fd(dlBokMalKw * 5)
    turtle.lt(90)
    turtle.fd(dlBokMalKw)
    turtle.pd()
def circle(a,b):
    turtle.color("green")
    turtle.pu()
    turtle.goto(a,b)
    turtle.pd()
    turtle.setheading(90)
    turtle.circle(40)
예제 #22
0
def naGoreWiezy(bokProst1, bokTroj):
    turtle.pu()
    turtle.fd(bokProst1)
    turtle.rt(30)
    turtle.fd(bokTroj)
    turtle.lt(30)
    turtle.pd()
예제 #23
0
def draw_circle(x,y,r,t):
    t.pu()
    t.goto(x+r,y)
    t.setheading(90)
    t.pd()
    t.circle(r)
    t.pu()
예제 #24
0
파일: neural2.py 프로젝트: glutzic/bob
	def doDraw(self, turtle):
		turtle.pu()
		turtle.setpos(self.x1, self.y1)
		turtle.pd()
		turtle.goto(self.x2, self.y2)
		turtle.pu()
		return
예제 #25
0
def korDuza(popr,ile):
    turtle.pu()
    turtle.bk(popr * ile)
    turtle.lt(90)
    turtle.bk(popr)
    turtle.rt(90)
    turtle.pd()
예제 #26
0
def draw():
	size = randint(40, 300)
	angles = (144, 150, 157.5, 160, 165)
	angle = sample(angles, 1)[0]
	
	colors = [
		('#922B21', '#E6B0AA'), ('#76448A', '#D2B4DE'), ('#1F618D', '#AED6F1'), ('#515A5A', '#EAEDED'),
		('#148F77', '#D1F2EB'), ('#B7950B', '#F7DC6F'), ('#F39C12', '#FDEBD0'), ('#BA4A00', '#F6DDCC')]
	color = sample(colors, 1)[0]
	tt.color(color[0], color[1])
	
	x_pos = randint(-200,200)
	y_pos = randint(-200,200)
	tt.pu()
	tt.setpos(x_pos, y_pos)
	start_position = tt.pos()
	tt.pd()
	
	tt.begin_fill()
	while True:
		tt.forward(size)
		tt.left(angle)
		if abs(tt.pos() - start_position) < 1:
			break
	tt.end_fill()
예제 #27
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)
예제 #28
0
 def cleardisk(self):
     turtle.pu()
     turtle.goto(self.x,self.y)
     turtle.pd()
     turtle.color("white","white")
     turtle.begin_fill()
     turtle.goto(self.x+(self.w/2),self.y)
     turtle.goto(self.x+(self.w/2),self.y-self.h)
     turtle.goto(self.x-(self.w/2),self.y-self.h)
     turtle.goto(self.x-(self.w/2),self.y)
     turtle.goto(self.x,self.y)
     turtle.end_fill()
     turtle.pu()
     turtle.pu()
     turtle.goto(self.x,self.y)
     turtle.pd()
     turtle.color("red","red")
     turtle.begin_fill()
     turtle.goto(self.x+(10/2),self.y)
     turtle.goto(self.x+(10/2),self.y-self.h)
     turtle.goto(self.x-(10/2),self.y-self.h)
     turtle.goto(self.x-(10/2),self.y)
     turtle.goto(self.x,self.y)
     turtle.end_fill()
     turtle.pu()
     return 0
예제 #29
0
def szach(n):
    ustNaStart()
    numPowX = 1
    numPowY = 1
    bok = floor(450 / n)
    while(numPowY <= n / 2):
        while(numPowX <= n / 2):
            parzDwaKwadraty(bok)
            numPowX = numPowX + 1
        korDuza(n)
        turtle.pu()
        turtle.lt(90)
        turtle.fd(bok)
        turtle.rt(90)
        turtle.pd()
        numPowX = 1
        while(numPowX <= n / 2):
            nieParzDwaKwadraty(bok)
            numPowX = numPowX + 1
        korDuza(n)
        turtle.pu()
        turtle.lt(90)
        turtle.fd(bok)
        turtle.rt(90)
        turtle.pd()
        numPowX = 1
        numPowY = numPowY + 1
예제 #30
0
def ustDoNastTetki(orient=1, bokKw=10):
    turtle.pu()
    turtle.rt(90*orient)
    turtle.fd(bokKw*2)
    turtle.lt(90*orient)
    turtle.fd(bokKw*3)
    turtle.pd()
예제 #31
0
def move_turtle():
    turtle.pd()
    while not (turtle.xcor() >= 75):
        drawSquare()
        turtle.setx(turtle.xcor() + 37.5)
예제 #32
0
def head():
    turtle.color('black')

    # 脸轮廓
    turtle.pd()  # 落笔
    turtle.circle(50)  # 画一个半径为50的圆
    turtle.pu()  # 提笔

    # 右耳轮廓
    turtle.goto(50, 60)  # 移动到x=50,y=60的位置
    turtle.pd()  # 落笔
    turtle.circle(30, 260)  # 画一个半径为30,角度为245的圆弧
    turtle.pu()  # 提笔
    # 右耳耳纹
    turtle.goto(30, 90)
    turtle.pd()
    turtle.seth(65)
    turtle.circle(-30, 70)
    turtle.pu()

    # 左耳轮廓
    turtle.goto(-50, 60)
    turtle.pd()
    turtle.seth(180)  # 设置方向为西,
    turtle.circle(-30, 260)
    turtle.pu()
    # 左耳耳纹
    turtle.goto(-30, 90)
    turtle.pd()
    turtle.seth(120)
    turtle.circle(30, 70)
    turtle.pu()

    # 面部五官
    # 右侧眉毛
    turtle.goto(5, 80)
    turtle.seth(20)
    turtle.pd()
    turtle.circle(-25, 40)
    turtle.pu()
    # 左侧眉毛
    turtle.goto(-5, 80)
    turtle.seth(160)
    turtle.pd()
    turtle.circle(25, 40)
    turtle.pu()

    # 右侧眼睛
    turtle.begin_poly()
    turtle.goto(8, 60)
    turtle.seth(45)
    turtle.pd()
    turtle.circle(-15, 120)
    turtle.pu()
    turtle.goto(8, 60)
    turtle.seth(40)
    turtle.pd()
    turtle.circle(-15, 100)
    turtle.pu()
    turtle.end_poly()

    # 左侧眼睛
    turtle.goto(-8, 60)
    turtle.seth(135)
    turtle.pd()
    turtle.circle(15, 120)
    turtle.pu()
    turtle.goto(-8, 60)
    turtle.seth(140)
    turtle.pd()
    turtle.circle(15, 100)
    turtle.pu()

    # 鼻子
    # 鼻子上瓣
    turtle.goto(-6, 45)
    turtle.seth(70)
    turtle.pd()
    turtle.circle(-6, 150)
    turtle.pu()
    # 鼻子下瓣
    turtle.goto(-6, 45)
    turtle.seth(-70)
    turtle.pd()
    turtle.circle(6, 150)
    turtle.pu()

    # 鼻线
    turtle.goto(0, 40)
    turtle.seth(270)
    turtle.pd()
    turtle.forward(7)
    turtle.pu()

    # 上嘴线
    turtle.seth(200)
    turtle.pd()
    turtle.circle(-15, 60)
    turtle.pu()

    turtle.goto(0, 33)
    turtle.seth(-20)
    turtle.pd()
    turtle.circle(15, 60)
    turtle.pu()

    # 下嘴线
    turtle.goto(10, 33)
    turtle.seth(260)
    turtle.pd()
    turtle.circle(-15, 65)
    turtle.pu()

    turtle.goto(-10, 33)
    turtle.seth(280)
    turtle.pd()
    turtle.circle(15, 65)
    turtle.pu()

    # 牙齿
    turtle.goto(4, 33)
    turtle.seth(270)
    turtle.pd()
    turtle.forward(4)
    turtle.seth(180)
    turtle.forward(8)
    turtle.seth(90)
    turtle.forward(4)
    turtle.pu()

    # 胡须
    turtle.pensize(2)
    turtle.goto(30, 30)
    turtle.seth(8)
    turtle.pd()
    turtle.circle(-60, 40)
    turtle.pu()

    turtle.goto(30, 25)
    turtle.seth(-5)
    turtle.pd()
    turtle.circle(-60, 40)
    turtle.pu()

    turtle.goto(-30, 30)
    turtle.seth(172)
    turtle.pd()
    turtle.circle(60, 40)
    turtle.pu()

    turtle.goto(-30, 25)
    turtle.seth(188)
    turtle.pd()
    turtle.circle(60, 40)
    turtle.pu()

    # 睫毛
    turtle.pensize(1)
    turtle.goto(30, 58)
    turtle.seth(20)
    turtle.pd()
    turtle.circle(20, 20)
    turtle.pu()

    turtle.pensize(1)
    turtle.goto(28, 62)
    turtle.seth(25)
    turtle.pd()
    turtle.circle(20, 12)
    turtle.pu()

    turtle.pensize(1)
    turtle.goto(-30, 58)
    turtle.seth(160)
    turtle.pd()
    turtle.circle(-20, 20)
    turtle.pu()

    turtle.pensize(1)
    turtle.goto(-28, 62)
    turtle.seth(165)
    turtle.pd()
    turtle.circle(-20, 12)
    turtle.pu()
예제 #33
0
def drawCircle(x,y,c='red'):
    p.pu()        # 抬起画笔
    p.goto(x, y)  # 绘制圆的起始位置
    p.pd()        # 放下画笔
    p.color(c)
    p.circle(30, 360)
예제 #34
0
puzzle_4 = [[0, 2, 4, 0], [1, 0, 0, 3], [4, 0, 0, 2],
            [0, 1, 3,
             0]]  # Solution: [[3,2,4,1],[1,4,2,3],[4,3,1,2],[2,1,3,4]]
puzzle_5 = [[0, 4, 2, 0], [2, 0, 0, 0], [0, 0, 0, 3],
            [0, 3, 1,
             0]]  # Solution: [[3,4,2,1],[2,1,3,4],[1,2,4,3],[4,3,1,2]]

all_puzzles = [puzzle_1, puzzle_2, puzzle_3, puzzle_4, puzzle_5]

# ---------------------------------------------   Start the game   ---------------------------------------------------------- #

while True:
    turtle.reset()  # Start with a clean canvas in case user wants to replay
    setWorld()
    game_won = False
    turtle.pd()
    drawGrid()

    turtle.pu()
    turtle.goto(-75, 0)
    turtle.pd()
    turtle.fd(150)
    turtle.pu()
    turtle.goto(0, 75)
    turtle.lt(270)
    turtle.pd()
    turtle.fd(150)
    turtle.pu()

    turtle.goto(-75, -75)
예제 #35
0
# coding:utf-8
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)

#鼻子  --test test2
t.pu()
t.goto(-100, 100)
t.pd()
t.seth(-30)
t.begin_fill()
a = 0.4
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  #向左转3度
        t.fd(a)  #向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

t.pu()
t.seth(90)
t.fd(25)
예제 #36
0
def drawLine(draw):
    turtle.pd() if draw else turtle.pu()
    turtle.fd(40)
    turtle.right(90)
예제 #37
0
 def pd(self):
     self.step += 1
     turtle.pd()
예제 #38
0
from turtle import *
import turtle

turtle.hideturtle()
turtle.bgcolor('black'), turtle.color('gray')
turtle.speed(0), turtle.delay(0)

turtle.pensize(1)
turtle.setup(width=2000, height=1080, startx=0, starty=0)
turtle.pu(), turtle.goto(-400, -400), turtle.pd()


def peano_curve(size, steps, orientation):
    X = 'XFYFX+F+YFXFY-F-XFYFX'
    Y = 'YFXFY-F-XFYFX+F+YFXFY'
    l = r = 90

    if steps == 0:
        return

    if orientation > 0:
        for i in X:
            if i == 'X':
                peano_curve(size, steps - 1, orientation)
            elif i == 'Y':
                peano_curve(size, steps - 1, -orientation)
            elif i == '+':
                turtle.left(90)
            elif i == '-':
                turtle.right(90)
            else:
예제 #39
0
def draw_rabbit():
    # 绘制大耳朵兔
    turtle.speed(10)

    # 小兔的面部
    turtle.color('pink')
    turtle.pensize(5)
    turtle.circle(radius=100)  # 脸

    # 眼睛
    turtle.pencolor('black')
    # 左眼
    turtle.pu()
    turtle.goto(-45, 92)
    turtle.pd()
    turtle.begin_fill()
    turtle.color((0, 0, 0), (0, 0, 0.1))
    turtle.circle(radius=15)
    # 右眼
    turtle.pu()
    turtle.goto(45, 92)
    turtle.pd()
    turtle.circle(radius=15)
    turtle.end_fill()

    # 鼻子
    turtle.pu()
    turtle.goto(20, 60)
    turtle.color('pink')
    turtle.pd()
    turtle.begin_fill()
    turtle.goto(-20, 60)
    turtle.goto(0, 45)
    turtle.goto(20, 60)
    turtle.end_fill()

    # 嘴
    turtle.goto(0, 45)
    turtle.goto(0, 40)
    turtle.seth(-90)
    turtle.circle(10, 120)
    turtle.pu()
    turtle.goto(0, 40)
    turtle.seth(-90)
    turtle.pd()
    turtle.circle(-10, 120)

    # 小兔的耳朵
    # 左耳
    turtle.pu()
    turtle.goto(-60, 180)  #
    turtle.seth(200)
    turtle.pd()
    turtle.circle(radius=350, extent=90)
    turtle.goto(-98, 110)
    # 右耳
    turtle.pu()
    turtle.goto(60, 180)  #
    turtle.seth(-20)
    turtle.pd()
    turtle.circle(radius=-350, extent=90)
    turtle.goto(98, 110)

    # 小兔的身体
    turtle.pu()
    turtle.goto(20, 3)
    turtle.seth(-25)
    turtle.pd()
    turtle.circle(radius=-250, extent=25)
    turtle.circle(radius=-135, extent=260)
    turtle.seth(50)
    turtle.circle(radius=-250, extent=25)

    ##小兔的胳膊
    # 左臂
    turtle.pu()
    turtle.seth(180)
    turtle.goto(-30, -3)
    turtle.pd()
    # 小短胳膊
    ##circle(radius=270,extent=20)
    ##circle(radius=20,extent=190)
    turtle.circle(radius=248, extent=30)
    turtle.circle(radius=29, extent=185)
    # 右臂
    turtle.pu()
    turtle.seth(0)
    turtle.goto(30, -3)
    turtle.pd()
    turtle.circle(radius=-248, extent=30)
    turtle.circle(radius=-27, extent=184)

    ##小兔的脚
    ##左脚
    turtle.pu()
    turtle.goto(-162, -260)  #
    turtle.pd()
    turtle.seth(0)
    turtle.circle(radius=41)
    # 右脚
    turtle.pu()
    turtle.goto(164, -260)
    turtle.pd()
    turtle.circle(radius=41)

    turtle.done()
    turtle.exitonclick()
예제 #40
0
# coding:utf-8
import turtle as t
t.pensize(4)  # set the pen size 设置画笔的大小
t.colormode(255)  #  set the color of GBK 设置GBK颜色范围为0-255
t.color((255, 155, 192),
        "pink")  # set the pen color(pink) and fill it 设置画笔颜色和填充颜色(pink)
t.setup(840, 500)  # set the size of main window 设置主窗口的大小为840*500
t.speed(20)  # set the speed of drawing 设置画笔速度为10

# draw Peppa Pig's nose
t.pu()  # use the pen 提笔
t.goto(-100, 100)  # go to (-100, 100) 画笔前往坐标(-100,100)
t.pd()  # begin to draw 下笔
t.seth(-30)  # set the angle of the pen (-30°) 笔的角度为-30°
t.begin_fill()  # the signal to fill the figure 外形填充的开始标志
a = 0.4  # preset the step length
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  # turn left 3 degrees向左转3度
        t.fd(a)  # go forward step "a" 向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()  # fill the color 依据轮廓填充

# draw Peppa Pig's nostrils
t.pu()  # use the pen提笔
t.seth(90)  # set the angle of the pen(90°) 笔的角度为90度
t.fd(25)  # go forward 25 steps 向前移动25
예제 #41
0
def tp(x, y):
    t.pu()
    t.goto(x, y)
    t.pd()
예제 #42
0
from turtle import *
import turtle

turtle.hideturtle()
turtle.bgcolor('black')
turtle.color('grey')
turtle.speed(0)
turtle.delay(0)

turtle.pensize(0.2)
turtle.setup(width=1900, height=1080, startx=0, starty=0)
turtle.pu(), turtle.goto(-500, -40), turtle.pd()

ls = [90, -90, -90, -90, 90, 90, 90, -90, 0]


def peano_curve(size, recursive_steps, ls):
    '''Draws the original Peano space-filling
	curve.  Try different recursive_steps values 
	to view the development of this curve!
	'''

    if recursive_steps > 0:
        for i in range(len(ls)):
            peano_curve(size, recursive_steps - 1, [i for i in ls])
            turtle.left(ls[i])
    else:
        turtle.forward(size)


peano_curve(5, 5, ls)
예제 #43
0
def drawLine(draw):
    drawGap()
    t.pd() if draw else t.pu()
    t.fd(40)
    drawGap()
    t.right(90)
예제 #44
0
# coding:utf-8
import turtle as t
# 绘制小猪佩奇
# =======================================

t.pensize(4)  #画笔宽度
# t.hideturtle()  #隐藏箭头显示
t.colormode(255)  #RGB整数模式
t.color((255, 155, 192), "pink")  #同时设置pencolor=color1, fillcolor=color2
t.setup(840, 500)  #设置窗体的位置和大小
t.speed(10)  #设置画笔移动速度,画笔绘制的速度范围[0,10]整数, 数字越大越快

# 鼻子
t.pu()  #画笔抬起,不留下痕迹
t.goto(-100, 100)  #指从当前的点指向括号内所给坐标
t.pd()  #画笔落下,留下痕迹
t.seth(-30)  #改变行进方向(角度)
t.begin_fill()
a = 0.4
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长  指沿着海龟的前方向运行
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
        t.end_fill()

t.pu()
예제 #45
0
def pd():
    turtle.pd()
예제 #46
0
def head():
    """
         头部
    :return:
    """
    # 头

    t.color((255, 155, 192), "pink")

    t.pu()

    t.seth(90)

    t.fd(41)

    t.seth(0)

    t.fd(0)

    t.pd()

    t.begin_fill()

    t.seth(180)

    t.circle(300, -30)

    t.circle(100, -60)

    t.circle(80, -100)

    t.circle(150, -20)

    t.circle(60, -95)

    t.seth(161)

    t.circle(-300, 15)

    t.pu()

    t.goto(-100, 100)

    t.pd()

    t.seth(-30)

    a = 0.4

    for i in range(60):

        if 0 <= i < 30 or 60 <= i < 90:

            a = a + 0.08

            t.lt(3)  # 向左转3度

            t.fd(a)  # 向前走a的步长

        else:

            a = a - 0.08

            t.lt(3)

            t.fd(a)

    t.end_fill()
예제 #47
0
def drawLine(draw):
    drawGap()
    turtle.pd() if draw else turtle.pu()  # 如果需要画则按下画笔,否则抬起
    turtle.fd(30)
    drawGap()
    turtle.right(90)
예제 #48
0
def eye():
    """
        眼睛
    :return:
    """
    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()
예제 #49
0
def drawline(x1, y1, x2, y2):
    t.pu()
    t.goto(x1, y1)
    t.pd()
    t.goto(x2, y2)
    t.pu()
예제 #50
0
def bizi():
    # 鼻子

    t.pu()

    t.goto(-100, 100)

    t.pd()

    t.seth(-30)

    t.begin_fill()

    a = 0.4

    for i in range(120):

        if 0 <= i < 30 or 60 <= i < 90:

            a = a + 0.08

            t.lt(3)  # 向左转3度

            t.fd(a)  # 向前走a的步长

        else:

            a = a - 0.08

            t.lt(3)

            t.fd(a)

    t.end_fill()

    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()

    t.pu()

    t.seth(0)

    t.fd(20)

    t.pd()

    t.pencolor(255, 155, 192)

    t.seth(10)

    t.begin_fill()

    t.circle(5)

    t.color(160, 82, 45)

    t.end_fill()
예제 #51
0
import turtle
# coding:utf-8
import turtle as t

t.pensize(4)  # 设置画笔的大小
t.colormode(255)  # 设置GBK颜色范围为0-255
t.color((255, 155, 192), "pink")  # 设置画笔颜色和填充颜色(pink)
t.setup(840, 500)  # 设置主窗口的大小为840*500
t.speed(10)  # 设置画笔速度为10
#鼻子
t.pu()  # 提笔
t.goto(-100, 100)  # 画笔前往坐标(-100,100)
t.pd()  # 下笔
t.seth(-30)  # 笔的角度为-30°
t.begin_fill()  # 外形填充的开始标志
a = 0.4
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  #向左转3度
        t.fd(a)  #向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()  # 依据轮廓填充
t.pu()  # 提笔
t.seth(90)  # 笔的角度为90度
t.fd(25)  # 向前移动25
t.seth(0)  # 转换画笔的角度为0
t.fd(10)
예제 #52
0
def hands():
    """
         hands
    :return:
    """
    # 手

    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)

    # 脚

    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)
예제 #53
0
def main():
    initialize()
    drawBorder()
    t.fillcolor("red")
    t.begin_fill()
    drawLeftcorner()
    t.end_fill()
    t.forward(30)
    t.left(90)
    t.forward(69)
    t.right(45)
    t.down()
    t.fillcolor("red")
    t.begin_fill()
    drawCenterDesign()
    t.end_fill()
    t.left(90)
    t.forward(27)
    drawText()
    t.up()
    t.forward(80)
    t.right(90)
    t.forward(100)
    t.right(90)
    t.forward(47)
    t.fillcolor("red")
    t.begin_fill()
    drawLeftcorner()
    t.end_fill()
    t.left(90)
    #first card's code ends here

    #second card's code starts here
    t.up()
    t.forward(300)
    t.right(90)
    t.forward(300)
    t.left(90)
    t.forward(10)
    t.right(180)
    t.pencolor("black")
    t.forward(10)
    t.right(180)
    t.forward(225)
    initialize()
    t.pd()
    t.pencolor("black")
    drawBorder2()
    t.up()
    t.fillcolor("black")
    t.begin_fill()
    cornerClub()
    t.end_fill()
    t.up()
    t.right(90)
    t.fd(75)
    t.left(90)
    t.fd(68)
    t.right(180)
    t.pd()
    t.fillcolor("black")
    t.begin_fill()
    club()
    t.end_fill()
    t.up()
    t.left(90)
    t.fd(180)
    t.left(90)
    t.fd(90)
    t.right(180)
    t.fillcolor("black")
    t.begin_fill()
    cornerClub()
    t.end_fill()
    #second card's code ends here
    t.pu()
    t.fd(64)
    t.right(90)
    t.fd(90)
    t.write("K", align="center", font=("Arial", 50, "bold"))
    t.up()
    t.fd(350)
    t.right(90)
    t.forward(180)
    t.pd()
    t.write("Diamond and Club", align="center", font=("Arial", 60, "bold"))
    t.left(90)
    t.pu()
    t.fd(100)
    t.pd()
    t.write("CS LAB 1", align="center", font=("Arial", 60, "bold"))
    t.right(90)
예제 #54
0
def SetupClock():
    """
    关于setup有明确的定义,它包括4个参数width,height,startx,starty,
    即定义了窗体的大小和相对于桌面的起始点的坐标以及窗口的宽度高度,缺省是居中占整个屏幕的一半
    screensize包括3个参数,定义了画布的大小和背景色
    需要注意的是,screensize定义画布大小,缺省是400,300
    """
    t.setup(600, 600, 10, 100)  # 大小和 和相对于桌面的起始点的坐标以及窗口的宽度高度,
    # t.screensize(600,600)
    t.dot(10)  # 在中心画个点

    t.seth(-90)  # 方向朝下
    Skip(200)
    # t.pu()
    # t.sety(-200)  # 定位到(-200,0) 下方200
    # t.pd()

    t.pensize(3)
    t.seth(0)  # 方向朝右
    t.circle(200)

    # t.pu()  # 抬起笔

    # 上移50
    t.seth(90)  # 方向朝上
    Skip(50)
    # t.fd(50)  # 上移50 ,即定为到(-150,0)

    # t.pd()  # 放下笔

    t.dot(5)  # 画一个点

    t.seth(0)  # 方向朝右
    # 间隔性的画第二层的小点
    for _ in range(59):
        t.pu()
        t.circle(150, 6)  # 移动60弧度
        t.pd()
        t.dot(5)  # 画一个点

    t.pu()

    # 画12个线段
    t.home()  # 回到起始圆点和状态
    t.pensize(5)
    t.seth(60)

    for i in range(12):
        t.fd(150)  # 前进150
        t.pd()  # 落笔
        t.fd(10)  # 前进10

        Skip(5)
        # t.up()  # 起笔
        # t.fd(5)  # 前进5
        # t.pd()  # 落笔

        t.write(i + 1, font=('Courier', 15, 'bold'))
        t.up()  # 起笔
        t.setx(0)  # 回来
        t.sety(0)  # 回来
        t.rt(30)  # 右转30度
예제 #55
0
def body():
    # 左手
    turtle.goto(-25, 8)
    turtle.seth(240)
    turtle.pd()
    turtle.circle(150, 15)
    turtle.seth(270)
    turtle.circle(40, 15)
    turtle.circle(15, 65)
    turtle.seth(0)
    turtle.forward(10)
    turtle.circle(10, 100)
    turtle.seth(90)
    turtle.forward(5)
    turtle.circle(10, 100)
    turtle.seth(180)
    turtle.forward(10)
    turtle.pu()
    # 右手
    turtle.goto(25, 8)
    turtle.seth(-60)
    turtle.pd()
    turtle.circle(-150, 15)
    turtle.seth(270)
    turtle.circle(-40, 15)
    turtle.circle(-15, 65)
    turtle.seth(180)
    turtle.forward(10)
    turtle.circle(-10, 100)
    turtle.seth(90)
    turtle.forward(5)
    turtle.circle(-10, 100)
    turtle.seth(0)
    turtle.forward(10)
    turtle.pu()

    # 袍子
    turtle.goto(-30, -48)
    turtle.seth(270)
    turtle.pd()
    turtle.forward(30)
    turtle.circle(10, 100)
    turtle.seth(0)
    turtle.forward(38)
    turtle.circle(10, 100)
    turtle.seth(90)
    turtle.forward(30)
    turtle.pu()

    # 领口
    turtle.goto(-20, 4)
    turtle.pd()
    turtle.seth(300)
    turtle.circle(30, 20)
    turtle.seth(0)
    turtle.forward(25)
    turtle.seth(30)
    turtle.circle(30, 20)
    turtle.pu()

    # 官带
    turtle.goto(-7, -38)
    turtle.seth(0)
    turtle.pd()
    turtle.forward(15)
    turtle.pu()
    turtle.goto(-30, -54)
    turtle.pd()
    turtle.forward(60)
    turtle.pu()

    # 袍子上的波浪
    turtle.goto(-30, -80)
    turtle.pd()
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.pu()

    turtle.goto(-25, -85)
    turtle.pd()
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.seth(90)
    turtle.circle(-5, 180)
    turtle.pu()
예제 #56
0
def switch():
  if t.isdown():
    t.pu()
  else :
    t.pd()
예제 #57
0
def hat():
    # 画帽子
    turtle.goto(-20, 98)
    turtle.pd()
    turtle.seth(80)
    turtle.forward(20)
    turtle.seth(60)
    turtle.circle(-20, 140)
    turtle.seth(-85)
    turtle.forward(18)
    turtle.pu()

    turtle.goto(-20, 98)
    turtle.pd()
    turtle.seth(80)
    turtle.forward(5)
    turtle.seth(30)
    turtle.forward(22)
    turtle.seth(-25)
    turtle.forward(24)
    turtle.pu()

    turtle.goto(0, 127)
    turtle.pd()
    turtle.seth(0)
    turtle.circle(5)
    turtle.pu()

    turtle.goto(0, 125)
    turtle.pd()
    turtle.seth(270)
    turtle.forward(10)
    turtle.pu()

    # 右边抖带
    turtle.goto(19, 110)
    turtle.pd()
    turtle.seth(30)
    turtle.circle(40, 50)
    turtle.seth(0)
    turtle.circle(10)
    turtle.seth(90)
    turtle.circle(10, 90)
    turtle.seth(0)
    turtle.circle(10, 90)
    turtle.seth(270)
    turtle.circle(10, 90)
    turtle.seth(180)
    turtle.circle(10, 90)
    turtle.pu()

    # 左边抖带
    turtle.goto(-19, 110)
    turtle.pd()
    turtle.seth(150)
    turtle.circle(-40, 50)
    turtle.seth(0)
    turtle.circle(10)
    turtle.seth(90)
    turtle.circle(10, 90)
    turtle.seth(0)
    turtle.circle(10, 90)
    turtle.seth(270)
    turtle.circle(10, 90)
    turtle.seth(180)
    turtle.circle(10, 90)
    turtle.pu()
예제 #58
0
def move(turtle, x, y):
    turtle.pu()
    turtle.setpos(x, y)
    turtle.pd()
예제 #59
0
def position(x):

    if x == 1:

        t.setx(-80)

        t.sety(10)

    elif x == 2:

        t.sety(10)

    elif x == 3:

        t.setx(80)

        t.sety(10)

    elif x == 4:

        t.setx(-80)

        t.sety(-70)

    elif x == 5:

        t.sety(-70)

    elif x == 6:

        t.setx(80)

        t.sety(-70)

    elif x == 7:

        t.setx(-80)

        t.sety(-150)

    elif x == 8:

        t.sety(-150)

    elif x == 9:

        t.setx(80)

        t.sety(-150)

    else:

        print 'wrong input'

    t.pd()

    t.color('black', 'green')

    t.begin_fill()

    t.circle(25)

    t.end_fill()

    t.up()

    t.home()

    t.ht
예제 #60
0
def cross(x):

    if x == 1:

        t.setx(-120)

        t.sety(10)

    elif x == 2:

        t.setx(-20)

        t.sety(10)

    elif x == 3:

        t.setx(60)

        t.sety(10)

    elif x == 4:

        t.setx(-120)

        t.sety(-70)

    elif x == 5:

        t.setx(-20)

        t.sety(-70)

    elif x == 6:

        t.setx(60)

        t.sety(-70)

    elif x == 7:

        t.setx(-120)

        t.sety(-150)

    elif x == 8:

        t.setx(-20)

        t.sety(-150)

    elif x == 9:

        t.setx(60)

        t.sety(-150)

    t.pd()

    t.pencolor('white')

    t.left(45)

    t.fd(70.71)

    t.right(135)

    t.color('white')

    t.up()

    t.fd(50)

    t.pd()

    t.color('white')

    t.left(225)

    t.fd(70.71)

    t.right(135)

    t.up()

    t.home()