def drawBoard():
    global b
    #actually draw the board :D
    turtle.ht()
    turtle.width(5)
    turtle.up()
    turtle.goto(-3*b/2.0,b/2.0)
    turtle.down()
    turtle.seth(0)
    turtle.forward(3*b)
    turtle.up()
    turtle.goto(-3*b/2.0,-b/2.0)
    turtle.down()
    turtle.seth(0)
    turtle.forward(3*b)
    turtle.up()
    turtle.goto(-b/2.0,3*b/2.0)
    turtle.down()
    turtle.seth(270)
    turtle.forward(3*b)
    turtle.up()
    turtle.goto(b/2.0,3*b/2.0)
    turtle.down()
    turtle.seth(270)
    turtle.forward(3*b)
Esempio n. 2
0
def ejes():
    ####################################
    # Ejes Coordenados                 #
    # los ejes x e y van de -150 a 150 #
    ####################################
    turtle.delay(0)
    turtle.ht()
    turtle.speed(0)
    turtle.pencolor('red')
    turtle.down()
    turtle.fd(301)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.lt(90)
    turtle.fd(300)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.lt(90)
    turtle.fd(300)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.lt(90)
    turtle.fd(300)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.up()
    turtle.pencolor('blue')
Esempio n. 3
0
def draw_l(word):
    turtle.up()
    turtle.clear()
    turtle.setposition(0, 0)
    turtle.setheading(0)
    turtle.bk(INITIAL_POS[0])
    turtle.down()
    turtle.st()
    stack = []
    for char in word:
        if char == '0':
            turtle.fd(SIZE[0])
        if char == '1':
            turtle.fd(SIZE[0])
        if char == '[':
            stack.append((turtle.position(), turtle.heading()))
            turtle.lt(45)
        if char == ']':
            position, heading = stack.pop()
            turtle.up()
            turtle.setposition(position)
            turtle.setheading(heading)
            turtle.rt(45)
            turtle.down()
    turtle.ht()
Esempio n. 4
0
def turtle_init():
	turtle.ht()
	turtle.up()
	turtle.speed(0)
	turtle.left(90)
	turtle.backward(350)
	turtle.down()
Esempio n. 5
0
    def display( self, text ):
        """Display the finished graphic until the window is closed.

        Might be better to display until key click or mouse click.
        """
        turtle.title( text )
        turtle.ht()
Esempio n. 6
0
def ttlinit():
    turtle.setup(width=1080, height=540)
    turtle.title("Világtérkép 🌍")
    turtle.delay(0)
    turtle.bgcolor("#8ab5ea")
    turtle.setworldcoordinates(-180, -90, 180, 90)
    turtle.up()
    turtle.ht()
Esempio n. 7
0
def spirale2():
    t.ht()
    t.up()
    t.setposition((0, 0))
    t.down()
    for i in range(90):
        t.circle(i)
        t.right(60)
Esempio n. 8
0
def spirale1():
    t.ht()
    t.up()
    t.setposition((0, 0))
    t.down()
    for i in range(700):
        t.forward(i)
        t.left(91)
Esempio n. 9
0
def main():
    turtle.setup(1000, 600)
    turtle.up()
    turtle.ht()
    turtle.goto(-200, 0)
    turtle.title("七段数码管")
    drawDate(time.strftime("%Y-%m=%d+", time.gmtime()))
    turtle.reset()
Esempio n. 10
0
def make_circle():
    m = 3
    for p in range(120):
        turtle.left(3)
        turtle.forward(m)
        if p > 60:
            turtle.st()
            turtle.shape('turtle')
    turtle.ht()
Esempio n. 11
0
def make_smaller_square():
    ''' This is a test for a document.
that should be used for make_smaller_square'''
    m = 200
    for p in range(22):
        turtle.left(90)
        turtle.forward(m)
        m -= 10
    turtle.ht()
Esempio n. 12
0
 def __init__(self, data):
     self.data = data
     self.t = turtle.Turtle()
     self.t.ht()
     self.t.pu()
     self.t.tracer(0, 0)
     turtle.ht()
     self.t.speed(0)
     turtle.onscreenclick(on_click)
Esempio n. 13
0
def drawEdge(e):
    turtle.st()
    ((sx, sy), (ex, ey)) = e
    turtle.goto(sx * 300, sy * 300)
    turtle.pendown()
    turtle.goto(ex * 300, ey * 300)
    turtle.dot()
    turtle.penup()
    turtle.ht()
Esempio n. 14
0
def ready(rad):
    turtle.speed(0)
    turtle.ht()
    turtle.up()
    turtle.goto(0,-rad)
    turtle.down()
    turtle.colormode(1)
    turtle.bgcolor('black')
    turtle.pensize(1.1)
Esempio n. 15
0
def init_turtle():
    turtle.ht()
    turtle.up()
    turtle.speed(0)
    turtle.setpos(-500, -300)
    turtle.left(60)
    turtle.colormode(255)
    turtle.pencolor((150, 150, 0))
    turtle.down()
Esempio n. 16
0
def drawHomeWindow():
    turtle.setup(width=510, height=510) #Opens up a 510x510 pixel window.
    turtle.ht()
    turtle.clear()
    turtle.penup()
    turtle.color("red")
    turtle.goto(0,200) #Draws welcome text on screen
    turtle.write("Welcome! Click to begin...", align="center", font=(None, 25, "normal"))
    turtle.title("Ben Stones - Snake Game")
Esempio n. 17
0
def f(degree):
    t.clear()
    t.reset()
    t.speed(1000)
    t.ht()
    t.pensize(1)
    t.color('black')
    t.seth(degree)
    t.fd(250)
def main():
    t.setup(800, 400)
    t.speed(0)
    t.up()
    t.goto(-300, -50)
    t.down()
    t.pensize(2)
    koch(600, 3)
    t.ht()
Esempio n. 19
0
def ready(rad):
    turtle.speed(0)
    turtle.ht()
    turtle.up()
    turtle.goto(0, -rad)
    turtle.down()
    turtle.colormode(1)
    turtle.bgcolor('black')
    turtle.pensize(1.1)
Esempio n. 20
0
def chess_board(li):

    turtle.tracer(0, 0)
    WIDTH = 40
    turtle.st()
    turtle.pu()
    turtle.goto(-len(li) / 2 * WIDTH, len(li) / 2 * WIDTH)
    turtle.pd()
    turtle.setup(width=len(li) * WIDTH + WIDTH, height=len(li) * WIDTH + WIDTH)
    turtle.title("Solving N-Queen...")

    def square(coloring):
        if coloring:
            turtle.begin_fill()
            for h in range(4):
                turtle.fd(WIDTH)
                turtle.rt(90)
            turtle.end_fill()
        else:
            for k in range(4):
                turtle.fd(WIDTH)
                turtle.rt(90)

    for i in range(1, len(li) + 1):
        for j in range(1, len(li) + 1):
            if ((i + j) % 2 == 0) or (i % 2 != 0 and j % 2 != 0):
                square(True)
                turtle.fd(WIDTH)
            else:
                square(False)
                turtle.fd(WIDTH)
        turtle.pu()
        turtle.goto(-len(li) / 2 * WIDTH, -WIDTH * i + len(li) / 2 * WIDTH)
        turtle.pd()
    turtle.pu()
    turtle.ht()

    for item in enumerate(li, 1):
        if item[0] <= len(li) / 2 and item[1] <= len(li) / 2:
            turtle.goto(-WIDTH * (len(li) / 2 + 1 - item[0]) + WIDTH / 2,
                        WIDTH * (len(li) / 2 + 1 - item[1]) - WIDTH / 2)
            turtle.dot(WIDTH / 2, 'red')
        if item[1] <= len(li) / 2 < item[0]:
            turtle.goto(WIDTH * (item[0] - len(li) / 2) - WIDTH / 2,
                        WIDTH * (len(li) / 2 + 1 - item[1]) - WIDTH / 2)
            turtle.dot(WIDTH / 2, 'red')
        if item[0] <= len(li) / 2 < item[1]:
            turtle.goto(-WIDTH * (len(li) / 2 + 1 - item[0]) + WIDTH / 2,
                        -WIDTH * (item[1] - len(li) / 2) + WIDTH / 2)
            turtle.dot(WIDTH / 2, 'red')
        if item[0] > len(li) / 2 and item[1] > len(li) / 2:
            turtle.goto(WIDTH * (item[0] - len(li) / 2) - WIDTH / 2,
                        -WIDTH * (item[1] - len(li) / 2) + WIDTH / 2)
            turtle.dot(WIDTH / 2, 'red')

    turtle.mainloop()
Esempio n. 21
0
def init():
    """
    Initialize the turtle window
    :return: None
    """
    t.ht()
    t.up()
    t.setup(200, 200)
    t.setpos(0, 60)
    t.title("Font Options")
Esempio n. 22
0
def draw(s):
    turtle.speed(0)
    turtle.ht()
    for i in s:
        if i=='F':
            turtle.forward(10)
        elif i=='+':
            turtle.left(90)
        elif i=='-':
            turtle.right(90)
Esempio n. 23
0
def Setup():
    t.ht()  # Hide the turtle
    t.speed(0)
    t.tracer(0, 0)
    t.up()
    t.screensize(500, 500)
    t.bgcolor("black")
    t.color("white")
    t.setworldcoordinates(-50, -50, 450, 450)
    t.update()
def choose_items():
    item = str(
        screen.textinput('Welcome to the house',
                         "What item would you like to swap?"))
    check_item(item)
    item = str(
        screen.textinput('Choose more items, write no if you finished already',
                         "What item would you like to swap?"))
    check_item(item)
    turtle.ht()
Esempio n. 25
0
def writeTxt(size, txt):
    t.clear()
    left = 0 - size / 2
    top = 0 - size / 2
    t.up()
    t.goto(left, top)
    t.down()
    t.pencolor('red')
    t.write(txt, font=('Times New Roman', size, ''))
    turtle.ht()
Esempio n. 26
0
def update(x, y):
    turtle.clear()
    turtle.tracer(0, 0)
    turtle.ht()
    for bound in bounds:
        bound.show()
    particle.goto(x, y)
    particle.look(bounds)
    particle.show()
    turtle.update()
Esempio n. 27
0
def main():
    t.speed(20)
    t.shapesize(1000, 1000)
    t.up()
    t.goto(1000, 0)
    t.ht()
    t.onkey(showTurtle, "a")
    t.listen()
    t.onclick(getPos)
    t.onrelease(hideTurtle)
Esempio n. 28
0
def draw_circle(x: int, y: int, radius: int, color: str):
    turtle.pu()

    turtle.setx(x)
    turtle.sety(y)
    turtle.pd()
    turtle.begin_fill()
    turtle.fillcolor(color)
    turtle.circle(radius)
    turtle.end_fill()
    turtle.ht()
def draw(sol):
    turtle.tracer(None)
    turtle.speed(0)
    turtle.ht()
    turtle.clear()
    turtle.pu()
    turtle.goto(sol.solution[0][0], sol.solution[0][1])
    turtle.pd()
    for x in range(1, len(sol.solution)):
        turtle.goto(sol.solution[x][0], sol.solution[x][1])
    turtle.goto(sol.solution[0][0], sol.solution[0][1])
def rulepopup():
    clearscreen()
    player.ht()
    player.penup()
    rule_changecolor()
    rule_clear()
    rule_movement()
    rule_pendown()
    rule_penlarge()
    rule_clear_rules()
    eraser_rule()
def color_quad(pos_x, pos_y, side, cor):
    turtle.pu()
    turtle.goto(pos_x, pos_y)
    turtle.pd()
    turtle.fillcolor(cor)
    turtle.begin_fill()
    for i in range(4):
        turtle.fd(side)
        turtle.rt(90)
    turtle.end_fill()
    turtle.ht()
Esempio n. 32
0
def despliega_instrucciones():
    turtle.ht()
    turtle.penup()
    turtle.goto(-320, -200)
    turtle.pendown()
    archivo = open("instrucciones.txt", "r")
    cadena = archivo.read()
    turtle.write(cadena,
                 move=False,
                 align="left",
                 font=("Arial", 11, "normal"))
def black_quad(pos_x, pos_y, side):
	turtle.pu()
	turtle.goto(pos_x, pos_y)
	turtle.pd()
	turtle.fillcolor('black')
	turtle.begin_fill()
	for i in range(4):
		turtle.fd(side)
		turtle.rt(90) 
	turtle.end_fill()
	turtle.ht()
Esempio n. 34
0
 def __init__(self, x, y, width, height, dy):
     Turtle.__init__(self)
     self.pu()
     turtle.ht()
     self.goto(x, y)
     self.shape("platform.gif")
     #register shape of the platform and change it
     self.shapesize = 60
     self.width = width
     self.height = height
     self.dy = dy
Esempio n. 35
0
def winner(color, blackCount, whiteCount):
    turtle.ht()
    turtle.pu()
    turtle.goto(4, 4)
    turtle.color('red')
    turtle.write(color, True, align='center', font=('Arial', 100, 'normal'))
    turtle.goto(4, 2)
    turtle.write('Black: ' + blackCount + ' White: ' + whiteCount,
                 True,
                 align='center',
                 font=('Arial', 50, 'normal'))
Esempio n. 36
0
def plot_by_magnitude(picture_size, coordinates_dict, magnitudes_dict):
    turtle.screensize(picture_size, picture_size)
    turtle.ht()
    for i in coordinates_dict:
        turtle.penup()
        turtle.goto(coordinates_dict[i][0] * picture_size / 2,
                    coordinates_dict[i][1] * picture_size / 2)
        star_size = round(10.0 / (magnitudes_dict[i] + 2))
        if star_size > 8:
            star_size = 8
        draw_square(star_size)
Esempio n. 37
0
def trivia(fo, ft):
    def question(person, question, answer, points, turn):
        print("The next question is for ")
        print(person + ".")
        print(question)
        fq = input()
        if (fq == answer):
            print("RIGHT! One point for ")
            print(person)
            WASD(points)
            WASD("d")
            WASD("d")
            WASD(points)
            WASD(turn)
            WASD("wwww")
            WASD(turn)
        else:
            if (turn == "a"):
                turn = "d"
            else:
                turn = "a"
            print("WRONG!")
            WASD(turn)
            WASD("wwww")
            WASD(turn)
            WASD(turn)
            WASD(turn)
            print("The answer is " + answer)

    WASD("d")
    turtle.ht()
    WASD("wwww")
    WASD("w")
    WASD("c")
    WASD("a")
    WASD("wwww")
    WASD("a")
    WASD("a")
    WASD("wwww")
    WASD("wwww")
    WASD("ss")
    WASD("d")
    print("Welcome to trivial persute!")

    question(ft, "2+2", "4", "ww", "a")
    question(fo, "9*3", "27", "ww", "d")
    question(ft, "10*10", "100", "w", "a")
    question(fo, "3**2", "9", "www", "d")
    question(ft, "3x**2 = 27, what is x?", "3", "www", "a")
    question(fo, "25ab/2b**3 * 4b/5a", "10/b", "wwww", "d")
    question(
        ft,
        "sqrt(-1) sqrt(64)  3.141592653589793238462643383279502... ' and it was good.'",
        "i ate pie and it was good.", "wwww", "a")
Esempio n. 38
0
def pintar(x, y):
    ##################################
    # Función para Encender un Pixel #
    ##################################
    turtle.delay(0)
    turtle.speed(0)
    turtle.ht()
    turtle.up()
    turtle.goto(2 * int(x), 2 * int(y))
    turtle.down()
    turtle.fd(0)
    turtle.up()
Esempio n. 39
0
def init_engine(delay=_ENGINEDELAY):
	'''
	(Re)initializes the game engine.  Only one game engine may exist
	at any one time.  The optional parameter specifies a delay added
	to each game time step, in seconds; the value may be a floating
	point number.
	'''
	global _e
	_e = _E(delay)

	turtle.pu()
	turtle.ht()
	turtle.clear()
Esempio n. 40
0
def __main__():
    turtle.ht()
    nodes = []
    while True:
        numberOfNodes = int(raw_input("Number of nodes (Max = 8): "))
        if numberOfNodes > 8 or numberOfNodes <= 1:
            print "The amount of nodes must be a number between 2 and 8."
        else:
            drawCircles(numberOfNodes)
            i = 1
            while i <= numberOfNodes:
                nodes = nodes + ["Q" + str(i)]
                i += 1
            break
    labelNodes(numberOfNodes)
    while True:
        startingNode = str(raw_input("Starting node: "))
        if startingNode in nodes:
            entrance([-400 + 80 * nodes.index(startingNode), 20])
            break
        else:
            print "That node does not exist please choose a node between Q1 and Q" + str(numberOfNodes) + "."
    while True:
        endingNodes = str(
            raw_input("Accepting state (Enter all accepting states put a comma between them ex. Q1,Q3): ")
        )
        endingNodes = endingNodes.split(",")
        valid = True
        for x in endingNodes:
            if x not in nodes:
                valid = False
                break
        if valid == True:
            for x in endingNodes:
                final([-400 + 80 * nodes.index(x), 20])
            break
        else:
            print "One of those nodes does not exist please try again"
    addT = "Jonathan"
    print "Transitions(Enter one transtion then press enter. After the last transition press enter twice. Format (StartingNode,Letter)=EndingNode *No spaces*)"
    while True:
        addT = str(raw_input())
        if addT == "":
            break
        else:
            new = transitions(addT)
            if new[0] in nodes and new[2] in nodes:
                addLine(nodes.index(new[0]), nodes.index(new[2]), new[1])
            else:
                print "Looks like their was an error with your format. Please try again."
    saveImg()
Esempio n. 41
0
def disp(A, cellsize = 1 / 10.5):
    turtle.clear()
    turtle.shape("square")
    turtle.penup()
    turtle.speed(0)
    turtle.shapesize(0.5, 0.5, 1)
    turtle.ht()
    top = len(A) / cellsize
    left = -len(A[0]) / cellsize
    for r in range(len(A)):
        for c in range(len(A[r])):
            if A[r][c]: 
                turtle.goto(c * 10.5 + left, top - r * 10.5)
                turtle.stamp()
Esempio n. 42
0
	def hold(self):
		""" holds the screen open until the user clicks or types 'q' """
	
		# have the turtle listen for events
		turtle.listen()

		# hide the turtle and update the screen
		turtle.ht()
		turtle.update()

		# have the turtle listen for 'q'
		turtle.onkey( turtle.bye, 'q' )
		# have the turtle listen for a click
		turtle.onscreenclick( lambda x,y: turtle.bye() )

		# start the main loop until an event happens, then exit
		turtle.mainloop()
		exit()
Esempio n. 43
0
def Sierpinsmod(size,mod,alto=1024,ancho=700,dx=4):
    r=1.0*dx  
    pp=dx  # Grueso de los puntos
    turtle.colormode(1)
    turtle.ht()
   
    turtle.speed("fastest")
    turtle.tracer(False)
    turtle.penup()
    turtle.home()
    ox = -(turtle.window_width()/2)+2*dx
    oy = (turtle.window_height()/2)-2*dx
 
    P=Pascal(size,mod)

    turtle.setpos(ox,oy)
   
    turtle.dot(pp,clr(P[0][0],mod))
    turtle.seth(90)
   
    for d in range(1,2*size-1):
        print("iniciando diagonal ",d),
        if d< size:
            initx=0  # Posiciones iniciales
            inity=d
        else:
            initx = d-size+1
            inity = size-1
       
        turtle.setpos(ox+initx*dx-dx,oy-inity*dx-dx)
 
        for k in range(initx,inity+1):  
            # Recorremos la diagonal de suma d
            # Los puntos corresponden a (k, d-k)
            turtle.right(90)
            turtle.forward(dx)
            turtle.left(90)
            turtle.forward(dx)
            t=P[k][d-k]
            if t > 0:
                turtle.dot(pp, clr(t,mod))
        if d % 20 ==0: turtle.update()        
Esempio n. 44
0
    def illustrate(self, color="red"):

        # if the tree is empty, exit program
        if self.is_empty():
            print("Empty")
            return

        # set turtle settings
        turtle.ht()
        turtle.pu()
        turtle.speed(0)

        # move turtle to near top of string
        turtle.goto(0, 250)

        # set color of the numbers on the nodes
        self.color = color

        # begin drawing the tree
        self.help_illustrate(self.root, turtle)
Esempio n. 45
0
 def drawFrame(self, i, j, colour=None):
     if colour is not None:
         turtle.color("red")
     else:
         turtle.color("black")
     turtle.ht()
     turtle.up()
     turtle.tracer(10000,0)
     x = self.index_to_pixel(i, "x")
     y = self.index_to_pixel(j, "y")
     print("going to " + str(x) + " " + str(y))
     turtle.setx(x)
     turtle.sety(y)
     turtle.down()
     turtle.forward(self.xside_box)
     turtle.left(90)
     turtle.forward(self.yside_box)
     turtle.left(90)
     turtle.forward(self.xside_box)
     turtle.left(90)
     turtle.forward(self.yside_box)
     turtle.left(90)
     turtle.update()
Esempio n. 46
0
# from here http://cs.calvin.edu/courses/cs/106/labs/cs106lab7.html & https://docs.python.org/2/library/turtle.html

import turtle
import math

# setup
turtle.Screen()
turtle.screensize(500,500)
turtle.ht() # make turtle invisible
turtle.pensize(2)

while True:

	answer = raw_input("would you like to draw a spirograph? y/n ")

	if answer == "y":
		# get user input
		r = float(raw_input("what radius do you want for the moving circle? "))  # classic = x
		R = float(raw_input("what radius do you want for the overall circle? ")) # classic = x - 10
		p = float(raw_input("offset of pen from moving circle ")) # classic = x/2
		color = raw_input("what pen color do you want? (in terms of color string) ")

		t = 0.0
		turtle.penup()
		turtle.pencolor(color)
		turtle.fillcolor(color)

		turtle.goto(0,-300)
		turtle.write("parameters: %g, %g, %g" % (r, R, p), True, align="center", font=("Arial", 10, "normal"))

		while t < 50.0:
Esempio n. 47
0
	d = l / 3
	vk(d, n - 1)
	t.left(60)
	vk(d, n - 1)
	t.right(120)
	vk(d, n - 1)
	t.left(60)
	vk(d, n - 1)

def f(l, n):
	t.up()
	t.goto( - l / 2, l / 3 )
	t.down()
	for i in rang(3):
		vk(l, n)
		t.right(120)

f(300, 6)

"""

from tkinter import *
import os

t.ht()
ts = t.getscreen()
ts.getcanvas().postscript(file="{0}.eps".format("van_koch"))
t.mainloop()

"""
Esempio n. 48
0
    def __init__(self, filename=None):   #, root=None):
        self.root = root = turtle._root = Tk()
        root.wm_protocol("WM_DELETE_WINDOW", self._destroy)
        root.resizable(width=FALSE, height=FALSE)

        #################
        self.mBar = Frame(root, relief=RAISED, borderwidth=2)
        self.mBar.pack(fill=X)

        root.title('PonyGE GUI')
        #################
        self.left_frame = left_frame = Frame(root)
        self.text_frame = text_frame = Frame(left_frame)
        self.vbar = vbar =Scrollbar(text_frame, name='vbar')
        self.text = text = Text(text_frame,
                                name='text', padx=5, wrap='none',
                                width=45)
        vbar['command'] = text.yview
        vbar.pack(side=LEFT, fill=Y)
        #####################
        self.hbar = hbar =Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)
        hbar['command'] = text.xview
        hbar.pack(side=BOTTOM, fill=X)
        #####################
        text['yscrollcommand'] = vbar.set
        text.config(font=txtfont)
        text.config(xscrollcommand=hbar.set)
        text.pack(side=LEFT, fill=Y, expand=1)
        #####################
        self.output_lbl = Label(left_frame, height= 1,text=" --- ", bg = "#ddf",
                                font = ("Arial", 16, 'normal'))
        self.output_lbl.pack(side=BOTTOM, expand=0, fill=X)
        #####################
        text_frame.pack(side=LEFT, fill=BOTH, expand=0)
        left_frame.pack(side=LEFT, fill=BOTH, expand=0)
        self.graph_frame = g_frame = Frame(root)

        turtle._Screen._root = g_frame
        turtle._Screen._canvas = turtle.ScrolledCanvas(g_frame, 700, 700, 700, 700)
        #xturtle.Screen._canvas.pack(expand=1, fill="both")
        self.screen = _s_ = turtle.Screen()
#####
        turtle.TurtleScreen.__init__(_s_, _s_._canvas)
#####
        self.scanvas = _s_._canvas
        #xturtle.RawTurtle.canvases = [self.scanvas]
        turtle.RawTurtle.screens = [_s_]

        turtle.ht()

        self.scanvas.pack(side=TOP, fill=BOTH, expand=1)

        self.btn_frame = btn_frame = Frame(g_frame, height=100)
        self.next_btn = Button(btn_frame, text=" NEXT ", font=btnfont, fg = "white",
                                disabledforeground = "#fed", command=self.nextGeneration)
        self.next_btn.pack(side=LEFT, fill=X, expand=1)
        self.save_btn = Button(btn_frame, text=" SAVE ", font=btnfont, fg = "white",
                                disabledforeground = "#fed", command=self.savecb)
        self.save_btn.pack(side=LEFT, fill=X, expand=1)
        self.redisplay_btn = Button(btn_frame, text=" REDISPLAY ", font=btnfont, fg = "white",
                                disabledforeground = "#fed", command=self.redisplaycb)
        self.redisplay_btn.pack(side=LEFT, fill=X, expand=1)
        self.stop_btn = Button(btn_frame, text=" STOP ",  font=btnfont, fg = "white",
                                disabledforeground = "#fed", command = self.stopIt)
        self.stop_btn.pack(side=LEFT, fill=X, expand=1)

        self.btn_frame.pack(side=TOP, fill=BOTH, expand=0)
        self.graph_frame.pack(side=TOP, fill=BOTH, expand=1)

        # Grid size, giving population
        self.n = 3
        self.m = 3
        # Set up PonyGE
        self.ge = GE(GRAMMAR_FILE)
        self.fitness = [0.0 for i in range(self.n) for j in range(self.m)]

        Percolator(text).insertfilter(ColorDelegator())
        self.dirty = False
        self.exitflag = False
        self.configGUI(NORMAL, DISABLED, DISABLED, DISABLED, DISABLED, DISABLED, INSTRUCTIONS)

        # bring the window to front
        root.attributes('-topmost', 1)
        root.attributes('-topmost', 0)
        # none of these succeeds in bringing to front
        # root.lift()
        # root.tkraise()
        # none of these succeeds in focussing
        # root.focus()
        # root.focus_force()
        # self.next_btn.focus_force()

        self.state = STARTUP
        self.nextGeneration()
Esempio n. 49
0
	# comment these two lines out for other examples
	myPile = googleMatrix()
	frame = googleMatrix()
	# Other examples
	# myPile = makePileMatrix(15,15)

	# the following line generates random values for the pile
	# myPile = RandomizePile(myPile)

	# the loop creates a line of grains 20 high across the center of the matrix
	# for i in range(0,15):
	# 	myPile[7][i]=20

	# this puts a pile 80 grains high at the center of the matrix
	# myPile[7][7] = 80
	# setScreen(myPile)
	# drawPile(myPile)
	# update()
	count = 1
	while (isStable(myPile) == False):
			# switch the comment status of the next two lines when
			# not working with the googleMatrix() function
		myPile = fullStepSandpileNoWhite(myPile,frame)
		# myPile = fullStepSandpile(myPile)
		drawPile(myPile)
		update()
		print(count)
		count+=1
	ht()
	done()
	# printMatrix(myPile)
Esempio n. 50
0
def visualSim(width, xlist, ylist, attempts, distObj):
    """ Sets up screen for visual simulation of projectile motion
        Parameters:
           width: the distance to the landing zone (black area)
           xlist: the list of x-values from the traj function
           ylist: the list of y-values from the traj function
           attempts: indicates which attempt the game is on
           distObj: the object distance if on level 5; otherwise, false
           score: the current score possible
        Return value: none
    """
    import turtle
    turtle = turtle.Turtle()
    screen = turtle.getscreen()
    turtle.ht()
    screen.setworldcoordinates(-10, -10, width + 15, 1000) #sets edges of screen
    turtle.up()
    turtle.setposition(-10, 0) #drawing of ground
    turtle.down()
    turtle.pensize(5)
    turtle.pencolor("green")
    turtle.setposition(width,0)
    turtle.pencolor("black")
    turtle.setposition(width+15,0)
    turtle.up()

    #draws the object
    if distObj != False:
        turtle.pencolor("blue")
        turtle.setposition(distObj,0)
        turtle.down()
        turtle.setposition(distObj, 400)
        turtle.setposition(distObj+5,400)
        turtle.setposition(distObj+5,0)
        turtle.up()

    turtle.pensize(1)
    turtle.setposition(0,0) #drawing of trajectory begins here
    turtle.shape("circle")
    turtle.down()
    
    if attempts == 5: #changes color of path depending on which attempt it is...purely aesthetic
        turtle.pencolor("blue")
    elif attempts == 4:
        turtle.pencolor("orange")
    elif attempts == 3:
        turtle.pencolor("yellow")
    elif attempts == 2:
        turtle.pencolor("purple")
    else:
        turtle.pencolor("red")
    turtle.showturtle()

    #draws the trajectory with a turtle object; stops if the turtle goes off of the screen to the left or right
    for position in range(len(xlist)):
        turtle.setposition(xlist[position], ylist[position])
        if xlist[position] > width + 15 or xlist[position] < 0: #line that stops an offscreen turtle
            turtle.hideturtle()
            break       
    time.sleep(1.5)
    screen.bye()
Esempio n. 51
0
	drawTrunk("brown",90, -225)
	drawTriangle("green", 225, -50)
	drawTriangle("green", 190, 25)
	drawTriangle("green", 150, 75)
	drawBall("red", 20, 225, -50)
	drawBall("blue", 20, 190, 25)
	drawBall("pink", 20, 150, 75)
	drawStar("yellow", 90, 75)

	drawStars(100, 300, "white")
	drawStars(150, 279, "white")
	drawStars(200, 310, "white")
	drawStars(250, 280, "white")
	drawStars(300, 260, "white")
	drawStars(100, 350, "white")
	drawStars(350, 230, "white")
	

t.title("A Tree!")
t.speed(0)
t.ht()
t.up()
t.goto (0,-350)
t.color("red")
t.write("Merry Christmas From CS105!", True, align="center", font=("Arial", 24, "bold"))
drawpicture()
t.goto (0,-375)
t.color("white")
t.write("By: Tyler Wittreich, Casey Blair, Ryan Hillstead", True, align="center", font=("Arial", 16, "normal"))
t.exitonclick()
def drawNodes(treeMin, eventDict, depth, nodeDict):
    """Takes as input
        treeMin   - a list of the starting nodes of the best reconciliations
        eventDict - the DTL format dictionary
        depth     - a starting y-coordinate
        nodeDict  - a dictionary of nodes and their coordinates.
    This function recursively draws the nodes of the DTL format dictionary, then
    connects them using the connect function aboves"""
    numTips = 0
    for key in eventDict.keys():
        if eventDict[key][0][0] == "C":
            numTips+=1
    width = numTips * 200
    DISPLACE = width/2
    dip = 15
    if len(eventDict)<25:
        radius = 30
    else:
        radius = 13
        dip = 15
        width = width/2
        DISPLACE = DISPLACE/2
    if treeMin == []:
        for key in nodeDict:
            for item in range(len(nodeDict[key][1:])):
                connect(turtle.Turtle(), nodeDict[key][0], nodeDict[key][item+1], radius)
                for thing in eventDict[key][item][1:-1]:
                    if thing !=(None, None):
                        connect(turtle.Turtle(), nodeDict[key][item+1], nodeDict[thing][0], radius)
        return

    difference = ((len(eventDict))*2)/numTips

    numSols = len(treeMin)
    turtle.speed(0)
    turtle.pen(pencolor = "black")
    eventList = []
    newtreeMin = []
    for x in range(len(treeMin)):
        if not treeMin[x] in nodeDict:
            nodeDict[treeMin[x]] = [((x+1)*width/(numSols + 1)-DISPLACE, depth + radius)]
            turtle.penup()
            turtle.setpos((x+1)*width/(numSols+1)-DISPLACE, depth)
            turtle.pendown()
            turtle.circle(radius)
            turtle.left(130)
            turtle.penup()
            turtle.forward(radius)
            turtle.pendown()
            turtle.right(130)
            turtle.write(treeMin[x], font = ("arial", 12, "normal"))
            for y in eventDict[treeMin[x]]:
                if type(y)== list:
                    eventList.append((y[0], treeMin[x]))
                    if y[1] !=(None, None) and not y[1] in newtreeMin:
                        newtreeMin.append(y[1])
                    if y[2] !=(None, None) and not y[2] in newtreeMin:
                        newtreeMin.append(y[2])
    numEvents = len(eventList)
    for event in range(len(eventList)):
        turtle.penup()
        nodeDict[eventList[event][1]].append(((event+1)*width/(numEvents+1)-DISPLACE, depth -(difference-radius)))
        turtle.setpos(((event+1)*width/(numEvents+1))-DISPLACE, depth - difference)
        turtle.pendown()
        turtle.circle(radius)
        turtle.left(95)
        turtle.penup()
        turtle.forward(radius)
        turtle.pendown()
        turtle.right(95)
        turtle.write(eventList[event][0], font = ("arial", 12, "normal"))
        turtle.ht()
    drawNodes(newtreeMin, eventDict, depth - 2*difference, nodeDict)
Esempio n. 53
0
    turtle.pu()
    turtle.setpos(x, y)
    turtle.pd()




'''
   Function: randomColor
Description: This function returns a random color from a predefined list.
'''
def randomColor():
    return random.choice(['red', 'orange', 'yellow', 'green', 'blue', 'violet'])


#================================================================================
#                                START OF MAIN
#================================================================================

turtle.speed(0) # Speed the computation time up significantly, way to slow to draw 
                # otherwise
turtle.clear()
turtle.home()

turtle.bgcolor("black") # Makes the colors really stand out
turtle.ht() # Hide the turtle, makes the program run a little faster


position(-300,0)

rowOfShapes(8)
Esempio n. 54
0
#!/usr/bin/env python
# -*- coding : Utf-8 -*-

import turtle as ttl
import random as rd

# Initialisations
ttl.ht()
ln_lig = 20
ln_s = 15
nbl = 20
la = 45

# Point zéro
for ll in range(nbl):
    ttl.pen(speed = 5)
    ttl.up()
    ttl.goto(0, 0)
    ttl.down()
    angles = [rd.random() * 2 * la - la for x in range(ln_lig)]
    ttl.color([0, 0, 0])
    for n in range(ln_lig):
        ttl.left(angles[n])
        ttl.forward(ln_s)
    ttl.color([1, 0, 0])
    ttl.pen(speed = 0)
    ttl.begin_fill(); ttl.circle(ln_s / 4); ttl.end_fill()
    
# Fin
ttl.mainloop()
Esempio n. 55
0
def init_turtle():
    turtle.ht()
    turtle.up()
    turtle.speed(0)
    turtle.setpos(-500, 0)
    turtle.down()
Esempio n. 56
0
def stamp(x,y):
    turtle.ht()
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()
    turtle.stamp()
Esempio n. 57
0
        kochLine(depth-1, distance/3)
        turtle.rt(60)
        kochLine(depth-1, distance/3)
        turtle.lt(120)
        kochLine(depth-1, distance/3)
        turtle.rt(60)
        kochLine(depth-1, distance/3)

def koch(depth, distance):
    for x in range(3):
        kochLine(depth, distance)
        turtle.lt(120)



distance = 400.0
depth = 5

turtle.speed(0) #0 = fastest
turtle.ht()     #hideturtle
turtle.penup()
turtle.setx(-distance/2)
turtle.sety(-distance * math.sqrt(3) / 4)   #1/2 way up triangle
turtle.pendown()
turtle.colormode(255)

#koch(depth, distance)

colorRef = ColorReference(depth)
sherp(depth, distance, colorRef)
Esempio n. 58
0
def f(length, depth, anti):
    if depth == 0:
        t.pd()          # pendown
        t.fd(length)    # forward
        t.pu()          # penup
        return

    for angle in [60, -120, 60, 0]:
        f(length/3, depth-1, anti)
        t.lt(angle * anti)


# main
t.reset()
t.speed(0)          # fast++
t.ht()              # hideturtle
t.pu()              # penup
screen = t.getscreen()
screen.bgcolor("black")
sleep(1)

for i in range(n):
    screen.tracer(49152, 0) # i
    # a b/w version
    cl = float(i+2) / float(n+2)
    t.color((cl, cl, cl))

    t.fill(True)        # 
    snowflake(sz, 5, 1) # i+2
    sz = sz - (sz / 8)  #
    t.fill(False)       #
Esempio n. 59
0
import turtle
turtle.ht()
turtle.speed(0)
print("welcome to the paint progaram,")
print("when you will click on the screen, a shape will appear.")
print("to change the shape press on --->")
print("Up - Circle, Down - Square, Left - Triangle, Right - Turtle.")
print("to change the color of the shape press on --->")
print("B - Blue, R - Red, G - Green, Y - Yellow, O - Orange, S - Black, W - White (eraser).")
print("to change the size of the shape press on --->")
print("size 1 - 1, size 2 - 2, size 3 - 3, size 4 - 4, size 5 - 5.")
print("to clear the screen press - C.")
print("ENJOY!")

def size_1():    
    turtle.shapesize(1,1,1)
    
turtle.getscreen().onkeypress(size_1,"1")
turtle.getscreen().listen()

def size_2():    
    turtle.shapesize(2,2,2)
    
turtle.getscreen().onkeypress(size_2,"2")
turtle.getscreen().listen()

def size_3():    
    turtle.shapesize(3,3,3)
    
turtle.getscreen().onkeypress(size_3,"3")
turtle.getscreen().listen()
Esempio n. 60
-1
 def __init__(self,pseudo,adv,*,x=600,y=400):
     super().__init__(pseudo,adversaire = adv)
     turtle.Screen().onkey(self.pleindre,'p')
     turtle.Screen().onkey(self.rule,'j')
     self.coord1 = None
     self.coord2 = None
     turtle.ht() 
     turtle.penup() 
     turtle.bgpic("interface.gif") #charge le fond d'écran
     turtle.setup (width=x, height=y, startx=0, starty=0)
     turtle.Screen().onkey(self.help,'m')
     turtle.goto(-170,115)
     turtle.write(self.adv,align="center",font=("Arial",25, "normal"))
     turtle.goto(140,115)
     turtle.write(pseudo,align="center", font=("Arial",25, "normal"))