Exemplo n.º 1
0
    def show_sharks(self, sharks):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        draw_cnt = 0
        px = {}
        for shark in sharks:
            draw_cnt += 1
            shark_shape = 'classic' if shark.tracked else 'classic'
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 0:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x = int(shark.x * self.one_px)
                scaled_y = int(shark.y * self.one_px)
                scaled_xy = scaled_x * 10000 + scaled_y
                turtle.color(shark.color)
                turtle.shape(shark_shape)
                turtle.resizemode("user")
                turtle.shapesize(1.5,1.5,1)
                if not scaled_xy in px:
                    px[scaled_xy] = 1
                    turtle.setposition(*shark.xy)
                    turtle.setheading(math.degrees(shark.h))
                    turtle.stamp()
Exemplo n.º 2
0
def enlarge():
	global lengthSize
	global widthSize
	turtle.resizemode("user")
	turtle.shapesize(lengthSize+1,widthSize+1)
	lengthSize += 1
	widthSize += 1
Exemplo n.º 3
0
def fireworks(pos, color, size, turtle):
	turtle.shapesize(0)
	turtle.goto(pos)
	turtle.color(color)
	for i in range(0, 36):
		turtle.speed(0)
		turtle.fd(size)
		turtle.lt(250)
Exemplo n.º 4
0
	def update(self):
		turtle.tiltangle(90)

		self.size = (-0.003)*(self.z) + 1.41		# y = mx + b, y=(-0.003)x + 1.41
		turtle.shapesize(self.size*0.7,self.size)

		self.x = self.x + ((s.turnX) * (((-0.3)*(self.z) + 118)/10) * s.acc * 0.1);		#more interpolation

		super().update()
def tegn_romskip():
    turtle.penup()
    turtle.shapesize(4)
    turtle.setpos(200, 400)
    turtle.setheading(90)
    turtle.color('blue')

    turtle.onkey(snu_hoyre, 'Right')
    turtle.onkey(snu_venstre, 'Left')
    turtle.onkey(bruk_motor, 'Up')
    turtle.listen()
Exemplo n.º 6
0
    def show_attraction_point(self, att):
        turtle.color('black')
        turtle.shape('circle')
        turtle.fillcolor("")
        turtle.resizemode("user")
        turtle.shapesize(1.5, 1.5, 1)

        turtle.setposition(att)
        turtle.setheading(0)
        turtle.stamp()
        turtle.update()
Exemplo n.º 7
0
def reduceSize():
	global lengthSize
	global widthSize
	turtle.resizemode("user")
	if lengthSize > 1 and widthSize >1:
		turtle.shapesize(lengthSize-1,widthSize-1)
		lengthSize -= 1
		widthSize -= 1
	else:
		turtle.shapesize(1,1)
		lengthSize = 1
		widthSize = 1
Exemplo n.º 8
0
	def update(self):
		turtle.shapesize(1,1.4)
		#screen wraparound
		if self.x > WIDTH / 2:
			self.x = WIDTH / 2
		elif self.x < -WIDTH / 2:
			self.x = -WIDTH / 2
		elif self.y > HEIGHT / 2:
			self.y = HEIGHT / 2
		elif self.y < -HEIGHT / 2:
			self.y = -HEIGHT / 2
		super().update()
Exemplo n.º 9
0
	def update(self):
		# adjust shear and size
		turtle.shearfactor(self.shear)
		turtle.shapesize(self.size, 1.0)

		self.shear = self.shear + 0.05
		self.size = self.size + 0.05

		super().update()

		# restore original values
		turtle.shapesize(1.0, 1.0)
		turtle.shearfactor(0.0)
Exemplo n.º 10
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()
Exemplo n.º 11
0
	def update(self):
		turtle.shapesize(self.sizex, self.sizey)
		turtle.settiltangle(0)
		#screen wraparound
		if self.x >= WIDTH / 2:
			self.x = -WIDTH / 2
		elif self.x <= -WIDTH / 2:
			self.x = WIDTH / 2 - 2
		elif self.y >= HEIGHT / 2:
			self.y = -HEIGHT / 2
		elif self.y <= -HEIGHT / 2:
			self.y = HEIGHT / 2
		super().update()
		turtle.shapesize(0.1, 0.1)
Exemplo n.º 12
0
	def update(self):
		turtle.tiltangle(90)
		turtle.shapesize(10,4)

		curTime = round(time.time() - s.time, 0)

		if(curTime == math.ceil(curTime) and curTime != self.prevTime):	#prints time
			draw_score()

		if(GAMETIME - curTime <= 0):
			lose()

		self.prevTime = curTime
		
		super().update()
Exemplo n.º 13
0
	def update(self):
		turtle.shapesize(0.2,0.2)
		turtle.settiltangle(0)
		
		#screen wraparound
		if self.x >= WIDTH / 2:
			self.x = -WIDTH / 2
		elif self.x <= -WIDTH / 2:
			self.x = WIDTH / 2 - 2
		elif self.y >= HEIGHT / 2:
			self.y = -HEIGHT / 2
		elif self.y <= -HEIGHT / 2:
			self.y = HEIGHT / 2
		
		super().update()

		if self.age >= SHOTLIFE:
			engine.del_obj(self)
			s.shots -= 1
Exemplo n.º 14
0
import turtle

turtle.width(3)
turtle.shape('turtle')
turtle.shapesize(1,1,1)

turtle.circle(20)
turtle.color('yellow')
turtle.bk(100)
turtle.fd(300)

turtle.up()
turtle.goto(20,20)
turtle.down()
turtle.left(90)

turtle.color('red')
turtle.bk(100)
turtle.fd(300)

turtle.up()
turtle.goto(0,40)
turtle.down()
turtle.left(90)

turtle.color('green')
turtle.bk(100)
turtle.fd(300)

turtle.up()
turtle.goto(-20,20)
Exemplo n.º 15
0
import turtle

SLOW = 500  # this is about 1/2 of a second (quite noticeable)

# get a reference to the turtle's screen, so that later we can
# change the display speed fast/slow
screen = turtle.Screen()

turtle.shape("circle")

numTimes = 4
i = 1

while i <= numTimes:
    # Only go inside this block if i is <= numTimes

    turtle.color("yellow", "blue")  # color of border, then color of shape
    turtle.shapesize(4, 4, 8)  # x stretch, y stretch, then border size

    # Once we see the first circle, slow down so we can see everything
    screen.delay(SLOW)

    turtle.color("green", "purple")  # color of border, then color of shape
    turtle.shapesize(8, 8, 24)  # x stretch, y stretch, then border size

    i = i + 1
    # after i is incremented, the flow of control goes up to the while statement

turtle.done()
Exemplo n.º 16
0
turtle.circle(50)
turtle.end_fill()

turtle.pencolor("salmon")
turtle.pu()
turtle.goto(-150,-200)
turtle.pd()
turtle.stamp()

turtle.pu()
turtle.goto(-150,-250)
turtle.pd()
turtle.stamp()


turtle.pu()
turtle.goto(-150,-150)
turtle.pd()
turtle.stamp()


turtle.pu()
turtle.goto(-150,-300)
turtle.pd()
turtle.stamp()

turtle.pu()
turtle.home()
turtle.pd()
turtle.shapesize(5,5)
Exemplo n.º 17
0
 def draw(self):
     oldmode = turtle.resizemode()
     turtle.shapesize(outline=self.diameter)
     id = super().draw()
     turtle.resizemode(oldmode)
     return id
Exemplo n.º 18
0
import turtle as t
from time import sleep
from random import randint
import random
t.speed("fastest")
t.fillcolor("black")
t.shape("circle")
t.shapesize(.3, .3, .3)
t.pensize(5)

t.penup()
t.goto(-50,100)
t.pendown()
t.forward(100)
t.right(120)
t.begin_fill()
t.forward(200)
t.left(120)
t.forward(100)
t.left(120)
t.forward(10)
t.left(60)
t.forward(90)
t.end_fill()
t.left(180)
t.forward(90)
t.left(120)
t.begin_fill()
t.forward(110)
t.right(120)
t.forward(20)
Exemplo n.º 19
0
colorG = [
    'darkgreen', 'seagreen', 'forestgreen', 'yellowgreen', 'mediumseagreen',
    'green2', 'green3', 'green4', 'OliveDrab1', 'OliveDrab2', 'OliveDrab4'
]
colorB = [
    'saddlebrown', 'salmon4', 'brown4', 'LightSalmon4', 'OrangeRed4', 'gray2',
    'seashell3', 'lightblue2'
]
turtle.shape('square')

#turtle.tracer(0)

for turn in range(6):
    print('Turn = ' + str(turn))
    size = size / 2
    turtle.shapesize(size)
    pixel = turn * turn

    if (turn == 0):
        turtle.goto(0, 0)
        randB = randint(0, 5)
        ranColorB = colorB[randB]
        turtle.color(ranColorB)
        turtle.pd()
        turtle.stamp()

    if (turn == 1):
        value = 25
        pixel = 2

    if (turn == 2):
Exemplo n.º 20
0
import turtle as t

t.shape("turtle")
t.shapesize(3)
t.color("blue")
t.speed(10)

for i in range(10):
    t.circle(70)
    t.forward(30)
Exemplo n.º 21
0
def drawCoin():
    turtle.shape("circle")
    turtle.shapesize(1, 2)
    turtle.stamp()
Exemplo n.º 22
0
import turtle as t

t.color('red')
t.shape('turtle')
t.shapesize(1)
# t.delay(20) # 속도 느리게
t.speed(9)
t.fd(100)  # forward의 줄인 표시
dis = 100
rad = 90
for i in range(100):
    dis += 5
    rad += 2
    t.rt(rad)
    t.fd(dis)  # 2씩 늘린 변수를 대입시켜 각도를 늘림

t.mainloop()
Exemplo n.º 23
0
			dmenor = getDirData(getDirData(int(qactual[1])))/5
		else:
			dmenor = getDirData(int(qactual[1]))/5
		if int(qactual[2]) >= 40000:
			dmayor = getDirData(getDirData(int(qactual[2])))/5
		else:
			dmayor = getDirData(int(qactual[2]))/5
		turtle.pencolor(getDarkColor(qactual[3]))

		turtle.penup()
		turtle.forward((dmenor+0.5)*10)
		turtle.seth(180)
		turtle.forward((dmayor+0.5)*10)
		turtle.seth(90)
		turtle.shape("circle")
		turtle.shapesize(dmenor+0.5,dmayor+0.5,1)
		turtle.fillcolor(getDarkColor(qactual[3]))
		turtle.stamp()
		turtle.shapesize(dmenor,dmayor,1)
		turtle.fillcolor(getColor(qactual[3]))
		turtle.stamp()
		turtle.shapesize(1,1,1)
		turtle.fillcolor("black")
		turtle.shape('classic')
		turtle.penup()
		turtle.seth(0)
		turtle.forward((dmayor+0.5)*10)
		turtle.seth(90)
		turtle.backward((dmenor+0.5)*10)
		prevSample = False
Exemplo n.º 24
0
 def draw(self):
     turtle.shapesize(outline=20)
     draw_shape = super().draw()
     turtle.resizemode("auto")
     return draw_shape
Exemplo n.º 25
0
def jog1():
    #Turtle race
    #EQM - Games
    #Eduardo Q Marques
    #29/03/2019

    #Janela
    window = turtle.Screen()
    window.title("Turtle Race")
    turtle.bgcolor("forestgreen")
    turtle.color("white")
    turtle.speed(0)
    turtle.penup()
    turtle.setpos(-140, 200)
    turtle.write("Turtle Race", font=("Arial", 30, "bold"))
    turtle.penup()

    #DIRT
    turtle.setpos(-400, -180)
    turtle.color("chocolate")
    turtle.begin_fill()
    turtle.pendown()
    turtle.forward(800)
    turtle.right(90)
    turtle.forward(300)
    turtle.right(90)
    turtle.forward(800)
    turtle.right(90)
    turtle.forward(300)
    turtle.end_fill()

    #Final line
    stamp_size = 20
    square_size = 15
    finish_line = 200

    turtle.color("black")
    turtle.shape("square")
    turtle.shapesize(square_size / stamp_size)
    turtle.penup()

    for i in range (10):
            turtle.setpos(finish_line, (150 - (i * square_size * 2)))
            turtle.stamp()

    for j in range(10):
            turtle.setpos(finish_line + square_size, ((150 - square_size) - (j * square_size * 2)))
            turtle.hideturtle()

    #Jabuti 1
    turtle1 = Turtle()
    turtle1.speed(0)
    turtle1.color("black")
    turtle1.shape("turtle")
    turtle1.penup()
    turtle1.goto(-250, 100)
    turtle1.pendown()

    #Jabuti 2
    turtle2 = Turtle()
    turtle2.speed(0)
    turtle2.color("cyan")
    turtle2.shape("turtle")
    turtle2.penup()
    turtle2.goto(-250, 50)
    turtle2.pendown()

    #Jabuti 3
    turtle3 = Turtle()
    turtle3.speed(0)
    turtle3.color("magenta")
    turtle3.shape("turtle")
    turtle3.penup()
    turtle3.goto(-250, 0)
    turtle3.pendown()

    #Jabuti 4
    turtle4 = Turtle()
    turtle4.speed(0)
    turtle4.color("yellow")
    turtle4.shape("turtle")
    turtle4.penup()
    turtle4.goto(-250, -50)
    turtle4.pendown()

    #Jabuti 5
    turtle5 = Turtle()
    turtle5.speed(0)
    turtle5.color("white")
    turtle5.shape("turtle")
    turtle5.penup()
    turtle5.goto(-250, -100)
    turtle5.pendown()

    time.sleep(2) #pause in seconds before race

    #Move the jabutis
    for i in range(145):
            turtle1.forward(randint(1,5))
            turtle2.forward(randint(1,5))
            turtle3.forward(randint(1,5))
            turtle4.forward(randint(1,5))
            turtle5.forward(randint(1,5))
            
    turtle.exitonclick()
Exemplo n.º 26
0
def visualizerTool():
    #Dictionary for source IPs
    ip_dict = {}
    #Set keeps track of all the ips, no duplicates
    ip_set = set()
    #dictionary to keep track of the randomized coordinates of each ip (used later to draw the package comm.)
    ip_screen = {}
    #Initialize the turtle screen with size of 400x300 pixels
    screen = t.Screen()
    screen.screensize(400, 300)

    visited_dict = {}

    #Reads from CSV files
    with open('log.csv', 'r') as csv_file:
        csv_reader = csv.reader(csv_file)

        next(csv_reader)
        #insert the contents of the CSV into the dictionary
        for line in csv_reader:
            #Checks if the IP is already in the set of IPs and adds it if not. Also checks for the destination IP
            if line[0] not in ip_set:
                ip_set.add(line[0])
            if line[1] not in ip_set:
                ip_set.add(line[1])
            #Checks that the src IP is not in the IP dictionary and maps it accordingly
            if line[0] not in ip_dict:
                ip_dict[line[0]] = []
                ip_dict[line[0]].append(line[1])
                ip_dict[line[0]].append(line[2])
            else:
                if ip_dict[line[0]][0] == line[1]:
                    ip_dict[line[0]][1] = line[2]

        #print(ip_set)
        #Draw each "circle" for each IP
        for item in ip_set:
            #print(key + " goes to" + ip_dict[key][0] + " and exchanged " +
            #     ip_dict[key][1] + " packages")

            #Randomize x and y coordinates of the circle and store them in the screen dictionary
            rand_x = r.randrange(-350, 350, 1)
            rand_y = r.randrange(-300, 300, 1)
            ip_screen[item] = (rand_x, rand_y)
            #Sets the turtle color to red and its shape to a circle of size 2
            t.color("purple")
            t.shape("circle")
            t.shapesize(1)
            #Lifts the "pen" so no line is drawn when moving the turtle
            t.penup()
            #Move the turtle to the randomized coordinates and stamp (paint the circle)
            t.setpos(rand_x, rand_y)
            t.stamp()
            #Stamps the IP with its respective circle
            t.setpos(rand_x, rand_y + 20)
            t.write(item, font=("Arial", 15, "bold"))

        #print(ip_screen)
        #Recreates a smaller turtle to show the communication between IPs
        t.shapesize(0.20)
        t.color("orange")
        t.shape("square")

        for key in ip_dict:
            #Hide the turtle while moving to a new location and increase the speed to move faster
            t.hideturtle()
            t.speed(10)
            t.penup()
            dest_ip = ip_dict[key][0]

            #The new position will be given by the randomized values stored in the screen dictionary, mapped to the IP (key)
            t.setpos(ip_screen[key][0], ip_screen[key][1])
            t.showturtle()
            t.speed(1.20)
            #Pen down to draw the line
            t.pendown()
            #New position is the destination source of the current key. Accessed via the IP dictionary, and reused by the
            #screen dictionary to find its coordinates.

            if dest_ip not in visited_dict:
                t.color("orange")
                t.setpos(ip_screen[ip_dict[key][0]][0],
                         ip_screen[ip_dict[key][0]][1])
                t.stamp()
                t.penup()
                t.setpos(ip_screen[ip_dict[key][0]][0],
                         ip_screen[ip_dict[key][0]][1] - 40)
                t.write("Packages: " + ip_dict[key][1],
                        font=("Arial", 12, "bold"))
                visited_dict[dest_ip] = 1
            else:
                t.color("green")
                t.setpos(ip_screen[ip_dict[key][0]][0],
                         ip_screen[ip_dict[key][0]][1])
                t.stamp()
                t.penup()
                t.setpos(ip_screen[ip_dict[key][0]][0],
                         ip_screen[ip_dict[key][0]][1] + 40)
                t.write("Packages: " + ip_dict[key][1],
                        font=("Arial", 12, "bold"))

        t.penup()
        t.hideturtle()
        t.setpos(0, 0)
        t.exitonclick()
Exemplo n.º 27
0
def createtoken(color):
    turtle.speed(0)
    turtle.shape("circle")
    turtle.color(color)
    turtle.shapesize(2.75, 2.75, 2.75)
    turtle.stamp()
Exemplo n.º 28
0
    turtle.color('red')
    turtle.goto(float(bulkx) * xscale - xoffset, float(12) * yscale)

with open(componentFilename) as csv_file:
    biggestComp = 0
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if (line_count != 0):
            biggestComp = max(biggestComp, float(row[2]))
        line_count += 1

print(biggestComp)
with open(componentFilename) as csv_file:
    compScale = 2 / biggestComp
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    turtle.shape('circle')
    turtle.resizemode("user")
    for row in csv_reader:
        if (line_count != 0):
            turtle.penup()
            turtle.goto(
                float(row[0]) * xscale - xoffset,
                float(row[1]) * yscale)
            turtle.pendown()
            turtle.color("blue")
            turtle.shapesize(max((float(row[2]) * compScale)**.5, .05))
            turtle.stamp()
        line_count += 1
Exemplo n.º 29
0
turtle.addshape("star.gif")
turtle.shape("star.gif")

turtle.speed(1000000000000000000000000000000000)
turtle.pensize(1)
a = 0

for i in range(360):
    turtle.pendown()
    turtle.right(90)
    turtle.forward(200)
    turtle.right(45)
    turtle.forward(80)
    turtle.right(45)
    turtle.forward(40)

    turtle.right(90)
    turtle.forward(200)
    turtle.right(45)
    turtle.forward(80)
    turtle.right(45)
    turtle.forward(40)

    turtle.penup()
    turtle.home()
    a += 7
    turtle.left(a)
turtle.shapesize(1000)

turtle.mainloop()
Exemplo n.º 30
0
	turtle.shapesize(lengthSize+1,widthSize+1)
	lengthSize += 1
	widthSize += 1
turtle.onkeypress(enlarge,"equal")
def reduceSize():
	global lengthSize
	global widthSize
	turtle.resizemode("user")
	if lengthSize > 1 and widthSize >1:
		turtle.shapesize(lengthSize-1,widthSize-1)
		lengthSize -= 1
		widthSize -= 1
	else:
		turtle.shapesize(1,1)
		lengthSize = 1
		widthSize = 1
turtle.onkeypress(reduceSize,"minus")
#Stamp function and definition
def stamp(x,y):
	turtle.pu()
	turtle.goto(x,y)
	turtle.stamp()

turtle.ondrag(stamp, btn = 1, add = True)
######
turtle.onscreenclick(turtle.goto, btn = 1, add = True)
turtle.onkeypress(turtle.clear, "space")
print(turtle.shapesize(), turtle.turtlesize())
turtle.getscreen().listen()
turtle.mainloop()
Exemplo n.º 31
0
    def simulate_with_steering(self, next_angle, params):
        """Run simulation to allow glider to be steered.

        Args:
            next_angle(func): Student submission function for gliders next turn angle.
            params(dict): Test parameters.

        Raises:
            Exception if error running submission.
        """
        self._reset()

        #make the test somewhat repeatable by seeding the RNG.
        random.seed(params['map_seed'])

        ourMapFunc = getMapFunc(params['map_seed'], params['map_freq'])
        #Student function is separate, so they can mess it up if they want.
        studentMapFunc = getMapFunc(params['map_seed'], params['map_freq'])

        target = glider.glider(
            params['target_x'],
            params['target_y'],
            5000 + random.randint(-50, 50),  #Altitude
            params['target_heading'],
            ourMapFunc)
        target.set_noise(params['measurement_noise'],
                         params['altitude_offset'], params['turning_noise'])

        other_info = None
        steps = 0
        tolerance = 10.0  #Double tolerance for steering task.

        # Set up the plotter if requested
        if PLOT_PARTICLES == True:
            import turtle
            s = turtle.Screen()
            s.tracer(0, 1)
            turtle.setup(width=800, height=800)
            turtle.setworldcoordinates(-WINDOW_SIZE, -WINDOW_SIZE, WINDOW_SIZE,
                                       WINDOW_SIZE)

            #Draw a cross at (0,0)
            turtle.penup()
            turtle.setposition(0, -5)
            turtle.pendown()
            turtle.setposition(0, 5)
            turtle.penup()
            turtle.setposition(-5, 0)
            turtle.pendown()
            turtle.setposition(5, 0)
            turtle.penup()

            turtle.setposition(target.x, target.y)
            turtle.pendown()
            turtle.shape("triangle")
            turtle.shapesize(0.2, 0.4)
            turtle.settiltangle(target.heading * 180 / math.pi)
            turtle.pencolor("red")

            turtleList = []

        try:
            while steps < params['max_steps']:
                target_meas = target.sense()
                target_height = target.get_height()
                result = next_angle(target_height, target_meas, studentMapFunc,
                                    other_info)
                if len(result) == 3:
                    steering, other_info, extra_points = result
                elif len(result) == 2:
                    steering, other_info = result
                    extra_points = None
                else:
                    print "next_angle did not return 2 or 3 return values!"

                steering = max(-PI / 8.0, steering)
                steering = min(steering, PI / 8.0)

                target.glide(steering)

                target_pos = (target.x, target.y)
                separation = self.distance((0, 0), target_pos)

                if PLOT_PARTICLES == True:

                    if extra_points != None:
                        #Add turtles if needed.
                        while len(extra_points) > len(turtleList):
                            newTurtle = turtle.Turtle()
                            newTurtle.penup()
                            turtleList.append(newTurtle)

                        #remove turtles if needed.
                        while len(extra_points) < len(turtleList):
                            turtleList[-1].hideturtle()
                            turtleList = turtleList[0:-1]

                        # Draw the particles, set angle and position of each turtle.
                        for i in range(len(extra_points)):
                            t = turtleList[i]
                            p = extra_points[i]
                            if len(p) > 2:
                                t.shape("triangle")
                                t.shapesize(0.2, 0.4)
                                t.settiltangle(p[2] * 180 / math.pi)
                            else:
                                t.shape("circle")
                                t.shapesize(0.1, 0.1)
                            t.setposition(p[0], p[1])

                    #Always show the actual glider.
                    turtle.setposition(target.x, target.y)
                    turtle.settiltangle(target.heading * 180 / math.pi)

                    s = turtle.Screen()
                    s.update()

                if VERBOSE == True:
                    actual_height = target.z
                    ground_height = ourMapFunc(target.x, target.y)
                    actual_dist_to_ground = actual_height - ground_height
                    print "Step: {} Actual Heading ({}) \n  Dist To (0,0) = {}\n ".format(
                        steps, target.heading, separation)

                if separation < tolerance:
                    self.glider_found.put(True)
                    self.glider_steps.put(steps)
                    return

                steps += 1

            self.glider_found.put(False)
            self.glider_steps.put(steps)

        except:
            self.glider_error.put(traceback.format_exc())
Exemplo n.º 32
0
import turtle

turtle.shape('turtle')
turtle.shapesize(2, 2)
turtle.speed(6)

def narisi_veckotnik(n, d=100):
    for x in range(n):
        turtle.forward(d)
        turtle.left(360 / n)

def narisi_zvezdico(n, d=100):
    for x in range(n):
        turtle.forward(d)
        turtle.right(180 - 180 / n)
Exemplo n.º 33
0
import turtle as t

t.shape('turtle')
t.shapesize(2)
t.speed(0)
t.width(2)

t.color("chocolate")
for n in range(10):
    t.circle(70)
    t.penup()
    t.fd(30)
    t.pendown()

t.exitonclick()
Exemplo n.º 34
0
def drawmonsterdetails(mirror, scale, generikmon,startoftoes):
    detailsbit = generikmon['detail0']
    turtle.penup()
    turtle.goto(startoftoes)
    turtle.pendown()
    ### draw the toes webs and claws    
    numofToes = generikmon['numofToes']
    fullwidth= turtle.xcor()
    tailwidth= fullwidth*generikmon['tailbodyratio'] #talibodywidthratio,
    pawswidth= fullwidth-tailwidth
    frontpawwidth=pawswidth*generikmon['frontbackratio'] #fronttobackratio
    toewidth=frontpawwidth/(numofToes)
    for i in range(numofToes):
        turtle.setheading(270)
        turtle.forward(scale*generikmon['toelengthD'])#toelengthD
        turtle.right(mirror*90)
        turtle.forward(mirror*toewidth*0.1)  #mirror required here since xcord is negative on second hlaf
        # start claw layout calcs
        xclawstart = turtle.xcor()
        xclawtip = xclawstart - toewidth*0.4
        xclawend = xclawtip - toewidth*0.4
        yclawstart = turtle.ycor()
        yclawtip = yclawstart-scale*detailsbit['clawlength']
        yclawend = yclawstart
        #draw claw (it's already at the start)
        turtle.goto(xclawtip, yclawtip)
        turtle.goto(xclawend, yclawend)     
        turtle.forward(mirror*toewidth*0.1)  #mirror required here since xcord is negative on second hlaf
        turtle.right(mirror*90)
        turtle.forward(scale*generikmon['toelengthD']) #toelegnth - going back up               
      #into the rear toes. # all lengths scaled by generikmon[16] = frontotbackratio
    toewidth=(pawswidth-frontpawwidth)/numofToes  #redefines toe width for backpaws.
    for i in range(numofToes):
        turtle.setheading(270)
        turtle.forward(scale*generikmon['frontbackratio']*generikmon['toelengthD'])#toelengthD
        turtle.right(mirror*90)
        turtle.forward(mirror*toewidth*0.1)  #mirror required here since xcord is negative on second hlaf
        # start claw layout calcs
        xclawstart = turtle.xcor()
        xclawtip = xclawstart - toewidth*0.4
        xclawend = xclawtip - toewidth*0.4
        yclawstart = turtle.ycor()
        yclawtip = yclawstart-scale*detailsbit['clawlength']*generikmon['frontbackratio']
        yclawend = yclawstart
        #draw claw (it's already at the start)
        turtle.goto(xclawtip, yclawtip)
        turtle.goto(xclawend, yclawend)     
        turtle.forward(mirror*toewidth*0.1)  #mirror required here since xcord is negative on second hlaf
        turtle.right(mirror*90)
        turtle.forward(scale*generikmon['frontbackratio']*generikmon['toelengthD']) #toelegnth - going back up
        

    ### draw the ears
    turtle.penup()
    turtle.home()
    turtle.setheading(90)
    turtle.right(mirror*90)                 #requires turtle to be facing upwards       
    turtle.forward(scale*generikmon['crownD'])  #crownD follow crown line exactly
    turtle.left(mirror*generikmon['ear1A'])     #ear1A
    turtle.right(mirror*90)     #turns back into shape.
    turtle.forward(scale*(generikmon['ear2D']*0.1+0.01))
    startoftheear = turtle.pos()
    turtle.pendown()
        # start actually drawing
    turtle.setheading(90)
    turtle.right(mirror*90)
    turtle.left(mirror*generikmon['ear1A'])     #ear1A
    turtle.forward(scale*generikmon['ear2D']*0.8)  #ear2D
    turtle.right(mirror*generikmon['ear3A'])    #ear3A
    turtle.forward(scale*generikmon['ear2D']*0.8)  #ear2D
    turtle.right(mirror*generikmon['ear4A'])    #ear4A
    turtle.forward(scale*generikmon['ear6D']*0.7)  #ear6D
    turtle.right(mirror*generikmon['ear5A'])    #ear5A
    turtle.forward(scale*generikmon['ear6D']*0.7)  #ear5D
    turtle.goto(startoftheear)                      #finishs the ear off.
    ### draw the eyes (stamped over ears if needed)
    turtle.penup()
    turtle.home()
   # print(turtle.xcor(),turtle.ycor())
    turtle.setheading(90)
    turtle.right(mirror*90)                 #requires turtle to be facing upwards       
    turtle.forward(scale*generikmon['crownD']*detailsbit['eyeratio']) #crownD, #eyeratio
    turtle.setheading(270)
    turtle.forward(scale*generikmon['cheekD']*(1-detailsbit['eyeratio'])) #cheekD, #eyeratio
    turtle.shape("circle")
    turtle.resizemode("user")
    turtle.shapesize(detailsbit['eyesize'],detailsbit['eyesize']*detailsbit['eyeratio']*4,1)
   # print(turtle.shapesize())
    turtle.tilt(mirror*detailsbit['frownA'])
    turtle.stamp()
    turtle.tilt(-1*mirror*detailsbit['frownA']) #takes the tilt off the turtle to avoid later confusion
    turtle.shapesize(1,1,1)             #takes off the eye size, i think.
    ### draw the nose
    turtle.penup()
    turtle.home()
    turtle.setheading(270)
    turtle.forward(scale*generikmon['cheekD']) #cheekD
    turtle.shape("triangle")
    turtle.shapesize(detailsbit['nosesize'],detailsbit['nosesize'],1)
    turtle.stamp()
    #and from the nose, the mouth
    turtle.pendown()
    turtle.forward(scale*generikmon['shoulderD']*detailsbit['nosesize']+detailsbit['nosesize']) #shouldD below the nose
    turtle.left(mirror*90)
    turtle.forward(scale*generikmon['crownD']*detailsbit['mouthsize']) #crownD   #width of mouth
    turtle.penup()
    turtle.home()
    return()
Exemplo n.º 35
0
import turtle
import math



turtle.shape('turtle')
turtle.shapesize(1)
turtle.speed(10)


def polygon(r, n):
    turtle.pendown()
    for i in range (n):
        turtle.left(90 + 180/n)
        turtle.forward(2 * r * math.sin(math.pi/n))
        turtle.right((180 - 360/n) / 2)
    turtle.penup()
    
    
for i in range (1, 10):
    turtle.penup()
    turtle.goto(20*i + 10, 0)
    polygon(20*i + 10, i + 2)
 
    
Exemplo n.º 36
0
def size_2():    
    turtle.shapesize(2,2,2)
Exemplo n.º 37
0
import turtle
import random
turtle.shape('circle')
turtle.shapesize(3, 3, 3)
turtle.penup()
turtle.forward(400)
turtle.pendown()
turtle.left(90)
turtle.circle(400)
turtle.penup()
turtle.goto(0, 0)
while turtle.distance(0, 0) < 400:
    turtle.left(random.randint(1, 180))
    turtle.forward(100)
    if turtle.distance(0, 0) >= 400:
        turtle.undo()
Exemplo n.º 38
0
def size_4():    
    turtle.shapesize(4,4,4)
Exemplo n.º 39
0
import turtle as t


def draw_pos(x, y):
    t.clear()
    t.setpos(x, y)
    t.stamp()

    hl = -(t.window_height() / 2)

    tm = 0
    while True:
        d = (9.8 * tm**2) / 2
        ny = y - int(d)
        if ny > hl:
            t.goto(x, ny)
            t.stamp()
            tm = tm + 0.3
        else:
            break


t.setup(500, 600)
t.shape("circle")
t.shapesize(0.3, 0.3, 0)
t.penup()
s = t.Screen()
s.onscreenclick(draw_pos)
s.listen()
Exemplo n.º 40
0
        # Locate the tile and move to the tile position
        #
        # - Find the x, y position of the tile in the turtle window
        tile_x = maze_x + col * tile_size
        tile_y = maze_y + (maze_rows - row - 1) * tile_size

        # - Put the turtle to the tile position
        turtle.goto(tile_x, tile_y)

        # Draw the tiles according to the tile symbol
        #
        # - Draw the tiles for walls, food and power food
        if tile == "+":  # wall
            turtle.shape("square")
            turtle.shapesize(tile_size / 20,
                             tile_size / 20)  # 1 denote 20 pixels
            turtle.color("blue", "black")
            turtle.stamp()
        elif tile == ".":  # food
            turtle.color("yellow")
            turtle.dot(food_size / 2)

            food_count += 1
        elif tile == "o":  # power food
            turtle.color("white")
            turtle.dot(food_size)

            food_count += 1
        # - Initialize the position of pacman
        elif tile == "P":  # pacman
            pacman_x = tile_x
Exemplo n.º 41
0
turtle.forward(300)
turtle.right(90)
turtle.forward(800)
turtle.right(90)
turtle.forward(300)
turtle.end_fill()  #Fill the shape drawn after the last call to begin_fill()

# fINISH LINE
stamp_size = 20  #Move and draw / turtle.stamp Stamp a copy of the turtle shape onto the canvas at the current turtle position
square_size = 15
finish_line = 200

turtle.color("black")
turtle.shape("square")
turtle.shapesize(
    square_size / stamp_size
)  #turtle.shapesize(stretch_wid=None, stretch_len=None, outline=None) // turtle.shapesize(5, 5, 12)
turtle.penup()

#i,j
for i in range(10):
    turtle.setpos(finish_line,
                  (150 - (i * square_size * 2)
                   ))  #150 = y (Finish Line)/ *2 = development of squares
    turtle.stamp()

for j in range(10):
    turtle.setpos(finish_line + square_size,
                  ((150 - square_size) - (j * square_size * 2)))
    turtle.stamp()
Exemplo n.º 42
0
	def draw(self):
		oldmode = turtle.resizemode()
		turtle.shapesize(outline=self.diameter)
		id = super().draw()
		turtle.resizemode(oldmode)
		return id
Exemplo n.º 43
0
import turtle
import constantes
import robot_mouvment
import init_board
from constantes import LISTEGOBI, convert_CMOtoCTC, convert_CTCtoCMO


turtle.colormode(0xFF)
turtle.speed(100)
turtle.shapesize(0.1, 0.1, 0.1)
turtle.penup()
init_board.dessin_Gobies_init()


def dessin_Gobies_init2():
    """
    Dessine l'ensemble des gobies de la table (à ne faire qu'une fois). Dans
    l'état les éléments de la liste sont en unité turtle centré
    donc on applique juste ECHELLE.
    """
    for i in range(0, 24):
        init_board.dessin_Cercle(
            convert_CMOtoCTC(LISTEGOBI[i][0]),
            convert_CMOtoCTC(LISTEGOBI[i][1]),
            LISTEGOBI[i][2]
        )


rotate_target(86)
turtle.mainloop()
Exemplo n.º 44
0
import turtle

turtle = turtle.Turtle()

# turtle. tilt(angle)
# Parameters: angle – a number
# Rotate the turtleshape by angle from its current tilt-angle, but do not change the turtle’s heading (direction of movement).

turtle.speed(1)
turtle.shape("circle")
turtle.shapesize(5, 2)
turtle.tilt(30)
turtle.fd(50)
turtle.tilt(30)
turtle.fd(50)
Exemplo n.º 45
0
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.forward(800)
turtle.right(90)
turtle.forward(300)
turtle.end_fill()

#finish line
stamp_size = 20
square_size = 15
finish_line = 200

turtle.color("black")
turtle.shape("square")
turtle.shapesize(square_size / stamp_size)
turtle.penup()

for i in range(10):
    turtle.setpos(finish_line, (150 - (i * square_size * 2)))
    turtle.stamp()
for j in range(10):
    turtle.setpos(finish_line + square_size,
                  (150 - square_size) - (j * square_size * 2))
    turtle.stamp()

#turtle1
t1 = Turtle()
t1.speed(0)
t1.color('black')
t1.shape('turtle')
Exemplo n.º 46
0
import turtle as t
t.title('自动轨迹绘制')
t.setup(800, 600, 0, 0)
t.pencolor("red")
t.shapesize(5)
# 数据读取
datals = []
f = open("D:/PythonProject/chapter7/data.txt")
for line in f:
    line = line.replace("\n", "")
    datals.append(list(map(eval, line.split(","))))
f.close()
# 自动绘制
for i in range(len(datals)):
    t.pencolor(datals[i][3], datals[i][4], datals[i][5])
    t.fd(datals[i][0])
    if datals[i][1]:
        t.right(datals[i][2])
    else:
        t.left(datals[i][2])
t.done

Exemplo n.º 47
0
import turtle

for i in range(1):
    turtle.shapesize(0.01)
    turtle.pensize(5)
    turtle.pencolor("blue")
    turtle.title("Animation 1")
    turtle.speed(1)
    turtle.left(270)
    turtle.forward(90)
    turtle.left(90)
    turtle.forward(90)
    turtle.clear()
    turtle.penup()
    turtle.goto(0,0)
    turtle.pendown()
    turtle.left(270)
    turtle.forward(90)
    turtle.penup()
    turtle.goto(0,0)
    turtle.goto(0,90)
    turtle.pendown()
    turtle.forward(9)
    turtle.clear()
    turtle.penup()
    turtle.goto(0,0)
    turtle.pendown()
    turtle.left(45)
    turtle.forward(90)
    turtle.left(90)
    turtle.forward(90)
Exemplo n.º 48
0
import turtle

turtle.shape('turtle')
turtle.shapesize(2)
turtle.color('green')
Exemplo n.º 49
0
def size_1():    
    turtle.shapesize(1,1,1)
Exemplo n.º 50
0
import turtle
#turtle.circle(100,180)
turtle.shape("circle")
turtle.shapesize(4, 5, 1)
turtle.fillcolor("white")
Exemplo n.º 51
0
def size_3():    
    turtle.shapesize(3,3,3)
Exemplo n.º 52
0
import turtle

turtle.shape("circle")
turtle.shapesize(.1, .1, 5)
speed = 5
x, y = 0, 0
turtle.speed(0)
xmaxsize = 512
ymaxsize = 256

turtle.setup(xmaxsize * 2, ymaxsize * 2)
xdir, ydir = speed, speed
xlimit, ylimit = xmaxsize, ymaxsize
turtle.penup()

while True:
    x = x + xdir
    y = y + ydir

    if not -xlimit < x < xlimit:
        xdir = -xdir
    if not -ylimit < y < ylimit:
        ydir = -ydir

    turtle.goto(x, y)
Exemplo n.º 53
0
def size_5():    
    turtle.shapesize(5,5,5)
Exemplo n.º 54
0
import turtle

# default square
print()
print('"Your Default square size is : 15 px"')
print()
print("Do you want to change square size ?")
turtle.bgcolor("gray")
turtle.color("black", "olive")
turtle.pensize(5)

turtle.begin_fill()
turtle.shape("square")  # create the square using shape method.
turtle.shapesize(15)  #shape size.
turtle.end_fill()

print()

b = int(input("So, enter the value for square in px : ")
        )  # Enter the any interger value for area of square.

turtle.reset()  #reset the python turtle graphic

print()

print('"Thank you, you can check your square in python turtle graphic."')

d = b * b  # area of square

window = turtle.Screen()  # Pop up a new window using turtle screen method.
Exemplo n.º 55
0
    t.showturtle()  ##거북이를 화면에 표시하는 함수
    t.stamp()  ##현재위치에 스탬프 찍기

    hl = -(t.window_height() / 2)
    # t.window_height() : 터틀창의 높이를 반환하는 함수

    ux = velocity * math.cos(angle)
    uy = velocity * math.sin(angle)

    while True:
        uy = uy + (-1 * a_g) * drawing_time
        dy = t.ycor() + (uy * drawing_time) - (a_g * drawing_time ** 2) / 2
        ##t.ycor() : 현재위치의 y좌표 반환
        dx = t.xcor() + (ux * drawing_time)
        # t.xcor() : 현재위치의 x좌표 반환

        if dy > hl:
            t.goto(dx, dy)
            t.stamp()
        else:
            break  ##완료시 반복문 탈출


t.setup(600, 600)  # 화면 창 크기 조절
t.shape("turtle")  # 거북이의 모양을 바꿔주는 함수 모양에는 'arrow','turtle','circle'등이 있습니다.
t.shapesize(0.5, 0.5, 0.5)  # 거북이의 폭과 길이의 스케일과 외곽선의 두께를 지정하는 함수
t.penup()  # 펜 올리기
s = t.Screen()
s.onscreenclick(draw_track)
s.listen()  ##키 입력모드 실행
t.mainloop()  # ==t.done() ##저의 개발환경이 '파이참'이라 터틀창이 바로 꺼지는 현상이 있었습니다. 이를 해결하기 위하여 쓴 함수입니다.##
Exemplo n.º 56
0
int1 = int(add[:space])
int2 = int(add[space+1:])

answer = int1+int2
str2 = str(int1)+'+'+str(int2)+'='+str(answer)
print (str2)
#Problem 4
import turtle
color = str(input("Enter a color: "))
shape = str(input("Enter a shape: "))
size = int(input("Enter a size: "))

turtle.color(color)
turtle.shape(shape)
turtle.shapesize(size,size)
#Problem 5
old_tel=str(input("Please enter the old phone number "))
if(old_tel[3]!= '-' and old_tel[7]!='-' and len(old_tel)==12):
    print ("invalid number")
else:
    save= old_tel[8:]
    new_tel = str(('646-997-')+save)
    print (new_tel)

#Question 6
phrase=str(input("enter the phrase: "))
first_space = phrase.find(" ")
small_phrase=phrase[1+first_space:]
second_space= small_phrase.find(" ")
second_space+=first_space+1