예제 #1
0
def main():
    # to display the degree sign when printing results
    deg = u'\N{DEGREE SIGN}'

    turtle.setup(500, 500)                   # make window set size
    win = turtle.Screen()                    # refer to the screen as win
    win.title( "Triangles and Angles!")         # change the window title
    win.bgcolor( "#D3D3D3")               # change background color

    # get 3 X,Y coords from the user using eval( input())
    x1, y1, x2, y2, x3, y3 = eval( input( "Give 3 points: [e.g. 20, 20, 100, 200, 20, 200]  "))

    # compute the distances of all points
    a = distance( x1, y1, x2, y2)
    b = distance( x2, y2, x3, y3)
    c = distance( x1, y1, x3, y3)

    # round off 
    d1 = round( a * 100) / 100.0
    d2 = round( b * 100) / 100.0
    d3 = round( c * 100) / 100.0

    # make 3 seperate calls to determine_angle to find all angles opposite their sides
    angle_x = determine_angle( a,b,c)
    angle_y = determine_angle( b,c,a)
    angle_z = determine_angle( c,b,a)
    print( "The angles of the triangle are:")
    print( "\tAngle A: {:.2f}{}  \n\tAngle B: {:.2f}{}  \n\tAngle C: {:.2f}{}".format( angle_x,deg,angle_y,deg,angle_z,deg),end='\n\n')
    
    # draw the grid for the layout and referencing of plots
    draw_grid()
    draw_line( x1, y1, x2, y2, x3, y3, angle_x, angle_y, angle_z)
    
    turtle.done()
예제 #2
0
def draw_figures(figures):
    for figure in figures:
        t = Turtle()
        t.speed('slow')
        figure.draw_figure(t)

    done()
예제 #3
0
def draw_table(dimension: int, side: int, turtle: Turtle, x_coord: int, y_coord: int) -> None:
    fill = False

    for i in range(dimension ** 2):
        if i % dimension == 0:
            y_coord -= side
            turtle.penup()
            turtle.setpos(x_coord, y_coord)
            turtle.pendown()
            fill = fill != (dimension % 2 == 0)

        if fill:
            turtle.begin_fill()

        for _ in range(4):
            turtle.forward(side)
            turtle.right(90)

        if turtle.filling():
            turtle.end_fill()

        turtle.forward(side)

        fill = not fill

    done()
예제 #4
0
def printTreeGraphic(brotherList):
    t = turtle.Turtle()
    setRoot()
    distX = 110
    distY = 110
    global mybox
    for b in brotherList:
        mybox = Card((b.column*distX,150-(b.row*distY)), 180, 60)
        if b.status == 1:
            mybox.setColor("#00a0df")
            mybox.setTextColor("white")
        else:
            mybox.setColor("white")
            mybox.setTextColor("black")
            
        mybox.setTilt(30)
        mybox.drawCard(b)


    ## Save ##
    #t.getscreen().getcanvas().postscript(file = "t1.eps")

    ## END ##
    turtle.done()
    return
예제 #5
0
def main():

    
    turtle.forward(100)
    turtle.right(90)
    turtle.forward(50)
    turtle.right(90)
    turtle.forward(100)
    turtle.right(90)
    turtle.forward(50)
    turtle.left(135)
    turtle.forward(50)
    turtle.left(45)
    turtle.forward(50)
    turtle.right(270)
    turtle.forward(100)
    turtle.left(45)
    turtle.forward(50)
    turtle.left(45)
    turtle.forward(50)
    turtle.left(135)
    turtle.forward(50)
    turtle.right(45)
    turtle.forward(100)
    turtle.forward(-100)
    turtle.left(90)
    turtle.forward(50)
    turtle.right(50)
    turtle.right(40)
    turtle.forward(100)
    turtle.right(135)
    turtle.forward(50)
    turtle.done()
예제 #6
0
 def draw(self):
     turtle.forward(self.radius)
     turtle.left(90)
     turtle.circle(self.radius, extent=self.angle)
     turtle.left(90)
     turtle.forward(self.radius)
     turtle.done()
예제 #7
0
	def plot(self, node1, node2, debug=False):
		"""Plots wires and intersection points with python turtle"""
		tu.setup(width=800, height=800, startx=0, starty=0)
		tu.setworldcoordinates(-self.lav, -self.lav, self.sample_dimension+self.lav, self.sample_dimension+self.lav)
		tu.speed(0)
		tu.hideturtle()
		for i in self.index:
			if debug:
				time.sleep(2)   # Debug only
			tu.penup()
			tu.goto(self.startcoords[i][0], self.startcoords[i][1])
			tu.pendown()
			tu.goto(self.endcoords[i][0], self.endcoords[i][1])
		tu.penup()
		if self.list_of_nodes is None:
			intersect = self.intersections(noprint=True)
		else:
			intersect = self.list_of_nodes
		tu.goto(intersect[node1][0], intersect[node1][1])
		tu.dot(10, "blue")
		tu.goto(intersect[node2][0], intersect[node2][1])
		tu.dot(10, "blue")
		for i in intersect:
			tu.goto(i[0], i[1])
			tu.dot(4, "red")
		tu.done()
		return "Plot complete"
예제 #8
0
def main():
    turtle = Turtle()
    turtle.speed(0)
    turtle.home()
    turtle.left(90)
    drawTree(turtle, 8, 150)
    done()
예제 #9
0
def draw_pyramid(side: Number):
    """
    Plots a pyramid using turtle
    :param side: length of side
    :return: Plot of pyramid
    """
    turtle.forward(side)
    turtle.left(45)
    turtle.forward(side)
    turtle.left(135)
    turtle.forward(side)
    turtle.left(45)
    turtle.forward(side)
    turtle.goto(0, 0)
    turtle.penup()
    turtle.goto(0, 0)
    turtle.pendown()
    turtle.goto(side/2, 200)
    turtle.penup()
    turtle.goto(side, 0)
    turtle.pendown()
    turtle.goto(side/2, 200)
    turtle.penup()
    turtle.goto(side*cos(pi/4), side*sin(pi/4))
    turtle.pendown()
    turtle.goto(side/2, 200)
    turtle.penup()
    turtle.goto(side*(1+cos(pi/4)), side*sin(pi/4))
    turtle.pendown()
    turtle.goto(side/2, 200)
    turtle.done()
예제 #10
0
def main(argv):
  user_file = ""

  # User GetOpt to Pull File from Command Line
  try:
    opts, args = getopt.getopt(argv,"hi:",["ifile="])
  except getopt.GetoptError:
    print("name-strip.py -i <input_file>")
    sys.exit(2)
  for opt, arg in opts:
    if opt in ("-h", "--help"):
      print("name-strip.py HELP\n\t-i <input_file>\t selects input file csv to interpret as map")
      sys.exit()
    elif opt in ("-i", "--ifile"):
      user_file = arg

  # Quit if no File Given
  if user_file == "":
    print("No file entered. Program terminating.")
    sys.exit()

  # Set Up CSV Reader
  mapReader = csv.reader(open(user_file, newline=''), delimiter=',', quotechar='|')

  # Iterate Through CSV
  for map_item in mapReader:
    #print("Map Item:", map_item)
    if map_item[0] == "c":
      create_city(map_item)
    else:
      create_road(map_item)

  turtle.hideturtle()
  turtle.done()
예제 #11
0
def main():
    bob = turtle.Turtle()

    bob.speed(20)

    theta = 137.508
    a = 1
    b = 1
    c = 1
    #radius = c*theta**0.5

    for r in range(500):
        radius = a + b*r**(1/c)
        # red = r/500.0
        # gre = r/500.0
        # blu = r/500.0
        # if r%3 == 0:
        #     bob.pencolor((1,1-gre,0))
        # elif r%3 == 1:
        #     bob.pencolor((1,1,0))
        # else:
        #     bob.pencolor((1,gre,blu))
        bob.dot()
        bob.penup()
        bob.left(theta)
        bob.forward(radius)

    turtle.done()
예제 #12
0
def draw_triangle(l):
    i=0
    while(i<3):
        turtle.forward(l)
        turtle.left(120)
        i=i+1
    turtle.done()
예제 #13
0
def draw_regular_hexagon(l):
    i=0
    while(i<6):
        turtle.forward(l)
        turtle.left(60)
        i=i+1
    turtle.done()
예제 #14
0
 def draw(self):
     for i in range(0,2):
         turtle.forward(self.length)
         turtle.left(90)
         turtle.forward(self.width)
         turtle.left(90)
     turtle.done()
예제 #15
0
def main():
    """ The main function, which creates a turtle and uses it to draw a happy robot
    :return: None
    """
    t = turtle.Turtle()

    body = [Square(0, 0, 200)]
    head = [Circle(0, 200, 100),
            Circle(50, 230, 20),
            Circle(-50, 230, 20),
            Triangle(50, 170, 0, 150, -50, 170),
            Triangle(40, 300, 0, 340, -40, 300)
            ]
    arms = [Rectangle(150, 100, 100, 20, 10),
            Rectangle(200, 150, 100, 20, 70),
            Rectangle(-150, 80, 100, 20, 10),
            Rectangle(-200, 30, 100, 20, 70)
            ]
    legs = [Rectangle(100, -200, 20, 200, 5),
            Rectangle(-100, -200, 20, 200, -5)
            ]

    robot = body + arms + legs + head

    for shape in robot:
        shape.draw(t)

    t.hideturtle()
    turtle.done()
예제 #16
0
def draw_figures(area: Number):
    """
    Plots figures of the same area
    :param area: Area of figures
    :return:Plot of figures
    """
    begin_fill()
    turtle.right(45)
    turtle.forward(sqrt(area))
    turtle.right(90)
    turtle.forward(sqrt(area))
    turtle.right(90)
    turtle.forward(sqrt(area))
    turtle.right(90)
    turtle.forward(sqrt(area))
    i = 0
    while (i < 4):
        turtle.forward(sqrt(area))
        turtle.left(90)
        i = i+1
    turtle.circle(sqrt(area/pi))
    turtle.forward(sqrt(2*area))
    turtle.left(135)
    turtle.forward(sqrt(2)*sqrt(2*area))
    turtle.left(135)
    turtle.forward(sqrt(2*area))

    turtle.done()
예제 #17
0
def main():
    bob = turtle.Turtle()
    turtle.title('Sun Figure')
    turtle.setup(800, 800, 0, 0)
    bob.speed(0)
    bobMakesASun(bob, 1, 'purple')
    turtle.done()
예제 #18
0
def drawLines(line_arr):
    turt = turtle.Turtle()
    turtle.shape("blank")
    # draws each line in the line_arr
    for line in line_arr:
        draw_single_line(line, turt)
    turtle.done()
예제 #19
0
파일: draw_image.py 프로젝트: RIT-2015/CPS
def init():
    global totalWood
    global maxHeight
    trees = int(input("How many trees in your forest?"))
    house = input("Is there a house in the forest (y/n)?")
    turtle.penup()
    turtle.setposition(-330, -100)
    if(trees < 2 and house == "y"):
        print("we need atleast two trees for drawing house")
        turtle.done()
    else:
        position_of_house = random.randint(1, trees - 1)
        counter = 1
        house_drawn = 0
        while counter <= trees :
            if counter - 1 == position_of_house and house_drawn == 0:
                y = drawHouse(100)
                house_drawn = 1
                totalWood = totalWood + y
                spaceBetween(counter, trees)
            else:
                type_of_tree = random.randint(1, 3)
                wood, height = drawTrees(type_of_tree)
                spaceBetween(counter, trees)
                totalWood = totalWood + wood
                counter = counter + 1
                if height > maxHeight:
                    maxHeight = height

    turtle.penup()
    draw_star(maxHeight)
    turtle.hideturtle()
    input("Press enter to exit")
예제 #20
0
def main():

    # want to edit the global copy
    global board

    # print out the "Apocalypse" text
    print("""
       (                         (
       )\                      ) )\(             (
    ((((_)(  `  )  (    (  ( /(((_)\ ) `  )  (   ))\\
     )\ _ )\ /(/(  )\   )\ )(_) )_(()/( /(/(  )\ /((_)
     (_)_\(_|(_)_\((_) ((_| (_)_| |(_)|(_)_\((__|__))
      / _ \ | '_ \) _ \/ _|/ _` | | || | '_ \|_-< -_)
     /_/ \_\| .__/\___/\__|\__,_|_|\_, | .__//__|___|
            |_|                    |__/|_|
        """)
    print("Welcome to Apocalypse!!\nThis is a simultaneous turn game which is based upon rules of chess\n")
    draw_board()
    penaltyCount()

    # bind the event handler
    screen.onclick(clicky)
    screen.onkeyrelease(save_state, "s")
    screen.onkeyrelease(load_state, "l")

    screen.listen()
    turtle.done()
예제 #21
0
 def draw(self):
     for i in range(2):
        turtle.forward(self.base)
        turtle.left(60)
        turtle.forward(self.slant_height)
        turtle.left(120)
     Parallelogram(100, 50, 200)
     turtle.done()
예제 #22
0
 def draw(self):
     turtle.forward(self.side_c)
     turtle.left(180 - self.angleB)
     turtle.forward(self.side_a)
     turtle.left(180 - self.angleC)
     turtle.forward(self.side_b)
     turtle.left(180 - self.angleA)
     turtle.done()
예제 #23
0
def draw_right_angle_triangle(x,y,r):

        turtle.forward(x)
        turtle.left(90)
        turtle.forward(y)
        turtle.left(135)
        turtle.forward(r)
        turtle.done()
def spiralStar():
   spiral = turtle.Turtle()

   for i in range(20):
       spiral.forward(i * 10)
       spiral.right(144)
    
   turtle.done()
예제 #25
0
def draw_square(side):
     i = 0;
     while (i < 4):
         turtle.forward(side)
         turtle.left(90)
         i = i+1

     turtle.done()
 def draw(self):
     for i in range(0,2):
         turtle.forward(200)
         turtle.left(120)
         turtle.forward(200)
         turtle.left(120)
         i = i + 1
     turtle.done()
예제 #27
0
 def draw(self):
     turtle.forward(self.length1)
     turtle.left(90)
     turtle.forward(self.height)
     turtle.left(90)
     turtle.forward(self.length2)
     turtle.goto(0,0)
     turtle.done()
예제 #28
0
 def draw(self):
     for i in range(2):
         turtle.forward(self.length)
         turtle.left(90)
         turtle.forward(self.breadth)
         turtle.left(90)
     Rectangle(100, 50)
     turtle.done()
예제 #29
0
 def draw(self):
     for i in range(0,2):
        turtle.forward(self.base)
        turtle.left(90)
        turtle.forward(self.height)
        turtle.left(90)
        i = i+1
     turtle.done()
예제 #30
0
def draw_circle(radius: Number):
    """
    Plots a circle using turtle
    :param radius: Radius of circle
    :return: Plot of circle
    """
    turtle.circle(radius)
    turtle.done()
예제 #31
0
def txt():
    t1 = (x, y)
    t2 = (x + 12, y - 12)
    penSize = 5
    t.screensize(400, 400, "#fff")
    t.pensize(penSize)
    t.pencolor("#ff0000")
    t.speed(10)
    t.hideturtle()
    # 点、
    t.up()
    t.goto(t1)
    t.down()  # 移动,画线
    t.goto(t2)

    # 横 -
    x1 = x - 18
    y1 = y - 22
    t3 = (x1, y1)
    t4 = (x1 + 60, y1)
    t.up()
    t.goto(t3)
    t.down()
    t.goto(t4)

    # 点、、
    x2 = x1 + 16
    y2 = y1 - 10
    t5 = (x2, y2)
    t6 = (x2 + 8, y2 - 16)
    t7 = (x2 + 26, y2)
    t8 = (x2 + 18, y2 - 18)
    t.up()
    t.goto(t5)
    t.down()
    t.goto(t6)
    t.up()
    t.goto(t7)
    t.down()
    t.goto(t8)

    # 长横-
    x3 = x1 - 15
    y3 = y2 - 24
    t9 = (x3, y3)
    t10 = (x3 + 90, y3)
    t.up()
    t.goto(t9)
    t.down()
    t.goto(t10)

    # 横 -
    x4 = x3 + 10
    y4 = y3 - 22
    t11 = (x4, y4)
    t12 = (x4 + 70, y4)
    t.up()
    t.goto(t11)
    t.down()
    t.goto(t12)

    # 竖 |
    x5 = x + 12
    y5 = y3
    t13 = (x5, y5)
    t14 = (x5, y5 - 90)
    t.up()
    t.goto(t13)
    t.down()
    t.goto(t14)

    # 勾
    x6 = x5
    y6 = y5 - 90
    t15 = (x6 - 12, y6 + 10)
    t.goto(t15)

    # 点、、
    x7 = x6 - 12
    y7 = y5 - 40
    t16 = (x7, y7)
    t17 = (x7 - 8, y7 - 20)
    t.up()
    t.goto(t16)
    t.down()
    t.goto(t17)
    t18 = (x7 + 24, y7 - 5)
    t19 = (x7 + 30, y7 - 16)
    t.up()
    t.goto(t18)
    t.down()
    t.goto(t19)

    # 撇
    x8 = x + 100
    y8 = y - 10
    t20 = (x8, y8)
    t21 = (x8 - 32, y8 - 20)
    t.up()
    t.goto(t20)
    t.down()
    t.goto(t21)

    # 撇
    t22 = (x8 - 40, y8 - 135)
    t.goto(t22)

    # 横
    x9 = x3 + 100
    y9 = y3 - 8
    t23 = (x9, y9)
    t24 = (x9 + 50, y9)
    t.up()
    t.goto(t23)
    t.down()
    t.goto(t24)

    # 竖
    x10 = x9 + 24
    y10 = y9
    t25 = (x10, y10)
    t26 = (x10, y10 - 80)
    t.up()
    t.goto(t25)
    t.down()
    t.goto(t26)
    nian()
    kuai()
    le()
    t.done()
예제 #32
0
# program0611.py
'''绘制图案为紫色正方形螺旋'''
import turtle

turtle.setup(400, 360)
turtle.pensize(2)  # 设置画笔宽度为1像素
turtle.pencolor("purple")  # 设置画笔颜色为紫色
turtle.shape("turtle")  # 设置画笔形状为“海龟”
turtle.speed(10)  # 设置绘图速度为10
a = 5  # 起始移动长度a为5单位
for i in range(40):  # 循环40次
    a = a + 6  # 移动长度a每次增加6单位
    turtle.left(90)  # 画笔每次移动旋转90度
    turtle.fd(a)  # 画笔向前移动a单位
turtle.hideturtle()  # 隐藏画笔
turtle.done()  # 结束绘制
예제 #33
0
    global old_x, old_y
    
    move(x-old_x, old_y-y)
    
    old_x = x
    old_y = y

t.onclick(on_click)
t.ondrag(on_drag)

# --- example ---

# draw something 

for a in range(8):
    for _ in range(8):
        t.left(45)
        t.fd(20)
    t.right(45)
    t.up()
    t.fd(60)
    t.down()

# move

move(300, 50)

# ---

turtle.done() # `turtle`, not `t`
예제 #34
0
def writeText(s, x, y):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.write(s)
    turtle.done()
예제 #35
0
    triangle(100)
    t.left(150)

    t.forward(20)
    t.right(150)
    triangle(80)
    t.left(150)

    t.forward(20)
    t.right(150)
    triangle(60)
    t.left(150)

    t.forward(20)
    t.right(150)
    triangle(40)
    t.left(150)

    t.penup()
    t.backward(190)
    t.pendown()


pine()

# =============
# 你的代码结束,以下的代码勿动

t.hideturtle()  # 隐藏海龟
turtle.done()  # 海龟作图完成,等待欣赏
예제 #36
0
#turtle is graphics module
import turtle  #import
"""
turtle.speed(666)
turtle.color(0,0,0)			#color that is used to draw
wn = turtle.Screen()		#defining the screen
wn.bgcolor("light green")	#color of the output window
wn.title("Turtle")			#title of output window
while True:
	turtle.left(185.5)		#rotates aticlockwise
	turtle.forward(200)		#the movement of the pen
"""
"""
#hexagon 
polygon = turtle.Turtle() 

num_sides = 6
side_length = 70
angle = 360.0 / num_sides 

for i in range(num_sides): 
	polygon.forward(side_length) 
	polygon.right(angle) 
	
turtle.done() 
"""
"""
#star
star = turtle.Turtle() 

for i in range(50): 
예제 #37
0
from turtle import fd, rt, done

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

done()
예제 #38
0
                'D':np.array([3]*4,dtype='int32')                             


# In[9]:


## drawing a square
import turtle as tt
a1=tt.Turtle()
a1.forward(150)
a1.right(90)

a1.forward(150)
a1.right(90)


a1.forward(150)
a1.right(90)

a1.forward(150)
a1.right(90)

tt.done()


# In[ ]:




예제 #39
0
def main():
    charlie = turtle.Turtle(shape="turtle")
    charlie.pensize(5)
    charlie.color("red")
    draw_spiral(charlie, 10)
    turtle.done()
예제 #40
0
import turtle

wn = turtle.Screen()
wn.bgcolor("light green")
wn.title("Turtle")
t = turtle.Turtle()

t.forward(100)  #moved skk 100 pixels forward

#kotak
for i in range(4):
    t.forward(50)
    t.right(90)

#bintang
for i in range(5):
    t.forward(50)
    t.right(144)

#ploygon
num_sides = 6
side_length = 70
angle = 360.0 / num_sides

for i in range(num_sides):
    t.forward(side_length)
    t.right(angle)

turtle.done()  #the done() function and We’re done!
예제 #41
0
파일: BYOA.py 프로젝트: brysy/BYOA-Bryan-P3
def scene1b():
    write("When you walk past him the Crabman\n reaches over with his razor sharp claws\n and snips your head off.", "black", 50, 5000, 5000)
    write("END", "black", 100, 5000, 3000)
    turtle.done()
예제 #42
0
import turtle

my_turtle = turtle.Turtle()

def square():
    my_turtle.forward(100)
    my_turtle.left(90)
    my_turtle.forward(100)
    my_turtle.left(90)
    my_turtle.forward(100)
    my_turtle.left(90)
    my_turtle.forward(100)


square()
my_turtle.forward(150)
square()

turtle.done()



예제 #43
0
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240, 128, 128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
# 尾巴
t.pensize(4)
t.color((255, 155, 192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(70, 20)
t.circle(10, 330)
t.circle(70, 30)
t.done()
def drawSquareScene():
    """
    Helper function to call drawSquare() function.
    """
    drawSquare(100)
    turtle.done()
예제 #45
0
def emailidvalidation(email):
    pattern = '^[a-z0-9][a-z0-9_.]{5,14}[@][a-z0-9]{3,18}[.][a-z]{2,4}$'
    if re.match(pattern, email):
        return True
    return False


print(emailidvalidation('*****@*****.**'))

# In[ ]:

# draw a line backward
import turtle as tt
a1 = tt.Turtle()
tt.backward(100)
tt.done()

# In[3]:

# Draw a square
import turtle as tt
a1 = tt.Turtle()
a1.forward(150)
a1.right(90)
a1.forward(150)
a1.right(90)
a1.forward(150)
a1.right(90)
a1.forward(150)
a1.right(90)
tt.done()
예제 #46
0
import turtle as tu

with open("pi.txt", "r") as f:
    pi = f.read()

lines = 100

tu.mode('logo')
for n in range(lines):
    zahl = int(pi[n])
    rotation = zahl * 36
    tu.setheading(rotation)
    tu.forward(50)

tu.done()
'''
**3.19 (Turtle: draw a line) Write a program that prompts the user to enter two points
        and draw a line to connect the points and displays the coordinates of the points

/**
 * @author BASSAM FARAMAWI
 * @email [email protected]
 * @since 2018
 */
'''
import turtle  # Import turtle module

# Prompt the user to Enter 2 points
x1, y1, x2, y2 = eval(input("Enter tow points: "))

# Draw the line
turtle.penup()
turtle.goto(x1, y1)
turtle.pendown()
turtle.write("(" + str(x1) + ", " + str(y1) + ")")

turtle.goto(x2, y2)
turtle.write("(" + str(x2) + ", " + str(y2) + ")")

turtle.hideturtle()  # Hide the turtle
turtle.done()  # Don't close the turtle graphics window
예제 #48
0
def print_clock(ora, perc, masodperc):
    # kezdőállás, óra legyen középen
    turtle.speed(0)
    turtle.ht()
    turtle.width(5)
    turtle.up()
    turtle.seth(-90)
    turtle.fd(250)
    turtle.seth(0)
    turtle.down()

    # számlap színezés
    turtle.color("#86fc80")
    turtle.begin_fill()
    turtle.circle(250)
    turtle.end_fill()
    turtle.color("#0d83dd")

    for szog in range(0, 360, 6):
        # színek változtatása
        turtle.colormode(255)

        # zöld nő
        if szog in range(0, 60) and szinmix[1] <= 255 - 21:
            szinmix[1] += 21
        # piros csökken
        elif szog in range(60, 120) and szinmix[0] >= 0 + 21:
            szinmix[0] -= 21
        # kék nő
        elif szog in range(120, 180) and szinmix[2] <= 255 - 21:
            szinmix[2] += 21
        # zöld csökken
        elif szog in range(180, 240) and szinmix[1] >= 0 + 21:
            szinmix[1] -= 21
        # piros nő
        elif szog in range(240, 300) and szinmix[0] <= 255 - 21:
            szinmix[0] += 21
        # kék csökken
        elif szog in range(300, 360) and szinmix[2] >= 0 + 21:
            szinmix[2] -= 21

        turtle.color(szinmix)

        # óra, perc strigulák kirajzolása, külső körvonal
        turtle.seth(90 + szog)
        turtle.width(4)
        # óra-strigulák
        if szog % 15 == 0:
            turtle.width(5)
            turtle.fd(20)
            turtle.bk(20)
        # perc-strigulák
        else:
            turtle.fd(10)
            turtle.bk(10)
        turtle.seth(szog)
        turtle.width(5)

        turtle.circle(250, 6)

    # középre helyezés
    turtle.up()
    turtle.setpos(0, 0)
    turtle.down()

    # óramutató
    turtle.width(7)
    turtle.color("#720ddd")
    turtle.seth(90 - ora * 30 - perc * 0.5)
    turtle.fd(120)
    turtle.bk(120)

    # percmutató
    turtle.width(5)
    turtle.color("#0d91dd")
    turtle.seth(90 - perc * 6 - masodperc * 0.1)
    turtle.fd(170)
    turtle.bk(170)

    # másodpercmutató
    turtle.width(3)
    turtle.color("#dd1e0d")
    turtle.seth(90 - masodperc * 6)
    turtle.fd(220)
    turtle.bk(220)

    # középső kör
    turtle.up()
    turtle.seth(-90)
    turtle.fd(10)
    turtle.down()
    turtle.begin_fill()
    turtle.color("#ddbb0d")
    turtle.seth(0)
    turtle.circle(10)
    turtle.end_fill()

    turtle.done()
예제 #49
0
def main():
    d = int(input("Enter the depth of the crosses: "))
    tt.left(90)
    crosses(100, d)
    tt.done()
예제 #50
0
import turtle as tl
a = 0
while a < 4:
    tl.forward(200)
    tl.left(90)
    a += 1
# tl.forward(100)
tl.penup()
tl.goto(100, 100)
tl.pendown()
tl.circle(100)
tl.done()
예제 #51
0
t.pendown()
t.begin_fill()
t.color('green')
t.circle(40, steps=5)
t.end_fill()

t.penup()  # 六边形
t.goto(100, -50)
t.pendown()
t.begin_fill()
t.color('yellow')
t.circle(40, steps=6)
t.end_fill()

t.penup()  # 圆形
t.goto(200, -50)
t.pendown()
t.begin_fill()
t.color('purple')
t.circle(40, extent=360)
# t.down()  # 没用却不报错
t.end_fill()

t.color('black')  # 文字表示颜色
t.penup()
t.goto(-100, 100)
t.pendown()
t.write("Cool Colorful Shapes", font=("Times", 18, "bold"))
t.hideturtle()
t.done()  # 用来停止画笔绘制,但绘图窗口不关闭。
예제 #52
0
파일: pythondraw.py 프로젝트: danisgithub/A
turtle.setup(650, 350, 200,
             200)  #turtle.setup(wight,hight,startx,starty) 设置窗体的大小及位置(左上角位置)
turtle.penup()  #抬起画笔,轨迹不在画布上出现
turtle.fd(-250)  #海龟坐标体系,向海龟前方行进,后退250但朝向不变 运动控制函数
turtle.pendown()  #画笔落下,海龟爬行,以下轨迹开始出现
turtle.pensize(25)  #画笔宽度
turtle.pencolor('purple')
turtle.seth(-40)
for i in range(4):  #i 表示循环的次数 取值为0 , i-1 range()产生循环计数序列
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
turtle.circle(40, 80 / 2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2 / 3)
turtle.done()  #程序运行完后不退出,去掉即自动退出

#turtle.goto(x,y) 绝对坐标体系
#turtle.fd(d)
#turtle.bk(d)
#turtle.circle(r,extent)#根据半径r绘制exent角度的弧形 默认圆心在海龟(朝向)左侧r距离的位置上,负数为右侧,如无extent则画圆
#turtle.seth(angle)  绝对角度0/360,90,180,270)只改变方向,不行进 将海龟当前的方向改为某一绝对的角度
#turtle.left(angle) 海龟角度 当前朝向转
#turtle.right(angle)
#turtle.colormode(mode) 1.0/255
#turtle.pencolor('color')/(255,255,255)
#range(n)产生0到n-1的整数序列,共n个
#range(m,n)产生m到n-1的整数序列,共n-m个
'''from<库名>import<函数名>
from<库名>import* #之后直接调用库中的函数'''
'''from turtle import*
예제 #53
0
import turtle as tu
import random
my_turtle = tu.Turtle()
my_turtle.screen.bgcolor('red')
my_turtle.left(90)
my_turtle.speed(20)
my_turtle.color('green')
my_turtle.pensize(5)
#my_turtle.screen.title("My Fractal Tree")

def draw_fractal(blen):
     
    # add these two lines
    sfcolor = ["white", "blue", "purple", "grey", "magenta"]
    my_turtle.color(random.choice(sfcolor))

    if(blen<10):
        return
    else:

        my_turtle.forward(blen)
        my_turtle.left(30)
        draw_fractal(3*blen/4)
        my_turtle.right(60)
        draw_fractal(3*blen/4)
        my_turtle.left(30)
        my_turtle.backward(blen)

draw_fractal(80)
my_turtle = tu.done()
예제 #54
0
파일: BYOA.py 프로젝트: brysy/BYOA-Bryan-P3
def main():
    startUpScreen()

    wn.onscreenclick(cyoa)
    turtle.done()
예제 #55
0
    sleep(1)
    t.right(45)

    sleep(1)
    t.forward(150)
    sleep(1)
    t.right(135)

    sleep(1)
    t.forward(150)
    sleep(1)
    t.right(45)

    sleep(1)
    t.forward(150)
    sleep(1)

    t.end_fill()


# Здесь новая команда leaf закончилась.
# Закончили ставить <Tab>

# Тут место для выполнения старых и новых команд.

# выполняем команды. Пишем БЕЗ пробелов и <Tab>
leaf()  # вызвали (использовали) функцию leaf (выполнили все ее команды)
#t.seth(90)
leaf()  # вызвали функцию leaf (выполнили все ее команды)
turtle.done()  # чтобы окно не закрывалось, на repl.it не нужно
예제 #56
0
def tur():
    turtle.shape("turtle")
    turtle.color("skyblue")
    turtle.write("CONNECT THE PYTHONISTAS", font=("궁서체", 18, "bold"))
    turtle.done()
'''
Created on Jul 1, 2018
@author: Burkhard A. Meier
'''





# module imports
import turtle


turtle.Turtle()         # create a turtle instance

turtle.done()           # keep the window up














예제 #58
0
import colorsys
import turtle

tata = turtle.Turtle()  #Faz a instancia da classe turtle
tata.hideturtle()  #Esconde p cursor
tata.shape("turtle")
tata.speed("fastest")
cont = 0
num = 150
num2 = 3
while (cont < 150):
    print("Cont ", cont)
    print("num ", num)
    print("num2 ", num2)
    tata.circle(num)  #desenha um circulo de 50px
    tata.up()  #Levanta a caneta do turtle, pra nao deixar o rastro do cursor
    tata.setposition(0, num2)  #posiciona o circulo dentro do outro circulo
    tata.down()  #desce a caneta do turtle, para voltar a desenhar
    cont += 1
    num -= 3
    num2 += 3
turtle.done()  #O cursor turtle para.
예제 #59
0
import turtle as tr


tr.forward(30)
tr.lt(90)
tr.forward(30)
tr.lt(90)
tr.forward(30)
tr.lt(90)
tr.forward(30)
tr.done()
예제 #60
0
def aguarda():
  turtle.done()