示例#1
1
def draw_circle(x,y):
	turtle.penup()
	turtle.goto(x,y)
	turtle.pendown()
	turtle.begin_fill()
	turtle.circle(10)
	turtle.end_fill()
示例#2
0
def drawLine():
	turtle.penup()
	turtle.goto(-50, 300)
	turtle.pendown()
	turtle.write("Base Line", font=("Arial", 14, "normal"))
	turtle.color("red")
	turtle.forward(500)
示例#3
0
def set(): #set of parameters
    turtle.hideturtle()
    turtle.tracer(1e3,1)
    turtle.left(95)
    turtle.penup()
    turtle.goto(0,-turtle.window_height()/2)
    turtle.pendown()
示例#4
0
    def drawLine(self,color,coord1,coord2): 
        """
        dessine une ligne entre deux coordonné sur la grille

        :param color: La couleur de la ligne
        :param coord1: La première coordonné en tuple (i,j,"joueur")
        :param coord2: La deuxième coordonné en tuple (i,j,"joueur")
        """
        if coord1[2] == coord2[2] and coord2[2] == "you":
            turtle.goto(38+coord1[1]*25,87-25*coord1[0])
        elif coord1[2] == coord2[2] and coord2[2] == "enemy":
            turtle.goto(-262+(25*coord1[1]),87-25*coord1[0])
        else:
            print('wrong player')
            return 0
        turtle.pensize(20)
        turtle.pencolor(color)
        if coord1[1] == coord2[1]: #Vertical
            turtle.pendown()
            turtle.setheading(270)
            turtle.fd((coord2[0]-coord1[0])*25)
        elif coord1[0] == coord2[0]: #horizontal
            turtle.pendown()
            turtle.setheading(0)
            turtle.fd((coord2[1]-coord1[1])*25)
        else:
            print('Ligne non Hori ou Vert')
            return 0
        turtle.penup()
        return 1
示例#5
0
def alpha_beta_helper():
	global state, root, alpha_time
	initialize()
	print("PLEASE WAIT!!!")
	root = TreeNode(-1000)
	time1 = time.time()
	alpha_beta(root, 1, state)
	init_screen()
	drawLine()
	drawGrid()
	drawColumns()
	drawRows()
	caliberate()
	col = root.ans
	row = -1
	turtle.onscreenclick(goto)
	for i in range(4):
		if state[i][col] == 0:
			row = i
			break
	state[row][col] = 1
	drawDot(row, col, 1)
	var = (int)(input("Enter 1 to continue playing or 0 to stop."))
	time2 = time.time()
	alpha_time = time2-time1
	if(var == 1):
		turtle.clear()
		turtle.goto(0, 0)
		turtle.penup()
		turtle.right(270)
		alpha_beta_helper()
	else:
		write_analysis(3)
示例#6
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 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)
示例#8
0
def drawS(turtle, height, width):
    """
    draw the letter S using turtle, with some height and width
    """
    # Pick pen up and move a little to the right
    turtle.penup()
    turtle.setheading(0)
    turtle.forward((1.0/6.0)*width)
    # Put pen down and draw bottom of S
    turtle.pendown()
    turtle.forward((2.0/3.0)*width)
    # Draw first curve
    turtle.left((180.0/math.pi)*math.atan((3.0/2.0)*height/width))
    turtle.forward(math.sqrt(((1.0/6.0)*width)**2+((1.0/4.0)*height)**2))
    turtle.left(180.0-(360.0/math.pi)*math.atan((3.0/2.0)*height/width))
    turtle.forward(math.sqrt(((1.0/6.0)*width)**2+((1.0/4.0)*height)**2))
    turtle.left((180.0/math.pi)*math.atan((3.0/2.0)*height/width))
    # Draw middle of S
    turtle.forward((2.0/3.0)*width)
    # Draw second curve
    turtle.right((180.0/math.pi)*math.atan((3.0/2.0)*height/width))
    turtle.forward(math.sqrt(((1.0/6.0)*width)**2+((1.0/4.0)*height)**2))
    turtle.right(180.0-(360.0/math.pi)*math.atan((3.0/2.0)*height/width))
    turtle.forward(math.sqrt(((1.0/6.0)*width)**2+((1.0/4.0)*height)**2))
    turtle.right((180.0/math.pi)*math.atan((3.0/2.0)*height/width))
    # Draw top of S, pick up pen, and move a little to the right
    turtle.forward((2.0/3.0)*width)
    turtle.penup()
    turtle.forward((1.0/6.0)*width)
示例#9
0
def forGlory(sideLength=50):
	turtle.left(150)
	turtle.penup()
	turtle.setpos(-25,75)
	turtle.color("blue")
	turtle.pendown()
	hexagon(sideLength)
示例#10
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()
示例#11
0
文件: test3.py 项目: mprihodko/python
	def draw(self):
		
		turtle.penup()
		turtle.goto(self.point_st)
		turtle.pendown()
		turtle.color(self.border_c, self.fill_c)	
		self._draw()
示例#12
0
def at(x, y):
    turtle.penup()
    turtle.home()
    turtle.forward(x)
    turtle.left(90)
    turtle.forward(y)
    turtle.pendown()
示例#13
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()
示例#14
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()
示例#15
0
    def draw_path(self, positions):
        '''
        Draws the path given by a position list
        '''

        def position_to_turtle(pos):
            '''Converts a maze position to a turtle position'''
            return (home_x + _DRAW_SIZE * pos[0], home_y - _DRAW_SIZE * pos[1])

        # Get maze size
        width, height = self.size

        # Prepare turtle
        home_x = (-(_DRAW_SIZE * width) / 2) + (_DRAW_SIZE / 2)
        home_y = ((_DRAW_SIZE * height) / 2) - (_DRAW_SIZE / 2)

        turtle.showturtle()
        turtle.pencolor(_DRAW_PATH)

        # Move to star
        turtle.penup()
        turtle.goto(home_x, home_y)
        turtle.pendown()

        # Draw the path
        for pos in positions:
            turtle.goto(position_to_turtle(pos))
示例#16
0
def main():
    file_name = "go"
    
    file_name = raw_input( 'Enter a file name or exit to quit program: ')
    while (file_name != "exit" and file_name != "Exit" and file_name != "quit" and file_name != "Quit"):

        f = open( file_name, 'r' )
    
        first_line = f.readline()
        first_line = first_line.split()
    
        distance = float( first_line[0] )
        angle = float( first_line[1] )
    
        stack = []

        wn = tur.Screen()

        for line in f:
            wn.clear()
            tur.penup()
            tur.seth(90)
            tur.setx(0)
            tur.sety(-200)
            tur.pendown()
            interprit_line(tur, line, angle, distance, stack)
        ts = tur.getscreen()
        ts.getcanvas().postscript(file=file_name +".eps")
        wn.exitonclick()

        file_name = raw_input( 'Enter a file name or exit to quit program: ')
示例#17
0
def draw_rectangle(length_float, width_float, color_str):
    """
    Asks for the length, width, and color of the rectangle and draws it
    using turtle
    
    Recieve:    The length, width and color of the triangle
    Return:     Nothing
    Algorithm:
        Use a for loop and draw a rectangle by going forward the specified
        length and making a 90 degree turn to the right and then going
        forward the width and turning 90 degrees to the right
        Then do the loop again
    """
    
    turtle.fillcolor(color_str)    
    turtle.pendown()
    turtle.begin_fill()
    
    for i in range(2):
        turtle.forward(length_float)
        turtle.right(90)
        turtle.forward(width_float)
        turtle.right(90)
        
    turtle.end_fill()
    turtle.penup()
示例#18
0
def dope_flowers(x, y):
    turtle.pendown()
    turtle.begin_fill()
    move(turtle, 100)
    flower(turtle, 10, 20.0, 60.0)
    turtle.end_fill()
    turtle.penup()
def draw_rectangle():
    Fline = line.split()
    if Fline[1] == 'not_int':
        print(Fline)
        print("I'm sorry, I cannot understand that integer")
        return
    if len(Fline) < 4:
        print(Fline)
        print("I'm sorry, I do not understand that value")
        return
    x = int(Fline[1])
    y = int(Fline[2])
    width = int(Fline[3])
    height = int(Fline[4])
    turtle.penup()
    turtle.setpos(x, y)
    turtle.setheading(0)
    turtle.pendown()
    turtle.begin_fill()
    turtle.forward(width)
    turtle.setheading(-90)
    turtle.forward(height)
    turtle.setheading(180)
    turtle.forward(width)
    turtle.setheading(90)
    turtle.forward(height)
    turtle.end_fill()
def drawPoint(x, y): 
    turtle.penup() # Pull the pen up
    turtle.goto(x, y)
    turtle.pendown() # Pull the pen down
    turtle.begin_fill() # Begin to fill color in a shape
    turtle.circle(3) 
    turtle.end_fill() # Fill the shape
示例#21
0
文件: one.py 项目: cparker/pythonclub
def drawCircleAt(turtleX, turtleY, circleSize):
    turtle.penup()
    turtle.goto(turtleX,turtleY)
    turtle.pendown()
    turtle.begin_fill()
    turtle.circle(circleSize)
    turtle.end_fill()
示例#22
0
def main():
  ap = ArgumentParser()
  ap.add_argument('--speed', type=int, default=10,
                  help='Number 1-10 for drawing speed, or 0 for no added delay')
  ap.add_argument('program')
  args = ap.parse_args()

  for kind, number, path in parse_images(args.program):
    title = '%s #%d, path length %d' % (kind, number, path.shape[0])
    print(title)
    if not path.size:
      continue
    pen_up = (path==0).all(axis=1)
    # convert from path (0 to 65536) to turtle coords (0 to 655.36)
    path = path / 100.
    turtle.title(title)
    turtle.speed(args.speed)
    turtle.setworldcoordinates(0, 655.36, 655.36, 0)
    turtle.pen(shown=False, pendown=False, pensize=10)
    for i,pos in enumerate(path):
      if pen_up[i]:
        turtle.penup()
      else:
        turtle.setpos(pos)
        turtle.pendown()
        turtle.dot(size=10)
    _input('Press enter to continue')
    turtle.clear()
  turtle.bye()
示例#23
0
def draw_grid(ll,ur):
	size = ur - ll
	for gridsize in [1, 2, 5, 10, 20, 50, 100 ,200, 500]:
		lines = (ur-ll)/gridsize
		# print('gridsize', gridsize, '->', int(lines)+1, 'lines')
		if lines <= 11: break
	turtle.color('gray')
	turtle.width(1)
	x = ll
	while x <= ur:
		if int(x/gridsize)*gridsize == x:
			turtle.penup()
			turtle.goto(x, ll-.25*gridsize)
			turtle.write(str(x),align="center",font=("Arial",12,"normal"))
			turtle.goto(x,ll)
			turtle.pendown()
			turtle.goto(x,ur)
			# print(x,ll,'to',x,ur)
		x += 1
	y = ll
	while y <= ur:
		# horizontal grid lines:
		if int(y/gridsize)*gridsize == y:
			turtle.penup()
			turtle.goto(ll-.1*gridsize, y - .06*gridsize)
			turtle.write(str(y),align="right",font=("Arial",12,"normal"))
			turtle.goto(ll,y)
			turtle.pendown()
			turtle.goto(ur,y)
			# print(ll,y,'to',ur,y)
		y += 1
示例#24
0
   def initialize_plot(self, positions):
      self.positions = positions
      self.minX = minX = min(x for x,y in positions.values())
      maxX = max(x for x,y in positions.values())
      minY = min(y for x,y in positions.values())
      self.maxY = maxY = max(y for x,y in positions.values())
      
      ts = turtle.getscreen()
      if ts.window_width > ts.window_height:
          max_size = ts.window_height()
      else:
          max_size = ts.window_width()
      self.width, self.height = max_size, max_size
      
      turtle.setworldcoordinates(minX-5,minY-5,maxX+5,maxY+5)
      
      turtle.setup(width=self.width, height=self.height)
      turtle.speed("fastest") # important! turtle is intolerably slow otherwise
      turtle.tracer(False)    # This too: rendering the 'turtle' wastes time
      turtle.hideturtle()
      turtle.penup()
      
      self.colors = ["#d9684c","#3d658e","#b5c810","#ffb160","#bd42b3","#0eab6c","#1228da","#60f2b7" ]

      for color in self.colors:         
         s = turtle.Shape("compound")
         poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
         s.addcomponent(poly1, color, "#000000")
         turtle.register_shape(color, s)
      
      s = turtle.Shape("compound")
      poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
      s.addcomponent(poly1, "#000000", "#000000")
      turtle.register_shape("uncolored", s)
示例#25
0
def entrance(pointOne):
    turtle.goto(pointOne[0], pointOne[1] + 36)
    turtle.setheading(270)
    turtle.pendown()
    turtle.forward(15)
    turtle.penup()
    drawArrows()
def drawFins(size):
    
    turtle.fillcolor("red")    
    turtle.setheading(90)
    turtle.begin_fill()
    turtle.forward(0.2*size)
    turtle.left(120)
    turtle.forward(0.6*size) 
    turtle.right(120)
    turtle.forward(0.3*size) 
    turtle.right(40)
    turtle.forward(0.8*size)
    turtle.end_fill()    
    
    turtle.setheading(0)
    
    turtle.begin_fill()

    turtle.penup()
    turtle.forward(size)
    turtle.pendown()
    turtle.begin_fill()
    turtle.right(50)
    turtle.forward(0.8*size) 
    turtle.right(40)
    turtle.forward(0.3*size) 
    turtle.right(120)
    turtle.forward(0.6*size)
    turtle.end_fill()
def draw_rectangle(x,y,width,height):
    """
    Draws a rectangle with the upper left hand corner starting at point (x,y).
    The said rectangle has the dimensions width x height.
    :param x:
    :param y:
    :param width:
    :param height:
    :return: None
    """
    turtle.penup()
    turtle.setx(x)
    turtle.sety(y)
    turtle.pendown()
    turtle.setheading(0)  # Set heading in x+ direction
    turtle.begin_fill()
    turtle.begin_poly()
    turtle.fd(width)
    turtle.right(90)
    turtle.fd(height)
    turtle.right(90)
    turtle.fd(width)
    turtle.right(90)
    turtle.fd(height)
    turtle.end_poly()
    turtle.end_fill()
    return None
def main():
    turtle.setup(800, 350, 200, 200)
    turtle.penup()
    turtle.fd(-300)
    turtle.pensize(5)
    drawDate(datetime.datetime.now().strftime('%Y%m%d'))
    turtle.hideturtle()
def drawP(size):
    turtle.setheading(90)
    turtle.penup()
    turtle.forward(size*1.5);
    turtle.pendown()
    turtle.forward(size*0.5);
    drawSemi(size, direction="right", degrees=336, colour="black")
def printwin(turtle):
  turtle.stamp()
  turtle.hideturtle()
  turtle.penup()
  turtle.goto(0,0)
  turtle.color("green")
  turtle.write("You Win!",font=("Arial",30), align = "center")
示例#31
0
def MoveTo(x, y):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
示例#32
0
def drawGap():
    turtle.penup()
    turtle.fd(5)
示例#33
0
import turtle as t
t.setup(1000, 1000)
t.penup()
t.down()
t.pensize(20)
t.pencolor("black")

t.fd(100)

for i in range(1, 6):
    j = i * 60
    t.seth(j)
    t.fd(100)
t.done()
'''
t.seth(60)
t.fd(100)

t.seth(120)
t.fd(100)

t.seth(180)
t.fd(100)

t.seth(240)
t.fd(100)

t.seth(300)
t.fd(100)
t.done()
'''
def draw_poly(n, length):
    for i in range(n):
        tl.left(360/n)
        tl.forward(length)


def my_sin(n):
    return math.sin(math.radians(n))


def get_radius(a, n):
    return a / (2*my_sin(360/(2*n)))


x, y = 0, 0

distance = 20
length = 50
radius = 0

for i in range(3, 10):
    radius = get_radius(length, i)
    tl.penup()
    tl.goto(x + radius, y)
    tl.pendown()
    tl.left((180 - (360/i))/2)
    draw_poly(i, length)
    tl.right((180 - (360 / i)) / 2)
    length += 20
示例#35
0
def drawGap():
    t.penup()
    t.fd(5)
示例#36
0
def drawLine(flag):
    drawGap()
    t.pendown() if flag else t.penup()
    t.fd(40)
    drawGap()
    t.right(90)
示例#37
0
from turtle import forward, left, right, penup, pendown, setposition, exitonclick
from math import sqrt
#move
penup()
setposition(-200.0, 0.0)
pendown()
houses = 7
#village
for i in range(houses):
    #variables
    x = 50
    diagonal = sqrt(2 * (x**2))
    #let's draw
    forward(x)
    left(135)
    forward(diagonal)
    right(135)
    forward(x)
    left(120)
    forward(x)
    left(120)
    forward(x)
    left(30)
    forward(x)
    left(135)
    forward(diagonal)
    right(135)
    forward(x)
    left(90)
    forward(20)
示例#38
0
def drawLine(draw):
    drawGap()
    turtle.pendown() if draw else turtle.penup()
    turtle.fd(40)
    drawGap()
    turtle.right(90)
示例#39
0
def krisha():
    turtle.left(90)
    turtle.penup()
    turtle.forward(65)
    turtle.pendown()
    turtle.left(90)
    turtle.forward(170)
    turtle.left(90)
    turtle.forward(350)
    turtle.right(90)
    turtle.forward(70)
    turtle.right(45)
    turtle.forward(175 * math.sqrt(2))
    turtle.right(90)
    turtle.forward(175 * math.sqrt(2) + 25)
    turtle.left(45)
    turtle.forward(17)
    turtle.left(135)
    turtle.forward(175 * math.sqrt(2) + 50)
    turtle.left(90)
    turtle.forward(175 * math.sqrt(2) + 50)
    turtle.left(135)
    turtle.forward(17)
    turtle.left(45)
    turtle.forward(25)
    turtle.right(45)
    turtle.forward(140)
    turtle.left(90)
    turtle.penup()
    turtle.forward(60)
    turtle.pendown()
    quad(70, -90)
    turtle.right(180)
    turtle.forward(70)
    turtle.left(90)
    turtle.forward(7)
    turtle.left(90)
    turtle.penup()
    turtle.forward(5)
    turtle.pendown()
    prm(60, 55, 90)
    turtle.left(180)
    turtle.penup()
    turtle.forward(125)
    turtle.left(90)
    turtle.forward(220)
    turtle.left(135)
    turtle.forward(100)
    turtle.right(45)
    turtle.pendown()
    turtle.forward(90)
    turtle.right(90)
    turtle.forward(20)
    turtle.left(90)
    turtle.forward(30)
    turtle.left(90)
    turtle.forward(70)
    turtle.left(90)
    turtle.forward(30)
    turtle.left(90)
    turtle.forward(60)
    turtle.left(180)
    turtle.forward(40)
    turtle.left(90)
    turtle.forward(57)
示例#40
0
def gotoxy(x, y):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
示例#41
0
def line(startX, startY, endX, endY, color):
    turtle.penup()  # Raise the pen
    turtle.goto(startX, startY)  # Move to the starting point
    turtle.pendown()  # Lower the pen
    turtle.pencolor(color)  # Set the pen color
    turtle.goto(endX, endY)  # Draw a square
示例#42
0
def movepen(x, y, d):
    t.penup()
    t.goto(x, y)
    t.setheading(d)
    t.pendown()
示例#43
0
            neighbour.add(tuple(p[t][2]))
        if p[t][3] != 0:
            neighbour.add(tuple(p[t][3]))
        if p[t][4] != 0:
            neighbour.add(tuple(p[t][4]))
        
        return neighbour


import turtle as tr
r=50
tr.setworldcoordinates(0,0,(12-S)*r,(12-S)*r)
tr.speed('fastest')
tr.tracer(0,0)
tr.ht()
tr.penup()
clr={}
def colour(t):
    tr.setposition(t[0]*r,(11-S-t[1])*r)
    tr.color("pink","pink")
    tr.st()
    #time.sleep(0.5)
    tr.ht()
    tr.color("green","green")
    tr.pendown()
    tr.shape("square")
    q=tr.stamp()
    tr.penup()
    clr[t]=q
'''
def c1(t):
示例#44
0
def fprint(t):
    
    tr.setposition(t[0]*r,(11-S-t[1])*r)
    tr.pendown()
    tr.write(str(fscore(t))+" ",False,'right')
    tr.penup()
示例#45
0
def tscheme_penup():
    """Raise the pen, so that the turtle does not draw."""
    _tscheme_prep()
    turtle.penup()
示例#46
0
文件: 02Lab.py 项目: KyleMiles/School
 def draw(self):
     turtle.penup()
     turtle.goto(*self._location)
     turtle.dot(self._size * 2, self._color)
示例#47
0
 def draw (self):
     turtle.penup()
     turtle.goto(self.x, self.y - super().SIZE/2)
     turtle.pendown()
     turtle.setheading(0)
     turtle.circle(super().SIZE)
示例#48
0
 def draw (self):
     turtle.penup()
     turtle.goto(self.x, self.y)
     turtle.write("*")
示例#49
0
 def write_text(self, text, x=0, y=0, font='Arial', size=16) -> None:
     turtle.penup()
     turtle.goto(x, y)
     turtle.write(text, font=(font, size, 'normal'), align='center')
示例#50
0
import turtle
#Everything that comes after the # is a
#comment.
#It is a note to the person reading the code.
#The computer ignores it.
#Write your code below here...
# ...and end it before the next line.
turtle.penup()  #Pick up the pen so it doesn’t
#draw
turtle.goto(-200, -100)  #Move the turtle to the
#position (-200, -100)
#on the screen
turtle.pendown()  #Put the pen down to start
#drawing
#Draw the M:
turtle.goto(-200, -100 + 200)
turtle.goto(-200 + 50, -100)
turtle.goto(-200 + 100, -100 + 200)
turtle.goto(-200 + 100, -100)

turtle.penup()  #Pick up the pen so it doesn’t
#draw
turtle.goto(0, -100)  #Move the turtle to the
#position (-200, -100)
#on the screen
turtle.pendown()  #Put the pen down to start
#drawing
#Draw the E:
turtle.goto(0, -100 + 200)
turtle.goto(0, -100)
turtle.goto(0, -100 + 200)
示例#51
0
import turtle as turtle
import random

print("Welcome to your drawing app! Select a shape you want to draw. After typing the number and hitting enter, go to the result tab!")

turtle.penup()
turtle.left(90)
turtle.forward(250)
turtle.left(90)
turtle.forward(300)
turtle.pendown()

turtle.write("Drawing App!", font=("Arial", 16, "normal"))

turtle.penup()
turtle.left(90)
turtle.forward(50)
turtle.pendown()

turtle.write("To draw a shape, go to the Console tab and choose an option!", font=("Arial", 16, "normal"))

turtle.penup()
turtle.forward(150)
turtle.left(90)
turtle.forward(150)
turtle.pendown()

def star():
  for i in range(0,5):
    turtle.forward(110)
    turtle.left(216)
示例#52
0
 def draw_polarline(self, angle, radius_1, radius_2) -> None:
     '''Draw a line directly out from center with endpoints specified by radii'''
     turtle.penup()
     turtle.goto(*self.circle_xy(angle, radius_1))
     turtle.pendown()
     turtle.goto(*self.circle_xy(angle, radius_2))
示例#53
0
def draw_wall(turtle, positions):
    turtle.penup()
    turtle.setposition(positions[0])
    turtle.pendown()
    for position in positions[1:]:
        turtle.setposition(position)
def apple(turtle, rand):
    turtle.hideturtle()
    turtle.penup()
    turtle.setheading(-90)
    rand = random.randrange(-300, 300)
    turtle.goto(rand, 300)
示例#55
0
def Skip(step):
    turtle.penup()
    turtle.forward(step)
    turtle.pendown()
示例#56
0
 def __init__(self):
     from turtle import speed, penup, hideturtle, degrees
     speed(0)
     penup()
     hideturtle()
     degrees(360)
示例#57
0
def line(startX, startY, endX, endY, color):
    turtle.penup()  # Поднять перо.
    turtle.goto(startX, startY)  # Переместить в начальную точку.
    turtle.pendown()  # Опустить перо.
    turtle.pencolor(color)  # Задать цвет заливки.
    turtle.goto(endX, endY)  # Нарисовать треугольник.
import turtle as tu
import random as rand
import math

fd, lt, rt = 0.5, 0.3, 0.2

angle = 90

tu.hideturtle()
tu.speed(0)
tu.screensize(500, 500)
tu.penup()

def erasableWrite(tortoise, name, font, align, reuse=None):
    eraser = tu.Turtle() if reuse is None else reuse
    eraser.hideturtle()
    eraser.up()
    eraser.setposition(tortoise.position())
    eraser.write(name, font=font, align=align)
    return eraser


tu.goto(-250, -250)
tu.pencolor(0.9, 0.9, 0.9)
tu.pendown()
for i in range(4): 
    tu.forward(500) 
    tu.left(90)


tu.penup()
    def eye(self, eye_type):
        print("画眼睛....")
        if eye_type == "large":
            # 设置填充颜色
            turtle.fillcolor("red")
            # left eye
            turtle.goto(-100, 150)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(40, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()

            # 眼睛中的黑色部分
            turtle.fillcolor("black")
            turtle.goto(-120, 150)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(15, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()

            # right eye
            # 设置填充颜色
            turtle.fillcolor("red")
            # 光标移位
            turtle.goto(60, 150)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(40, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()

            # right 眼睛中的黑色部分
            turtle.fillcolor("black")
            turtle.goto(40, 150)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(15, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()

        elif eye_type == "small":
            # left eye
            # 设置填充颜色
            turtle.fillcolor("red")
            turtle.goto(-120, 140)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(20, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()
            # 眼球
            turtle.fillcolor("black")
            turtle.goto(-120, 150)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(4, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()

            # right eye
            # 设置填充颜色
            turtle.fillcolor("red")
            turtle.goto(30, 150)
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(20, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()

            # right 眼球
            turtle.fillcolor("black")
            turtle.goto(30, 155)
            # 准备填充
            turtle.begin_fill()
            turtle.pendown()
            turtle.circle(4, 360)
            # 填充结束
            turtle.end_fill()
            turtle.penup()
示例#60
0
def sofSquares(size, level):
    """
    The method implements the recursion of squares
    :param size: The size of the figure
    :param level: The level of recursion
    """

    if level == 0:
        drawSquare(size / 3);

    elif level == 1:

        turtle.pendown()
        drawSquare(size / 3)
        turtle.penup()
        turtle.forward(size / 3)
        turtle.left(90)
        turtle.forward(size/3)
        turtle.right(90)
        turtle.pendown()
        drawSquare(size / 3)
        turtle.penup()
        turtle.right(90)
        turtle.forward(2*size / 3)
        turtle.left(90)
        turtle.pendown()
        drawSquare(size / 3)
        turtle.penup()
        turtle.back(2*size / 3)
        turtle.pendown()
        drawSquare(size / 3)
        turtle.penup()
        turtle.left(90)
        turtle.forward(2*size / 3)
        turtle.right(90)
        turtle.pendown()
        drawSquare(size / 3)
        turtle.penup()
        turtle.forward(size/3)
        turtle.right(90)
        turtle.forward(size/3)
        turtle.left(90)


    else:
        turtle.pendown()
        sofSquares(size / 3, level-1)
        turtle.penup()
        turtle.forward(size / 3)
        turtle.left(90)
        turtle.forward(size / 3)
        turtle.right(90)
        turtle.pendown()
        sofSquares(size / 3,level-1)
        turtle.penup()
        turtle.right(90)
        turtle.forward(2 * size / 3)
        turtle.left(90)
        turtle.pendown()
        sofSquares(size / 3,level-1)
        turtle.penup()
        turtle.back(2 * size / 3)
        turtle.pendown()
        sofSquares(size / 3,level-1)
        turtle.penup()
        turtle.left(90)
        turtle.forward(2 * size / 3)
        turtle.right(90)
        turtle.pendown()
        sofSquares(size / 3,level-1)
        turtle.penup()
        turtle.forward(size / 3)
        turtle.right(90)
        turtle.forward(size / 3)
        turtle.left(90)