Esempio n. 1
0
def ustDoNastKraw(ile, bokKw=10):
    turtle.pu()
    turtle.lt(90)
    turtle.fd(bokKw)
    turtle.rt(90)
    turtle.rt(180)
    turtle.pd()
Esempio n. 2
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()
Esempio n. 3
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()
Esempio n. 4
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
Esempio n. 5
0
def drawSide(l):
    """
        Draw one side of the hexagon.
        l is side length
    """
    turtle.fd(l)
    turtle.rt(60)
Esempio n. 6
0
def polygon(n,crad,turtle):
	a = (n-2.0)*(180.0/n)
	s = 2.0*math.sin(math.pi/n)*crad
	for i in range(0,n):
		turtle.fd(s)
		turtle.rt(180.0-a)
		turtle.color(random.random(), random.random(), random.random())
Esempio n. 7
0
def ustDoNastElem(dlBokMalKw):
    turtle.pu()
    turtle.rt(90)
    turtle.fd(dlBokMalKw * 5)
    turtle.lt(90)
    turtle.fd(dlBokMalKw)
    turtle.pd()
Esempio n. 8
0
def ustNaStart(a):
    turtle.pu()
    turtle.bk(a)
    turtle.lt(90)
    turtle.fd(a / 2)
    turtle.rt(90)
    turtle.pd()
Esempio n. 9
0
def grid(side):

	sqrt = math.sqrt(squares)

	#horizontal
	for i in range(1,squares):
		if i % sqrt == 0:
			turtle.width(2)
			turtle.color("red")
		move(-side*squares/2., side*squares/2.-i*side)
		turtle.fd(side*squares)
		turtle.width(1)
		turtle.color("black")

	#vertical
	turtle.setheading(-90)
	for i in range(1,squares):
		if i % sqrt == 0:
			turtle.width(2)
			turtle.color("red")
		move(-side*squares/2.+i*side, side*squares/2.)
		turtle.fd(side*squares)
		turtle.width(1)
		turtle.color("black")

	#big square
	move(-side*squares/2., side*squares/2.)
	turtle.width(3)
	turtle.setheading(0)
	turtle.color("blue")
	for i in range(4):
		turtle.fd(side*squares)
		turtle.rt(90)
Esempio n. 10
0
def naGoreWiezy(bokProst1, bokTroj):
    turtle.pu()
    turtle.fd(bokProst1)
    turtle.rt(30)
    turtle.fd(bokTroj)
    turtle.lt(30)
    turtle.pd()
Esempio n. 11
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()
Esempio n. 12
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()
Esempio n. 13
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()
Esempio n. 14
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)
Esempio n. 15
0
def korDuza(popr,ile):
    turtle.pu()
    turtle.bk(popr * ile)
    turtle.lt(90)
    turtle.bk(popr)
    turtle.rt(90)
    turtle.pd()
Esempio n. 16
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()
Esempio n. 17
0
def ustNaStart(r):
    turtle.lt(90)
    turtle.pu()
    turtle.rt(90)
    turtle.fd(r)
    turtle.lt(90)
    turtle.pd()
Esempio n. 18
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()
Esempio n. 19
0
def ustNaStartKwiatki(rozmKanwy, segment):
    turtle.pu()
    turtle.bk(225)
    turtle.lt(90)
    turtle.bk(225)
    turtle.rt(90)
    turtle.pd()
Esempio n. 20
0
def srodek(bok):
    beta = 360 / 5
    numPow = 1
    while(numPow <= 5):
        turtle.rt(beta)
        romb(bok)
        numPow = numPow+1
Esempio n. 21
0
def turtleXYZ():
	turtle.goto(0, 0)
	turtle.pd()
	turtle.goto(0, 300)
	turtle.goto(6, 290)
	turtle.pu()
	turtle.goto(-6, 290)
	turtle.pd()
	turtle.goto(0, 300)
	turtle.goto(0, 0)
	turtle.goto(300, 0)
	turtle.goto(290, 6)
	turtle.pu()
	turtle.goto(290, -6)
	turtle.pd()
	turtle.goto(300, 0)
	turtle.goto(0, 0)
	turtle.rt(135)
	turtle.fd(212.1)
	turtle.lt(135)
	turtle.fd(5)
	turtle.bk(10)
	turtle.lt(90)
	turtle.fd(10)
	turtle.pu()
	turtle.goto(0, 0)
Esempio n. 22
0
def ustNaStart():
    turtle.pu()
    turtle.bk(250)
    turtle.lt(90)
    turtle.bk(250)
    turtle.rt(90)
    turtle.pd()
Esempio n. 23
0
File: 30.py Progetto: jpbat/freetime
def grid(side):
	turtle.color("blue")
	#horizontal
	for i in range(1, 5):
		move(-side*3, side*3-i*side)
		turtle.fd(6*side)

	#vertical
	turtle.setheading(-90)
	for i in range(1, 6):
		move(-side*3+i*side, side*3)
		turtle.fd(5*side)
	
	#big square
	turtle.color("red")
	turtle.width(2)
	turtle.setheading(0)
	move(-side*3, side*3)
	for i in range(4):
		if (i % 2 == 0):
			cena = side * 6
		else:
			cena = side * 5
		turtle.fd(cena)
		turtle.rt(90)
Esempio n. 24
0
def korDuza(a):
    dlBokKw = a / 5
    turtle.pu()
    turtle.bk(a)
    turtle.rt(90)
    turtle.fd(dlBokKw)
    turtle.lt(90)
    turtle.pd()
Esempio n. 25
0
def cuartoDePoligono (lados, dist):
    angulo = 360/lados

    i = 0
    while i < lados /4:
        turtle.fd(dist)
        turtle.rt(angulo)
        i += 1
Esempio n. 26
0
def hacerPoligono (lados, dist):
    angulo = 360/lados

    i = 0
    while i < lados:
        turtle.fd(dist)
        turtle.rt(angulo)
        i += 1
Esempio n. 27
0
def forma(cantidad, poligono, distancia):
    angulo = 360/cantidad

    j = 0
    while j < cantidad:
        hacerPoligono(poligono, distancia)
        turtle.rt(angulo)
        j += 1
Esempio n. 28
0
def ustDoLUcha(a):
    ileBokow = 12
    skret = 360 / ileBokow
    turtle.pu()
    turtle.rt(skret)
    turtle.fd(a * 6)
    turtle.rt(180)
    turtle.pd()
Esempio n. 29
0
def segmento (radio, cantidad):
    angulo = 10
    lado = radio * math.sin(math.degrees(angulo))

    i = 0 
    while i < 360 / cantidad:
        turtle.fd(lado)
        turtle.rt(angulo)
        i += angulo
Esempio n. 30
0
def wielokatZeSkrP(ileBokow, bok, nrWierz):
    numPow = 1
    skret = 360 / ileBokow
    turtle.rt(nrWierz * skret)
    while(numPow <= ileBokow):
        turtle.fd(bok)
        turtle.lt(skret)
        numPow = numPow + 1
    turtle.lt(360 / ileBokow)
Esempio n. 31
0
import turtle as t

t.bgcolor("black")  #배경색을 검정색으로 설정합니다.
for x in range(100):  #0부터 99번까지 반복합니다.
    t.color("purple")  #선 색을 보라색으로 설정합니다.
    t.fd(3 * x)  #앞으로 3*x만큼 이동합니다
    t.rt(30)  #오른쪽으로 30만큼 회전합니다.
Esempio n. 32
0
            turtle.fd(W)
        turtle.rt(90)


turtle.setup(1000, 1000)
draw_rectangle(600, 800)

turtle.pu()
turtle.home()
turtle.pd()
turtle.speed(1)
turtle.pensize(2)

# arbitrary trajectory
turtle.fd(40)
turtle.rt(50)
turtle.fd(40)
turtle.rt(-90)
turtle.fd(40)

while True:
    # turtle.speed(1)
    cmd = input()
    if cmd == 'exit':
        break
    elif cmd[0] == 'f':
        try:
            dist = int(float(cmd[1:]))
            turtle.fd(dist)
        except ValueError as er:
            print('bad syntax: ', er)
Esempio n. 33
0
def moveToCenterRightTurn(turtle, x,):
   turtle.pu()
   turtle.fd(x/2)
   turtle.rt(270)
   turtle.fd(x/2)
   turtle.rt(90)
Esempio n. 34
0
turtle.goto(-400,350)
turtle.down()
turtle.back(600)
turtle.up()
turtle.color("red")
turtle.shape("turtle")
turtle.goto(-400,380)
turtle.right(90)
turtle.pendown()
 
# You simply have to beat the maze
# You are not allowed to change code above, go round the outside, teleport etc.
# This challenge was made by a year 9 girl!
# Start coding the solution below.
# You can use lists & variables above to help.
turtle.rt(90)
turtle.fd(25)
turtle.lt(90)

turtle.fd(r1+10)
turtle.rt(90)
turtle.fd(20+15)
turtle.rt(90)
turtle.fd(r1+10)
turtle.rt(180)

turtle.fd(t1+10)
turtle.rt(90)
turtle.fd(20+15)
turtle.rt(90)
turtle.fd(t1+10)
Esempio n. 35
0
wn = turtle.Screen()
wn.bgcolor("white") 
wn.title("Perplexing Patterns")
turtle.setup(800, 800)
# turtle.speed(1)
turtle.pen(pensize=3)

tess = turtle.Turtle()
tess.penup()
tess.color('grey')

turtle.color('grey')
turtle.penup()
turtle.goto(0, 0)

# turtle.right(50)
for n in range(3,10):
    turtle.penup()
    turtle.fd(135)
    turtle.pendown()
    angle = 360 / n
    for count in range(n):
        turtle.fd(30)
        turtle.right(angle)  # Draw a square in the current colour.   
    if n == 3:
        turtle.rt(180 - 360/7)
    else:
        turtle.rt(360/7)     

turtle.ht()
wn.mainloop()
#文件的写入.py
fo = open("output.txt", "w+")
ls = ["CN", "US", "FRE"]
fo.writelines(ls)  #这个时候指针在文件的最后,如果这个时候再去遍历每一行,是没有内容的。这个时候需要加一行
fo.seek(0)  #让指针回到文件的最前方。1表示光标当前位置,2表示文件最后。
for line in fo:
    print(line)
fo.close()

#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(datals[i][0])
    if datals[i][1]:
        t.rt(datals[i][2])
    else:
        t.lt(datals[i][2])
Esempio n. 37
0
        turtle.fd(newW)
        turtle.rt(90)
        turtle.fd(newW)
        turtle.rt(90)
        turtle.rt(225)
        turtle.pd()
    # if iter (number of iterations left) is no longer 0
    # finish the first iteration by drawing down and to the left for the remaining two sides of the square not yet drawn
    turtle.fd(w)
    turtle.rt(90)
    turtle.fd(w)
    turtle.rt(90)


# from the very beginning, rotate turtle so it is facing up in the correct direction
turtle.rt(-90)
""" Pythagoras Tree pseudo-code
def fancy_square(iterations, sidelength)
	move sidelength
	rotate 90
	if(iterations > 0)
		rotate to starting angle
		calculate new_sidelength
		fancy_square(iterations-1, new_sidelength)
	move sidelength
	rotate 90
	if(iterations > 0)
		rotate to starting angle
		calculate new_sidelength
		fancy_square(iterations-1, new_sidelength)
	move sidelength
Esempio n. 38
0
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import turtle as t
>>> angle=93
>>> t.bgcolor("black")
>>> t.color("blue")
>>> t.speed(0)
>>> for x in range(100):
	t.fd(x)
	t.rt(angle)
	t.lt(21)
	t.circle(x)

	
>>> 
Esempio n. 39
0
import turtle as t
for i in range(0,4):
    t.fd(100)
    t.rt(90)
Esempio n. 40
0
def move():
    turtle.rt(120)
    turtle.fd(100)
    turtle.lt(60)
Esempio n. 41
0
def draw_line(angle, size):
    tt.fd(size)
    #tt.rt((360/angle))
    tt.rt(144)
Esempio n. 42
0
import turtle

k = 0.1
while (k < 180):
    turtle.rt(k)
    turtle.fd(20)
    k = k + 0.1
t.pensize(4)
t.colormode(255)
t.color((0, 0, 255), "blue")
t.setup(800, 600)
t.speed(100)
#头部
t.hideturtle()
t.pu()
t.goto(-50, 0)
t.seth(150)
t.pd()
t.begin_fill()
t.color(0, 0, 255)
for i in range(300):
    t.rt(1)
    t.forward(2 * m.pi * 100 / 360)
t.seth(0)
t.backward(10)

t.seth(30)
for i in range(300):
    t.lt(1)
    t.forward(2 * m.pi * 80 / 360)
t.seth(0)
t.backward(10)
t.end_fill()
#眼睛
t.pu()
t.begin_fill()
t.pensize(3)
Esempio n. 44
0
def tree(iter, w):
    turtle.width(7)
    global N  # used for changing some colors in pythagoras
    N += 30

    # PYTHAGORAS COLOR, for left squares
    turtle.colormode(255)
    turtle.pencolor((iter * 153 + 40) % 255, (iter * 3 + 30) % 255,
                    (iter * 100 + 35) % 255)

    # initial line drawn up for the first side of the first iteration
    turtle.fd(w)
    turtle.rt(90)

    # if iter (number of iterations left) is not yet 0, draw the left square of the next iteration
    if iter > 0:
        turtle.rt(-135)
        newW = w / sqrt(2)
        tree(iter - 1, newW)
        turtle.rt(135)
    # move forward the length of the previous iteration's square to a new position for the right square of the next iteration
    turtle.fd(w)
    turtle.rt(90)

    # PYTHAGORAS COLOR continued, for right squares
    turtle.colormode(255)
    turtle.pencolor((N * 3) % 255, 100, 200)

    # if iter (number of iterations left) is still not 0, draw the right square of the next iteration
    if iter > 0:
        turtle.rt(-225)
        newW = w / sqrt(2)
        # draw up the first side of the right square
        turtle.fd(newW)
        turtle.rt(90)
        # draw the rest of the right square to end at the top right corner of the previous iteration's square
        tree(iter - 1, newW)
        # pull pen up to move turtle around right square to position at intersection of left square and right square for next iteration
        turtle.pu()
        turtle.fd(newW)
        turtle.rt(90)
        turtle.fd(newW)
        turtle.rt(90)
        turtle.fd(newW)
        turtle.rt(90)
        turtle.rt(225)
        turtle.pd()
    # if iter (number of iterations left) is no longer 0
    # finish the first iteration by drawing down and to the left for the remaining two sides of the square not yet drawn
    turtle.fd(w)
    turtle.rt(90)
    turtle.fd(w)
    turtle.rt(90)
Esempio n. 45
0
def DrawAxes():
    t.ht()

    t.color("white")
    t.rt(90)
    t.fd(10)

    t.up()
    t.fd(20)
    t.lt(90)
    t.down()
    t.write("1960", False, align="center")
    t.up()
    t.rt(90)
    t.bk(20)
    t.down()

    t.bk(10)
    t.lt(90)
    t.fd(400)
    t.rt(90)
    t.fd(10)

    t.up()
    t.fd(20)
    t.lt(90)
    t.down()
    t.write("2015", False, align="center")

    t.up()
    t.rt(90)
    t.bk(20)
    t.down()

    t.bk(10)
    t.lt(90)
    t.bk(200)

    t.up()
    t.rt(90)
    t.fd(25)
    t.lt(90)
    t.down()
    t.write("Year", False, align="center")
    t.up()
    t.lt(90)
    t.fd(25)
    t.rt(90)
    t.down()
    t.bk(200)

    t.bk(10)
    t.up()
    t.bk(20)
    t.down()
    t.write("0", False, align="center")
    t.up()
    t.fd(20)
    t.down()
    t.fd(10)

    t.lt(90)
    t.fd(200)

    t.lt(90)
    t.up()
    t.fd(25)
    t.down()
    t.write("Life\nExp.", False, align="center")
    t.up()
    t.bk(25)
    t.rt(90)
    t.down()
    t.fd(200)

    t.lt(90)
    t.fd(10)

    t.up()
    t.fd(20)
    t.down()
    t.rt(180)
    t.write("100", False, align="center")
    t.up()
    t.fd(20)

    t.fd(10)
    t.rt(90)
    t.fd(400)
    t.lt(90)

    t.update()
Esempio n. 46
0
import turtle

#Turtle set up
turtle.width(2)
turtle.speed(2)

#Starting on the left side of the page so that the graphic is centered
turtle.hideturtle()
turtle.penup()
turtle.goto(-60, 0)
turtle.pendown()

#Red part of graphic
turtle.color('red')
turtle.rt(-150)
turtle.fd(60)
turtle.rt(100)
turtle.fd(110)
turtle.rt(100)
turtle.fd(60)

#Blue part of graphic
turtle.color('blue')
turtle.rt(-100)
turtle.fd(60)
turtle.rt(100)
turtle.fd(110)
turtle.rt(100)
turtle.fd(60)

#Keep graphic
Esempio n. 47
0
import turtle
turtle.lt(90)
turtle.fd(100)
turtle.rt(150)
turtle.fd(120)
turtle.setheading(90)
turtle.fd(100)
turtle.pu()
turtle.bk(100)
turtle.setheading(0)
turtle.fd(50)
turtle.pd()
Esempio n. 48
0
import turtle as t
from time import sleep

for n in range(4):
    t.fd(200)
    t.rt(170)

sleep(2)

Esempio n. 49
0
def drawB(size):
    # Draws an uppercase B
    # Draw low horizontal stem
    t.pd()
    t.lt(180)
    t.fd(size * 60)
    # Draw vertical stem
    t.rt(90)
    t.fd(size * 120)
    # Draw high horizontal stem
    t.rt(90)
    t.fd(size * 60)
    # Draw the upper hump
    for i in range(180):
        t.fd(size * 0.524)
        t.rt(1)
    # Draw the lowerhump
    t.rt(180)
    for i in range(180):
        t.fd(size * 0.524)
        t.rt(1)
    # Finalize
    t.rt(180)
    t.pu()
Esempio n. 50
0
def drawSpace():
    t.rt(360)
Esempio n. 51
0
#screen size and start position
width = 100 * 2 + text_counter * 70 + (text_counter - 1) * 20
height = 300
turtle.setup(width=width,height=height,startx=0,starty=0)
turtle.goto(((-text_counter)/2) * 70, 0)

#start programm 
for i in range(text_counter):
    if text[i] == 'a':
        turtle.goto(0, -50)
        cx = turtle.xcor()
        cy = turtle.ycor()
        turtle.pendown()
        #drawing
        x = math.degrees(math.atan(25/100))
        turtle.rt(x - 90)
        turtle.forward(math.sqrt(10625))
        turtle.right(90 - x)
        turtle.forward(20)
        turtle.right(90 - x)
        turtle.forward(math.sqrt(10625))
        turtle.right(90 + x)
        turtle.forward(15)
        turtle.right(90 - x)
        turtle.forward(25)
        turtle.left(90 - x)
        turtle.forward(26.5)
        turtle.left(90 - x)
        turtle.forward(25)
        turtle.right(90 - x)
        turtle.forward(15)
Esempio n. 52
0
t.fillcolor("green")
t.penup()
t.goto(670 * s, -180 * s)
t.pendown()
t.right(140)
t.begin_fill()
t.circle(300 * s, 120)
t.left(60)
t.circle(300 * s, 120)
t.end_fill()
t.penup()
t.goto(180 * s, -550 * s)
t.pendown()
t.right(85)
t.circle(600 * s, 40)
#绘制另外一个绿叶
t.penup()
t.goto(-150 * s, -1000 * s)
t.pendown()
t.begin_fill()
t.rt(120)
t.circle(300 * s, 115)
t.left(75)
t.circle(300 * s, 100)
t.end_fill()
t.penup()
t.goto(430 * s, -1070 * s)
t.pendown()
t.right(30)
t.circle(-600 * s, 35)
t.done()
Esempio n. 53
0
# Multiline test
import turtle

repeat (2
        + 2):
    turtle.fd(100)
    turtle.rt(90)
Esempio n. 54
0
def pie(turtle, side_length, pieces):
    for i in range(pieces):
        triangle(turtle, side_length)
        turtle.rt(360 / pieces)
Esempio n. 55
0
    def cool_design_one():
        turtle.speed(0)
        turtle.pencolor('white')
        turtle.bgcolor('black')

        x = 0
        turtle.up()

        turtle.rt(45)
        turtle.fd(90)
        turtle.rt(135)

        turtle.down()
        while x < 120:

            turtle.fd(200)
            turtle.rt(61)
            turtle.fd(200)
            turtle.rt(61)
            turtle.fd(200)
            turtle.rt(61)
            turtle.fd(200)
            turtle.rt(61)
            turtle.fd(200)
            turtle.rt(61)
            turtle.fd(200)
            turtle.rt(61)

            turtle.rt(11.1111)
            x = x + 1

        turtle.exitonclick()
Esempio n. 56
0
# -*- coding: utf-8 -*-
# Time    : 2019/4/5 22:40
# Author  : Mifen
# Email   : [email protected]
# Github  : https://github.com/Amd794

import turtle as t
from turtle import *

angle = 60  #通过改变角度,绘制出各种多边形
t.bgcolor('black')
t.pensize(2)
randomColor = ['red', 'blue', 'green', 'purple', 'gold', 'pink']
t.speed(0)
for i in range(200):
    t.color(randomColor[i % 6])
    t.circle(i)
    t.rt(angle + 1)
up()
color("#0fe6ca")
goto(-600, 300)
write('Author:Mifen', font=("微软雅黑", 18))
goto(-600, 250)
write('E-mail :[email protected]', font=("微软雅黑", 18))
goto(-600, 200)
write('Code :https://github.com/Amd794/Python123', font=("微软雅黑", 18))
goto(0, 0)
down()
Esempio n. 57
0
from math import *  # 从数学模块导入函数
from pygame import Color  # 从pygame导入Color类


def coloradd(color, dh):
    """
       颜色增加函数,本函数把颜色的色相进行增加,其它指标不变。
       color:Color实例化后的颜色
       dh:一个int,色相增加的值
    """
    h, s, v, a = color.hsva
    h = h + dh  # 色相增加
    h = h % 360  # 不能超过360
    color.hsva = h, s, v, a  # 设定颜色的hsva值
    return Color(*color)  # 返回颜色实例


width, height = 480, 360
screen = turtle.getscreen()
screen.setup(width, height)
screen.title("turtle和pygame结合的彩色螺旋图www.lixingqiu.com")
screen.colormode(255)
screen.delay(0)
turtle.width(30)
yanse = Color('red')
for i in range(2200):
    turtle.color(yanse[:-1])
    turtle.fd(i)
    turtle.rt(35)
    yanse = coloradd(yanse, 1)
screen.mainloop()
Esempio n. 58
0
File: 五角星.py Progetto: ice-1/1
import turtle

turtle.color('red', 'red')
turtle.begin_fill()

for i in range(5):
    turtle.fd(200)
    turtle.rt(144)

turtle.end_fill()
Esempio n. 59
0
import random
import turtle

t = turtle.Turtle()
wn = turtle.Screen()
turtle.bgcolor('black')
turtle.color('white')

x = 0
#t.shape('turtle')
while x < 400:
    r = random.randint(0,2)
    if r == 0:
        movement = random.randrange(20, 50)
        turtle.rt(random.randint(1,180))
        turtle.forward(movement)
    else:
        movement = random.randrange(20, 50)
        turtle.lt(random.randint(1,180))
        turtle.forward(movement)
Esempio n. 60
0
def drawSide():
    """
        Draw one side of the hexagon.
    """
    turtle.fd(100)
    turtle.rt(60)