Пример #1
0
def tree( x, y, scale ):
	'''draws a leaf given location and scale'''
	goto( x, y )
	turtle.setheading(0)
	turtle.begin_fill()
	turtle.color('dark green')
	turtle.forward(25*scale)
	turtle.left(150)
	turtle.forward(25*scale)
	turtle.right(150)
	turtle.forward(20*scale)
	turtle.left(150)
	turtle.forward(30*scale)
	turtle.left(60)
	turtle.forward(30*scale)
	turtle.left(150)
	turtle.forward(20*scale)
	turtle.right(150)
	turtle.forward(25*scale)
	turtle.left(150)
	turtle.end_fill()
	turtle.forward(30*scale)
	goto( x, y )
	turtle.begin_fill()
	turtle.color('brown')
	turtle.right(90)
	turtle.forward(15*scale)
	turtle.right(90)
	turtle.forward(5*scale)
	turtle.right(90)
	turtle.forward(15*scale)
	turtle.right(90)
	turtle.end_fill()
	turtle.forward(5*scale)
Пример #2
0
    def show_particles(self, particles):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        # turtle.clearstamps()
        turtle.shape('tri')

        draw_cnt = 0
        px = {}
        for p in particles:
            draw_cnt += 1
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 1:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x1 = int(p.x1 * self.one_px)
                scaled_y1 = int(p.y1 * self.one_px)
                scaled_xy1 = scaled_x1 * 10000 + scaled_y1
                if not scaled_xy1 in px:
                    px[scaled_xy1] = 1
                    turtle.setposition(*p.xy1)
                    turtle.setheading(math.degrees(p.h))
                    turtle.color("Red")
                    turtle.stamp()

                    turtle.setposition(*p.xy2)
                    turtle.setheading(math.degrees(p.h))
                    turtle.color("Blue")
                    turtle.stamp()
Пример #3
0
 def show_shark(self, shark):
     turtle.color(shark.color)
     turtle.shape('turtle')
     turtle.setposition(*shark.xy)
     turtle.setheading(math.degrees(shark.h))
     turtle.stamp()
     turtle.update()
Пример #4
0
def tscm_color(c):
    """Set the color to C, a symbol such as red or '#ffc0c0' (representing
    hexadecimal red, green, and blue values."""
    _tscm_prep()
    check_type(c, scm_symbolp, 0, "color")
    turtle.color(str(c))
    return UNSPEC
Пример #5
0
 def show_robot(self, robot):
     turtle.color("blue")
     turtle.shape('square')
     turtle.setposition(*robot.xy)
     turtle.setheading(math.degrees(robot.h))
     turtle.stamp()
     turtle.update()
Пример #6
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
Пример #7
0
    def show_sharks(self, sharks):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        draw_cnt = 0
        px = {}
        for shark in sharks:
            draw_cnt += 1
            shark_shape = 'classic' if shark.tracked else 'classic'
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 0:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x = int(shark.x * self.one_px)
                scaled_y = int(shark.y * self.one_px)
                scaled_xy = scaled_x * 10000 + scaled_y
                turtle.color(shark.color)
                turtle.shape(shark_shape)
                turtle.resizemode("user")
                turtle.shapesize(1.5,1.5,1)
                if not scaled_xy in px:
                    px[scaled_xy] = 1
                    turtle.setposition(*shark.xy)
                    turtle.setheading(math.degrees(shark.h))
                    turtle.stamp()
Пример #8
0
 def show_robot(self, robot):
     turtle.color("green")
     turtle.shape('turtle')
     turtle.setposition(*robot.xy)
     turtle.setheading(robot.h)
     turtle.stamp()
     turtle.update()
Пример #9
0
def draw(cmds, size=2): #output tree
    stack = []
    for cmd in cmds:
        if cmd=='F':
            turtle.forward(size)
        elif cmd=='-':
            t = random.randrange(0,7,1)
            p = ["Red","Green","Blue","Grey","Yellow","Pink","Brown"]
            turtle.color(p[t])
            turtle.left(15) #slope left
        elif cmd=='+':
            turtle.right(15) #slope right
            t = random.randrange(0,7,1) #рандомная пер. для цвета
            p = ["Red","Green","Blue","Grey","Yellow","Pink","Brown"] #ряд цветов
            turtle.color(p[t]) #выбор цвета из ряда
        elif cmd=='X':
            pass
        elif cmd=='[':
            stack.append((turtle.position(), turtle.heading()))
        elif cmd==']':
            position, heading = stack.pop()
            turtle.penup()
            turtle.setposition(position)
            turtle.setheading(heading)  
            turtle.pendown()
    turtle.update()
def rectangle(length = 50, width = 30, x = 0, y = 0, color = 'black', fill = False):
    turtle.pensize(3)
    turtle.speed('fastest')
    turtle.hideturtle()
    if fill == True:
        turtle.color(color)
        for i in range(width): 
            turtle.setposition(x, (y+i))
            turtle.pendown()
            turtle.setposition((x+length), (y+i))
            turtle.penup()
    else:
        turtle.penup()
        turtle.goto(x,y)
        turtle.color(color)
        turtle.pendown()
        turtle.forward(length)
        turtle.left(90)
        turtle.forward(width)
        turtle.left(90)
        turtle.forward(length)
        turtle.left(90)
        turtle.forward(width)
        turtle.left(90)
        turtle.penup()

    return
def polygon(side = 50, angle = None, xstart = None, ystart = None, numberSides = 3, color = 'black', fill = False):
    turtle.pensize(3)
    turtle.speed('fastest')
    turtle.hideturtle()
    if angle != None:
        turtle.left(angle)
    
    turtle.penup()
    if fill == True:
        if xstart != None or ystart != None:
            turtle.goto(xstart, ystart)
        else:
            turtle.goto(0, 0)
        turtle.color(color)
        turtle.pendown()
        turtle.begin_fill()
        turtle.circle(side, 360, numberSides)
        turtle.end_fill()
        turtle.penup()
        
    else:
        turtle.goto(xstart, ystart)
        turtle.color(color)
        turtle.pendown()
        turtle.circle(side, 360, numberSides)
        turtle.penup()
    
    return
def tscheme_color(c):
    """Set the color to C, a string such as '"red"' or '"#ffc0c0"' (representing
    hexadecimal red, green, and blue values."""
    _tscheme_prep()
    check_type(c, scheme_stringp, 0, "color")
    turtle.color(eval(c))
    return okay
Пример #13
0
def drawLine(x1, y1, x2, y2, color = "black", size = 1):
    turtle.color(color)
    turtle.pensize(size)
    turtle.penup()
    turtle.goto(x1, y1)
    turtle.pendown()
    turtle.goto(x2, y2)
Пример #14
0
def forGlory(sideLength=50):
	turtle.left(150)
	turtle.penup()
	turtle.setpos(-25,75)
	turtle.color("blue")
	turtle.pendown()
	hexagon(sideLength)
Пример #15
0
def theStem(stemLength=100):
	turtle.home()
	turtle.forward(25)
	turtle.left(90)
	turtle.pensize(4)
	turtle.color("green")
	turtle.forward(stemLength)
Пример #16
0
def cross( x, y, scale, fill, color ):
	'''draws a cross given location, scale, and color'''
	goto( x, y )
	
	if fill == "True":
		'''if the scale is 1, and fill == True
			then this function will draw a cross 
			with its left point at (x,y) and
			will have lengths of 50 and widths of 15
			and filled with the color given'''
		t.begin_fill()
		t.color(color)
		for i in range(4):
			t.forward(50*scale)
			t.right(90)
			t.forward(50*scale)
			t.left(90)
			t.forward(15*scale)
			t.left(90)
		t.end_fill()
	else: 
		'''if the scale is 1, and fill == False
			then this function will draw a cross 
			with its left point at (x,y) and
			will have lengths of 50 and widths of 15
			and with no color fill'''
		for i in range(4):
			t.forward(50*scale)
			t.right(90)
			t.forward(50*scale)
			t.left(90)
			t.forward(15*scale)
			t.left(90)
Пример #17
0
def draw_star(size, color):

    turtle.pendown()
    turtle.begin_fill()
    turtle.color(1,1,1)
    turtle.forward(2.5) 
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.forward(2.5)
    turtle.left(size)
    turtle.forward(2.5)
    turtle.right(144)
    turtle.end_fill()
    turtle.penup()
Пример #18
0
def sky( x, y, scale ):
	'''draws a huge blue square given location and scale'''
	t.tracer(False)
	t.begin_fill()
	t.color('light blue')
	buildingblock(x-1000*scale, y+0*scale, 2000*scale, 1075*scale)
	t.end_fill()
Пример #19
0
def grass( x, y, scale ):
	'''draws a huge blue square given location and scale'''
	t.tracer(False)
	t.begin_fill()
	t.color('green')
	buildingblock(x-1000*scale, y-1000*scale, 2000*scale, 1075*scale)
	t.end_fill()
Пример #20
0
def cloud( x, y, scale, color):
	'''draws a cloud given location and scale'''
	goto( x, y )
	t.begin_fill()
	t.color(color)
	t.circle(50*scale)
	t.end_fill()
	t.begin_fill()
	t.color(color)
	t.up()
	t.forward(25*scale)
	t.down()
	t.circle(50*scale)
	t.end_fill()
	t.begin_fill()
	t.color(color)
	t.up()
	t.forward(35*scale)
	t.down()
	t.circle(50*scale)
	t.end_fill()
	t.begin_fill()
	t.color(color)
	t.up()
	t.forward(25*scale)
	t.down()
	t.circle(50*scale)
	t.end_fill()
	t.begin_fill()
	t.color(color)
	t.up()
	t.forward(25*scale)
	t.down()
	t.end_fill()
Пример #21
0
def block( x, y, width, height, fill, color ):
	goto( x, y )
	
	print 'block(): drawing block of size', width, height
	# tell the turtle to go foward by width
	# tell the turtle to turn left by 90 degrees
	# tell the turtle to go forward by height
	# tell the turtle to turn left by 90 degrees
	# repeat the above 4 commands
	
	# if the parameter fill is true then do this
	if fill == "True":
		''' draw a block at position (x,y) with the
			given width and height, and fill with 
			the color '''
		t.begin_fill()
		t.color(color)
		for i in range(2):
			t.forward(width)
			t.left(90)
			t.forward(height)
			t.left(90)	
		t.end_fill()
	# if the parameter fill is false then do this
	else:
		''' draw a block at position (x,y) with the
			given width and height, and fill with 
			the color '''
		for i in range(2):
			t.forward(width)
			t.left(90)
			t.forward(height)
			t.left(90)	
Пример #22
0
	def draw(self):
		
		turtle.penup()
		turtle.goto(self.point_st)
		turtle.pendown()
		turtle.color(self.border_c, self.fill_c)	
		self._draw()
Пример #23
0
def plano2d():
  turtle.penup()

  for i in range(13):
    y = 264 - (44 *i)
    turtle.penup()
    turtle.setposition(-264,y)
    turtle.pendown()
    turtle.forward(528)
  
  turtle.right(90)

  for i in range(13):
    x = -264 + (44*i)
    turtle.penup()
    turtle.setposition(x,264)
    turtle.pendown()
    turtle.forward(528)
  
  turtle.penup()
  turtle.home()
  turtle.pendown()
  turtle.color("blue")         
  turtle.pensize(3)

  for i in range(4):
    grados = 90 * (i+1)
    turtle.home()
    turtle.left(grados)
    turtle.forward(264) 
Пример #24
0
def curva(simbolos,identificador,linea):
  p1= obtener_punto(1,identificador,simbolos)
  p2= obtener_punto(2,identificador,simbolos)
  
  x1 = int (obtener_x(p1,simbolos))
  y1 = int (obtener_y(p1,simbolos))
  x2 = obtener_x(p2,simbolos)
  y2 = obtener_y(p2,simbolos)  

  rotar = obtener_rotar(identificador, simbolos,linea)
  escalar = obtener_escalar(identificador, simbolos,linea)
  relleno = obtener_color(obtener_relleno(identificador,simbolos,linea))  
  turtle.color(relleno)

  tx = obtener_tx(identificador, simbolos,linea)
  ty = obtener_ty(identificador, simbolos,linea)
  potencia = obtener_potencia(identificador,simbolos)
  
  #Trasladar recta
  x1 = int(x1*44 + tx*44)
  x2 = int(x2*44 + tx*44)
  y1 = y1*44 + ty*44
  y2 = y2*44 + ty*44  
  turtle.penup()
  for x in range(x1,x2):
  	turtle.goto(x+(44), (x+(44))**potencia)
  	turtle.pendown()
Пример #25
0
def circunferencia(simbolos,identificador,linea):
  p1= obtener_punto(2,identificador,simbolos)
  radio = obtener_radio(identificador,simbolos)
  x1 = obtener_x(p1,simbolos)
  y1 = obtener_y(p1,simbolos)
 
  escalar = obtener_escalar(identificador, simbolos,linea)
  relleno = obtener_color(obtener_relleno(identificador,simbolos,linea))
  borde = obtener_color(obtener_borde(identificador,simbolos,linea))  
  turtle.color(borde)
  if escalar == 0:
    escalar=1
  tx = obtener_tx(identificador, simbolos,linea)
  ty = obtener_ty(identificador, simbolos,linea)
  turtle.pensize(8)
  turtle.penup()

  
  #Trasladar circunferencia
  x1 = x1 + tx
  y1 = y1 + ty

  #turtle.setposition(x1, y1-(radio*44))
  #turtle.pendown()
  #turtle.circle(radio*44)

  #Escalar circunferencia
  turtle.penup()
  #turtle.setposition(x1, y1-(radio*44*escalar))
  turtle.setposition(x1*44, (y1*44)-(radio*44*escalar))
  turtle.pendown()
  turtle.fillcolor(relleno)
  turtle.begin_fill()
  turtle.circle(radio*44*escalar)
  turtle.end_fill()
def draw_borders(screen_dimension, left, right, down, up):
    """
    Draws border titles
    @param screen_dimension
    @param left - left x
    @param right - right x
    @param up - up y
    @param down - down y
    """
    #boundary titles
    turtle.color("black")  
    turtle.penup()
    turtle.goto(-screen_dimension[0]+100,10)
    turtle.pendown()
    if(left<0):
        turtle.write(str(left))
    turtle.penup()
    turtle.goto(screen_dimension[0]-150,10)
    turtle.pendown()
    turtle.write(str(right))
    turtle.penup()
    turtle.goto(5,screen_dimension[1]-20)
    turtle.pendown()
    turtle.write(str(up))
    turtle.penup()
    turtle.goto(5,-screen_dimension[1]+15)
    turtle.pendown()
    if(down<0):
        turtle.write(str(down))
def draw_coordinate_systen(screen_dimension,function, input_range):
    """
    Draws Coordinate System on screen 
    @param screen_dimension 
    """
    turtle.penup()
    turtle.goto(0,screen_dimension[1])
    turtle.pendown()
    turtle.goto(0,-screen_dimension[1])
    turtle.penup()
    turtle.goto(-screen_dimension[1],0)
    turtle.pendown()
    turtle.goto(screen_dimension[1],0)
    turtle.penup()
    turtle.goto(0,0)

    #titles (equation, input_range)
    turtle.color("red")  
    turtle.penup()
    turtle.goto(-screen_dimension[0]+100,screen_dimension[1]-30)
    turtle.pendown()
    turtle.write("Wykres f(x)="+function)
    turtle.penup()
    turtle.goto(-screen_dimension[0]+100,screen_dimension[1]-40)
    turtle.pendown()
    turtle.write("input_range: "+str(input_range))
    turtle.penup()
Пример #28
0
def drawmountain(x,y,color):
	t.up
	t.goto(x,y)
	t.down
	t.color(color)
	t.begin_fill()
	t.backward(200)
	t.right(120)
	t.backward(200)
	t.right(120)
	t.backward(200)
	t.right(120)
	t.end_fill()
	t.up

	t.goto(x-75,y+125)
	t.down
	t.color("White")
	t.begin_fill()
	t.backward(50)
	t.right(120)
	t.backward(50)
	t.right(120)
	t.backward(50)
	t.right(120)
	t.end_fill()
	t.up
Пример #29
0
def draw_stars():
	for i in range(NSTARS):
		x = random.randint(MINX, MAXX)
		y = random.randint(GROUNDY, MAXY)
		turtle.goto(x, y)
		turtle.color('white')
		turtle.dot(1)
Пример #30
0
def star( x, y, scale, fill, color ):
	'''draws a star given location, scale, and color'''
	goto( x, y )
	
	if fill == "True":
		'''if the scale is 1, and fill == True
			then this function will draw a star 
			with its left point at (x,y) and
			will have star ray lengths of 50
			and filled with the color given'''
		t.begin_fill()
		t.color(color)
		for i in range(10):
			t.forward(50*scale)
			t.right(108)
			t.forward(50*scale)
			t.left(144)
		t.end_fill()
	else: 
		'''if the scale is 1, and fill == False
			then this function will draw a star 
			with its left point at (x,y) and
			will have star ray lengths of 50
			and with no color fill'''
		t.begin_fill()
		for i in range(10):
			t.forward(50*scale)
			t.right(108)
			t.forward(50*scale)
			t.left(144)
Пример #31
0
def realmain():
    A1 = []
    A2 = []
    people = 0
    work = 0
    turtle.color("white")
    turtle.forward(100)
    turtle.color("brown")
    turtle.right(90)
    turtle.forward(300)
    turtle.backward(600)
    turtle.forward(200)
    turtle.left(90)
    turtle.forward(200)
    turtle.backward(600)
    turtle.forward(200)
    turtle.left(90)
    turtle.forward(200)
    turtle.backward(600)
    turtle.forward(200)
    turtle.left(90)
    turtle.forward(200)
    turtle.backward(600)
    turtle.forward(300)
    turtle.right(90)
    turtle.color("white")
    turtle.forward(100)
    while True:
        if work == 0:
            l = input("Player 1 Enter your desired location:--")
            for i in A1 + A2:
                if i == l:
                    print "That place is filled Try again..."
                    people = 1
                    break
            else:
                people = 0
                A1.append(l)
                if l == 1:
                    a = -200
                    b = 200
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A1) and (2 in A1) and (3 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, 200)
                            print "Hurray Player '1' wins!!!!"
                            break
                        elif (1 in A1) and (5 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (1 in A1) and (4 in A1) and (7 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        else:
                            pass
                elif l == 2:
                    a = 0
                    b = 200
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A1) and (2 in A1) and (3 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, 200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (2 in A1) and (5 in A1) and (8 in A1):
                            turtle.color("white")
                            turtle.setposition(0, 200)
                            turtle.color("purple")
                            turtle.setposition(0, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        else:
                            pass

                elif l == 3:
                    a = 200
                    b = 200
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A1) and (2 in A1) and (3 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, 200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (3 in A1) and (5 in A1) and (7 in A1):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("purple")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (3 in A1) and (6 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break
                        else:
                            pass
                elif l == 4:
                    a = -200
                    b = 0
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (4 in A1) and (5 in A1) and (6 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("purple")
                            turtle.setposition(200, 0)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (1 in A1) and (4 in A1) and (7 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        else:
                            pass
                elif l == 5:
                    a = 0
                    b = 0
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A1) and (5 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break
                        elif (3 in A1) and (5 in A1) and (7 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("purple")
                            turtle.setposition(200, 0)
                            print "Hurray Player '1' wins!!!!"
                            break
                        elif (4 in A1) and (5 in A1) and (6 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("purple")
                            turtle.setposition(200, 0)
                            print "Hurray Player '1' wins!!!!"
                            break
                        elif (2 in A1) and (5 in A1) and (8 in A1):
                            turtle.color("white")
                            turtle.setposition(0, 200)
                            turtle.color("purple")
                            turtle.setposition(0, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        else:
                            pass
                elif l == 6:
                    a = 200
                    b = 0
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (4 in A1) and (5 in A1) and (6 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("purple")
                            turtle.setposition(200, 0)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (3 in A1) and (6 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break
                        else:
                            pass
                elif l == 7:
                    a = -200
                    b = -200

                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (3 in A1) and (5 in A1) and (7 in A1):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("purple")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (7 in A1) and (8 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, -200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break
                        elif (1 in A1) and (4 in A1) and (7 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        else:
                            pass
                elif l == 8:
                    a = 0
                    b = -200
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (7 in A1) and (8 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, -200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (2 in A1) and (5 in A1) and (8 in A1):
                            turtle.color("white")
                            turtle.setposition(0, 200)
                            turtle.color("purple")
                            turtle.setposition(0, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        else:
                            pass
                else:
                    a = 200
                    b = -200
                    cross(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A1) and (5 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (7 in A1) and (8 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(-200, -200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break

                        elif (3 in A1) and (6 in A1) and (9 in A1):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("purple")
                            turtle.setposition(200, -200)
                            print "Hurray Player '1' wins!!!!"
                            break
                        else:
                            pass

        if people == 0:
            l1 = input("Player 2 Enter your desired location:--")
            for i in A1 + A2:
                if i == l1:
                    print "That place is filled Try again..."
                    work = 1
                    break
            else:
                work = 0
                A2.append(l1)
                if l1 == 1:
                    a = -200
                    b = 200
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A2) and (2 in A2) and (3 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(200, 200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        elif (1 in A2) and (5 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (1 in A2) and (4 in A2) and (7 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        else:
                            pass
                elif l1 == 2:
                    a = 0
                    b = 200
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A2) and (2 in A2) and (3 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(200, 200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (2 in A2) and (5 in A2) and (8 in A2):
                            turtle.color("white")
                            turtle.setposition(0, 200)
                            turtle.color("green")
                            turtle.setposition(0, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        else:
                            pass
                elif l1 == 3:
                    a = 200
                    b = 200
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A2) and (2 in A2) and (3 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(200, 200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (3 in A2) and (5 in A2) and (7 in A2):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("green")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (3 in A2) and (6 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        else:
                            pass
                elif l1 == 4:
                    a = -200
                    b = 0
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (4 in A2) and (5 in A2) and (6 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("green")
                            turtle.setposition(200, 0)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (1 in A2) and (4 in A2) and (7 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        else:
                            pass
                elif l1 == 5:
                    a = 0
                    b = 0
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A2) and (5 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        elif (3 in A2) and (5 in A2) and (7 in A2):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("green")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        elif (4 in A2) and (5 in A2) and (6 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("green")
                            turtle.setposition(200, 0)
                            print "Hurray Player '2' wins!!!!"
                            break
                        elif (2 in A2) and (5 in A2) and (8 in A2):
                            turtle.color("white")
                            turtle.setposition(0, 200)
                            turtle.color("green")
                            turtle.setposition(0, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        else:
                            pass
                elif l1 == 6:
                    a = 200
                    b = 0
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (4 in A2) and (5 in A2) and (6 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 0)
                            turtle.color("green")
                            turtle.setposition(200, 0)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (3 in A2) and (6 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        else:
                            pass
                elif l1 == 7:
                    a = -200
                    b = -200
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (3 in A2) and (5 in A2) and (7 in A2):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("green")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (7 in A2) and (8 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, -200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        elif (1 in A2) and (4 in A2) and (7 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(-200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        else:
                            pass
                elif l1 == 8:
                    a = 0
                    b = -200
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (7 in A2) and (8 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, -200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (2 in A2) and (5 in A2) and (8 in A2):
                            turtle.color("white")
                            turtle.setposition(0, 200)
                            turtle.color("green")
                            turtle.setposition(0, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        else:
                            pass
                else:
                    a = 200
                    b = -200
                    O(a, b)
                    if len(A1) + len(A2) == 9:
                        s4 = "\n THE MATCH IS DRAW BETTER LUCK NEXT TIME..."
                        for i in s4:
                            print i,
                            time.sleep(0.1)
                        break
                    else:
                        if (1 in A2) and (5 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, 200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (7 in A2) and (8 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(-200, -200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break

                        elif (3 in A2) and (6 in A2) and (9 in A2):
                            turtle.color("white")
                            turtle.setposition(200, 200)
                            turtle.color("green")
                            turtle.setposition(200, -200)
                            print "Hurray Player '2' wins!!!!"
                            break
                        else:
                            pass
Пример #32
0
import turtle


#turtle.setx(150)

turtle.bgcolor(0,0,0)

turtle.color('yellow')



#turtle.fill(True)

def web(size):
    for i in range (5):
        turtle.left(72)
        for i in range (5):
            turtle.forward(size)
            turtle.right(144)
        turtle.right(144)
        for i in range (5):
            turtle.forward(size)
            turtle.left(144)

web(100)
        
turtle.left(36)

web(200)

turtle.left(36)
Пример #33
0
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  8 20:59:02 2019

@author: Aaron
"""

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.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)
Пример #34
0
import turtle as tl

tl.shape("turtle")
tl.speed(8)
tl.left(45)
for i in range(1, 500):
    tl.color("Blue")
    tl.forward(i)
    tl.left(90)
    tl.color("red")
    tl.forward(i)
    tl.left(90)

tl.exitonclick()
Пример #35
0
def up():
    t.setheading(90)
    t.forward(20)


def down():
    t.setheading(270)
    t.forward(20)


def left():
    t.setheading(180)
    t.forward(20)


def right():
    t.setheading(0)
    t.forward(20)


t.shape('turtle')
t.setup(1000, 1000)
t.Screen().bgcolor("sky blue")
t.color("dark green")
t.turtlesize(3, 3, 2)
t.listen()
t.onkey(up, "Up")
t.onkey(down, "Down")
t.onkey(left, "Left")
t.onkey(right, "Right")
t.mainloop()
Пример #36
0
import turtle

turtle.bgcolor("silver")
turtle.speed(10)
turtle.turtlesize(0.5)
turtle.shape("arrow")
turtle.color("crimson")
turtle.width(2)
for i in range(10, 1000, 10):
    turtle.forward(i)
    turtle.left(90)
    turtle.forward(i)
    turtle.left(90)
    turtle.forward(i)
    turtle.left(90)
    turtle.forward(i)
    turtle.left(45)
    turtle.penup()
    turtle.forward(i % 10)
    turtle.pendown()
turtle.exitonclick()
Пример #37
0
__author__ = 'student'
import turtle as tu

tu.color('green')
tu.shape('turtle')
n
Пример #38
0
    def drawString(self, dstring, distance, angle):
        #create two lists which can include information of turtle position and turtle color
        stack = []
        color = []
        # for each character in the dstirng
        for c in str(dstring):

            if c == 'F':
                # python would go forward
                turtle.forward(distance)

            elif c == '+':
                #turtle would turn left
                turtle.left(angle)
            elif c == '-':
                #turtle would turn right
                turtle.right(angle)
            elif c == '[':
                #turtle would record the position and heading angle
                stack.append(turtle.position())
                stack.append(turtle.heading())
            elif c == ']':
                #turtle would return to the position and heading angle recorded before
                turtle.up()
                turtle.setheading(stack.pop())
                turtle.setposition(stack.pop())
                turtle.down()
            elif c == 'L':
                #turtle would draw a green leave
                h = turtle.heading()
                p = turtle.position()
                turtle.color('limegreen')
                turtle.fill(True)
                turtle.circle(distance / 3, 180)
                turtle.fill(False)
                turtle.color('black')
                turtle.up()
                turtle.goto(p)
                turtle.down()
                turtle.setheading(h)
            elif c == 'o':
                # turtle would draw a berry
                turtle.color(random.random(), random.random(), random.random())
                turtle.fill(True)
                turtle.circle(distance / 5, 360)
                turtle.fill(False)
                turtle.color("black")
            elif c == '<':
                #turtle would record the color value
                color.append(turtle.color()[0])
            elif c == '>':
                #turtle would return to the color value recorded before
                turtle.color(color.pop())
            elif c == 'g':
                #turtle would turn to green color
                turtle.color(0.15, 0.5, 0.2)
            elif c == 'y':
                #turtle would turn to yellow color
                turtle.color(0.8, 0.8, 0.3)
            elif c == 'r':
                #turtle would turn to red color
                turtle.color(0.7, 0.2, 0.3)
            elif c == 'b':
                #turtle would change color to brown
                turtle.color('saddlebrown')
            elif c == '%':
                #turtle would change color to chocolate
                turtle.color('chocolate')
            elif c == '!':
                #turtle would change color to black
                turtle.color('black')
            elif c == 'w':
                #turtle would change the width to 2(make the line seems thicker)
                turtle.width(2)
            elif c == 'c':
                #turtle would return to default value of width
                turtle.width(1)
        turtle.update()
Пример #39
0
import turtle, time
wn = turtle.Screen()
############################################################
turtle.up()
turtle.goto(-190, 0)
turtle.down()
time.sleep(6)
for i in range(2):
    turtle.color("green")
    turtle.begin_fill()
    turtle.forward(420)
    turtle.left(90)
    turtle.forward(80)
    turtle.left(90)
    turtle.end_fill()
turtle.up()
turtle.left(90)
turtle.forward(80)
turtle.down()
for i in range(2):
    turtle.color("white")
    turtle.begin_fill()
    turtle.forward(80)
    turtle.right(90)
    turtle.forward(420)
    turtle.right(90)
    turtle.end_fill()
turtle.up()
turtle.forward(80)
turtle.down()
for i in range(2):
Пример #40
0
 def color(self, c):
     turtle.color(c)
import turtle

turtle.color('blue')
turtle.shape('turtle')
turtle.speed(2)

turtle.forward(200)
turtle.left(120)

turtle.forward(200)
turtle.left(120)

turtle.forward(200)
turtle.left(120)
turtle.hideturtle()

turtle.exitonclick()
Пример #42
0
def chooseColor(length):
    if length < 5:
        turtle.color('green')
    else:
        turtle.color('black')
#!/usr/bin/env python
# coding: utf-8

# In[ ]:

import turtle

turtle.shape("turtle")
turtle.color("blue")
turtle.speed(2)

counter = 0
while counter < 54:
    for i in range(4):
        turtle.forward(100)
        turtle.left(90)
    turtle.left(7.5)
    counter += 1
turtle.exitonclick()

# In[ ]:
Пример #44
0
#!/usr/bin/python3

import turtle

height = 10
width = 7

turtle.color("orange")

turtle.speed(2)

turtle.penup()

for y in range(height):
    for x in range(width):
        turtle.dot()
        turtle.forward(20)
    turtle.backward(20 * width)
    turtle.right(90)
    turtle.forward(20)
    turtle.left(90)

turtle.exitonclick()
Пример #45
0
def join(x, y, ex, ey, color):  # 连接线段
    turtle.color(color)
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.goto(ex, ey)
Пример #46
0
import turtle
import time
turtle.screensize(800, 600, "green")
turtle.speed(1)
turtle.forward(300)

turtle.shape("turtle")
turtle.forward(100)
turtle.left(90)
turtle.forward(100)

pony = turtle.Turtle();

'''
pony.shape("turtle")
pony.forward(100)
pony.left(90)
pony.forward(100)
'''


turtle.color("red", "yellow")
turtle.speed(10)
turtle.begin_fill()
for _ in range(50):
    turtle.forward(200)
    turtle.left(170)
turtle.end_fill()
time.sleep(1)

#turtle.done()
Пример #47
0
                        self.beacons.extend(((x, nb_y), (x+1, nb_y), (x, nb_y+1), (x+1, nb_y+1)))
  
    def draw(self):
        for x, y in self.blocks:
            turtle.up()
            turtle.setposition(x, y)
            turtle.down()
            turtle.setheading(90)
            turtle.begin_fill()
            for _ in range(0, 4):
                turtle.fd(1)
                turtle.right(90)
            turtle.end_fill()
            turtle.up()
  
        turtle.color("#00ffff")
        for x, y in self.beacons:
            turtle.setposition(x, y)
            turtle.dot()
        turtle.update()
  
    def weight_to_color(self, weight):
        return "#%02x00%02x" % (int(weight * 255), int((1 - weight) * 255))
  
    def is_in(self, x, y):
        if x < 0 or y < 0 or x > self.width or y > self.height:
            return False
        return True
  
    def is_free(self, x, y):
        if not self.is_in(x, y):
Пример #48
0
	turtle.circle(-padEcart)
	turtle.end_fill()

	turtle.up()
	turtle.goto(0,padEcart)
	turtle.down()

	cpt = 2
	for decimale in decimales:
		turtle.left(90)
		turtle.forward(padEcart)
		turtle.right(90)
		turtle.circle(-padEcart*cpt,decimale*padAngle)
		cpt += 1


decimales = [3,1,4,1,5,9,2,6,5,4]
padEcart = 40
turtle.screensize(2000,1500)
turtle.begin_fill()
turtle.color(0.4,0.4,0.4)
turtle.up()
turtle.goto(0,11*padEcart+10)
turtle.down()
turtle.circle(-(11*padEcart)-10)
turtle.end_fill()
drawAxe(padEcart)
drawPI(padEcart,decimales)
turtle.exitonclick()

Пример #49
0
import turtle as t

t.shape('turtle')
t.color('green', 'yellow')
t.screensize(3000, 2000)
t.speed(10)

inp = open('input')

Number = [[0,0] for i in range(12)]

for i in range(1, 11, 1):
    num = list(inp.readline().split())
    for j in range(len(num)):
        num[j] = num[j].split(',')
    Number[i] = num
Number[0] = Number[10]

index = [1, 4, 1, 7, 0, 7]
for i in index:
    if (i == 1):
        t.up()
        t.lt(270)
        t.fd(50)
        t.lt(90)
        t.down()
        for angle, step in Number[i]:
            angle, step = float(angle), float(step)
            t.lt(angle)
            t.fd(step)
    else:
Пример #50
0
def draw(x, y, r):
    turtle.color('red')  # 画笔为红色
    turtle.penup()  # 提笔
    turtle.goto(x, y)  # 在指定坐标位置抬笔
    turtle.pendown()  # 落笔
    turtle.circle(r)
Пример #51
0
import turtle
import math
turtle.setup(800, 800 * (math.sqrt(5) - 1) / 2)
turtle.penup()
turtle.fd(-300)
turtle.pendown()
turtle.pensize(25)
turtle.color('purple')
turtle.seth(-40)
for i in range(4):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
turtle.circle(40, 40)
turtle.fd(80)
turtle.circle(16, 180)
turtle.fd(80 * 2 / 3)
turtle.done()
Пример #52
0
import turtle as t


t.pensize(3) # 设置画笔的大小
t.color("black")
t.circle(100)
t.right(45)
t.forward(200)
t.backward(200)
t.right(90)
t.forward(200)
t.backward(200)
t.left(45)
t.forward(300)
t.left(45)
t.forward(100)
t.backward(100)
t.right(90)
t.forward(100)
t.mainloop
Пример #53
0
    while num != 0:
        r = num % 10
        if large < r:
            large = r
        num = num // 10
    return large


printLarge(195263)

# In[1]:

# 1. To draw a circle
import turtle

turtle.color("green")
turtle.begin_fill()
turtle.circle(130, 360)
turtle.end_fill()
turtle.hideturtle()
turtle.color("orange")
turtle.begin_fill()
turtle.circle(130, 180)
turtle.end_fill()
turtle.done()

# In[7]:


# 4. To print Palindrome count between 2 limits
def isPalindrome(n):
Пример #54
0
import turtle

turtle.shape("square")
turtle.pensize(8)
turtle.speed(8)
turtle.colormode(255)
turtle.color(255, 0, 0)
turtle.hideturtle()
turtle.forward(150)
turtle.left(85)
turtle.forward(100)
turtle.left(70)
turtle.forward(150)
turtle.left(23)
turtle.forward(100)
turtle.left(60)

turtle.shape("square")
turtle.colormode(255)
turtle.color(255, 58, 0)
turtle.forward(150)
turtle.left(85)
turtle.forward(100)
turtle.left(70)
turtle.forward(150)
turtle.left(23)
turtle.forward(100)
turtle.left(60)

turtle.shape("square")
turtle.colormode(255)
Пример #55
0
import turtle as t

n = 100
t.bgcolor("black")  # 백그라운드 색
t.color("green")  # 선색
t.speed(0)  # 가장 빠른 거북이 속도 // 숫자가 작을수록 빠른속

for x in range(n):
    t.circle(80)
    t.lt(360 / n)
Пример #56
0
import time
import turtle
import os
def draw_rectangle(start_x,start_y,rec_x,rec_y):
    turtle.goto(start_x,start_y)
    turtle.color('red')
    turtle.fillcolor('red')
    turtle.begin_fill()
    for i in range(2):
        turtle.forward(rec_x)
        turtle.left(90)
        turtle.forward(rec_y)
        turtle.left(90)
    turtle.end_fill()


def draw_star(center_x,center_y,radius):
    turtle.setpos(center_x,center_y)
    #find the peak of the five-pointed star
    pt1=turtle.pos()
    turtle.circle(-radius,72)
    pt2=turtle.pos()
    turtle.circle(-radius,72)
    pt3=turtle.pos()
    turtle.circle(-radius,72)
    pt4=turtle.pos()
    turtle.circle(-radius,72)
    pt5=turtle.pos()
    #draw the five-pointed star
    turtle.color('yellow','yellow')
    turtle.fill(True)
Пример #57
0
    turtle.up()  # 提笔
    turtle.goto(x, y)  # 移动画笔到指定起始坐标(窗口中心为0,0)
    turtle.down()  # 下笔
    turtle.showturtle()  # 显示画笔


love = input("请输入表白话语:")
signature = input("请签署你的名字:")
date = input("请写上日期:")

if love == '':
    love = 'I Love You'

#1-3初始化
turtle.setup(width=800, height=500)  # 窗口(画布)大小
turtle.color('red', 'pink')  # 画笔颜色
turtle.pensize(3)  # 画笔粗细
turtle.speed(1)  # 描绘速度
# 初始化画笔起始坐标
move_pen_position(x=0, y=-180)  # 移动画笔位置
turtle.left(140)  # 向左旋转140度

turtle.begin_fill()  # 标记背景填充位置

#1-4画图和展示
turtle.forward(224)  # 向前移动画笔,长度为224
# 画爱心圆弧
hart_arc()  # 左侧圆弧
turtle.left(120)  # 调整画笔角度
hart_arc()  # 右侧圆弧
# 画心形直线( 右下方 )
Пример #58
0
    for i in range(200):
        turtle.right(1)
        turtle.forward(2)


# 输入表白的语句,默认I Love you
love = input(
    'Please enter a sentence of love, otherwise the default is "I Love you": ')
# 输入署名或者赠谁,没有不执行
me = input('Please enter pen name, otherwise the default do not execute: ')
if love == '':
    love = 'I Love you'
# 窗口大小
turtle.setup(width=900, height=500)
# 颜色
turtle.color('red', 'pink')
# 笔粗细
turtle.pensize(3)
# 速度
turtle.speed(1)
# 提笔
turtle.up()
# 隐藏笔
turtle.hideturtle()
# 去到的坐标,窗口中心为0,0
turtle.goto(0, -180)
turtle.showturtle()
# 画上线
turtle.down()
turtle.speed(1)
turtle.begin_fill()
Пример #59
0
import turtle as t
from random import choice
from time import sleep

colors = ('red', 'green', 'blue', 'yellow', 'black')
t.speed('fastest')
t.pu()
t.goto(400, -100)
t.setheading(90)
t.pd()
t.pensize(10)
turn = 10
length = 100
while length > 20:
    t.color(choice(colors))
    t.fd(length)
    t.left(turn)
    turn += 0.1
    length *= 0.99

sleep(1000)
Пример #60
0
Техническое задание:
На основе цветочка из квадратов, сделанного в первой итерации,
нарисовать картину из этого цветочка и солнышка.
Солнышко такое как тут, подойдет https://docs.python.org/3.7/library/turtle.html
В будущем ожидаю увидеть поле из разных цветов. Может, сделать цветок красивее.
"""

import turtle as t

t.penup()
t.speed(40)
t.goto(-200, 200)
a = abs(t.pos())
t.pendown()
t.begin_fill()
t.color('red', 'yellow')
while True:
    t.forward(150)
    t.left(170)
    b = abs(t.pos())
    if (a - 1 < b < a + 1):
        break
t.end_fill()
t.penup()


def draw_square(color, x=0, y=0, size=70):
    t.goto(x, y)
    t.begin_fill()
    t.pendown()
    t.color(color, 'red')