def main(): '''Creates lsystem from filename and then creates an arrangement''' # creates object from lsystem l = ls.Lsystem('lsystemextension2.txt') #number of iterations # for growth effect in task 3, made iters a parameter num_iter = 4 # creates buildstring function s = l.buildString(num_iter) #specific angle angle = 30 #creates an object from TI class ti = it.TurtleInterpreter() # sets the colors of the tracer and calls the drawstring function turtle.pencolor('ForestGreen') '''tree with stem color of forestgreen''' turtle.up() turtle.setposition(0,0) turtle.setheading(90) turtle.down() ti.drawString(s, 50 ,angle) ti.hold()
def plot_a_face(angle, pencolor, fillcolors, dimension): t.down() def plot_a_row(angle, pencolor, fillcolors,dimension): for i in range(len(fillcolors)): t.color(pencolor, fillcolors[i]) t.begin_fill() t.forward(50*3/dimension) t.right(angle) t.forward(50*3/dimension) t.right(180 - angle) t.forward(50*3/dimension) t.right(angle) t.forward(50*3/dimension) t.right(180 - angle) t.end_fill() t.forward(50*3/dimension) n = int(len(fillcolors)/dimension) for i in range(n): plot_a_row(angle,pencolor,fillcolors[dimension*i:dimension*(i+1)],dimension) t.up() t.backward(150) t.right(angle) t.forward(50*3/dimension) t.left(angle) t.down()
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)
def line(a, b, x, y): "Draw line from `(a, b)` to `(x, y)`." import turtle turtle.up() turtle.goto(a, b) turtle.down() turtle.goto(x, y)
def choix_position(self): #position aléatoire dans l'écran self.x = random.randint(-350, 350) self.y = random.randint(-350, 350) tt.up() tt.goto(self.x, self.y) tt.down()
def draw_tree(depth, height, branches, leafs, angle): """ Draws the tree using recursion :pre: pos(0,0), heading east, up :post: pos(0,0), heading east, up :param depth: number of layers of sub branches (recursion depth) :param height: height of tree :param branches: number of branches :param leafs: number of leafs :param angle: angle between branches :return: None """ if depth == 0: leafs = random.randint(0, leafs) draw_leaf(leafs) t.down() pass else: t.color('brown') t.forward(height) for i in range(1, branches+1): t.left(90 - i * angle) #random branches branches = random.randint(branches-1,branches+5) draw_tree(depth - 1, height * HEIGHT_FACTOR, branches, leafs, angle) t.right(90 - i * angle) #random angle angle = random.randint(angle-1, angle+1) if depth == 1: break t.color('brown') t.backward(height)
def drawCircle(x, y, r): turtle.up() turtle.setpos(x+r,y) turtle.down() for i in range(0, DEGREES_IN_CIRCLE): a = math.radians(i+1) turtle.setpos(x+r*math.cos(a), y+r*math.sin(a))
def draw_leaf(no_of_leafs): """ Draws leafs at the end of branch. Min 0 and max = no_of_leafs :pre: pos(0,0), heading east, up :post: pos(0,0), heading east, up :param no_of_leafs: maximum number of leads drawn :return: None """ for i in range(no_of_leafs): # draws random poylgon from triangle to hexagon sides = random.randint(3, 6) color = random.choice(COLORS) size = 10 angle = 360/sides t.left(90 - i * angle) t.right(90) t.begin_fill() t.down() t.color(color) for _ in range(sides): t.forward(size) t.left(angle) t.left(90) t.up() t.end_fill() t.right(90 - i * angle) global LEAF_COUNTER LEAF_COUNTER += 1
def drawS(length): """ Draw English character 'S' :pre: (relative) pos (X,Y), heading (east), up :post: (relative) pos (X+length,Y), heading (east), up :return: None """ turtle.up() turtle.left(90) turtle.forward(length) turtle.right(90) turtle.down() turtle.forward(length) turtle.right(180) turtle.forward(length) turtle.left(90) turtle.forward(length / 2) turtle.left(90) turtle.forward(length) turtle.right(90) turtle.forward(length / 2) turtle.right(90) turtle.forward(length) turtle.right(180) turtle.forward(length) turtle.up()
def drawHouse(wallSize): """ This is the function for drawing house which takes wall size as a input. :pre: (relative) pos (0,0), heading (east), right :post: (relative) pos (wallSize,0), heading (north), up :return: total wood required to built the house. """ turtle.down() turtle.forward(wallSize) turtle.left(90) turtle.forward(wallSize) maxX = turtle.xcor() turtle.left(45) turtle.forward(wallSize / math.sqrt(2)) maxY = turtle.ycor() turtle.left(90) turtle.forward(wallSize / math.sqrt(2)) turtle.left(45) turtle.forward(wallSize) turtle.left(90) turtle.forward(wallSize) turtle.up() return 2 * (wallSize + wallSize / math.sqrt(2))
def draw_triangle(point1, point2, point3): turtle.up() turtle.goto(point1) turtle.down() turtle.goto(point2) turtle.goto(point3) turtle.goto(point1)
def drawY(length): """ Draw English character 'Y' :pre: (relative) pos (X,Y), heading (east), up :post: (relative) pos (X+length,Y), heading (east), up :return: None """ turtle.up() turtle.left(90) turtle.forward(length) turtle.right(90) turtle.down() turtle.right(45) turtle.forward(math.sqrt((2 * math.pow((length / 2), 2)))) # moving at 45 degree angle for length sqrt(((math.pow((length/2)+(math.pow((length/2)),2))) # calculated using pythagorean theorem. turtle.right(45) turtle.forward(length / 2) turtle.right(180) turtle.forward(length / 2) turtle.right(45) turtle.forward(math.sqrt((2 * math.pow((length / 2), 2)))) turtle.right(45) turtle.up() turtle.right(90) turtle.forward(length) turtle.left(90) turtle.up()
def roach(turt): #make moves a global variable global moves turt.pencolor(randrange(255),randrange(255),randrange(255)) turtle.up() turtle.goto(0,0) turtle.down() #write the code for roach to go & turn while True: moves += 1 turt_heading = randrange(0,361) turt.left(turt_heading) turt_length = randrange(0,31) turt.forward(turt_length) distance = dist(turt) #if statement to determine if the roach is outside the circle or inside #if inside, keep moving #if outside, stop moving #return coordinate if distance >= 200: break turt.up() moves += moves #accummulate total moves print(moves) return moves
def questionMark(): """ Draw a question mark. """ scale = int(input("scale, integer please")) turtle.forward( 10 *scale) turtle.down() turtle.left( 90 ) turtle.forward( 2 *scale) turtle.up() turtle.forward( 3 *scale) turtle.down() turtle.forward( 5 *scale) turtle.right( 90 ) turtle.forward( 10 *scale) turtle.left( 90 ) turtle.forward( 10 *scale) turtle.left( 90 ) turtle.forward( 20 *scale) turtle.left( 90 ) turtle.forward( 5 *scale) turtle.up() turtle.forward( 15 *scale) turtle.left( 90 ) turtle.forward ( 30 *scale)
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()
def hexagone(c, longueur,m, col1, col2, col3,deform): """ Draws a hexagon with or without deformation """ lo = longueur x,y,z = c #Hexagon centre pa1,pa2,pa3 = (x+lo,y,z), (x+(lo/2),y-m,z), (x-(lo/2),y-m,z)#First losange coordinates (lower right) pb1,pb2,pb3 = (x+lo,y,z), (x+(lo/2),y+m,z), (x-(lo/2),y+m,z)#Losange 2 (upper right) pc1,pc2,pc3 = (x-(lo/2),y+m,z), (x-lo,y,z), (x-(lo/2),y-m,z)#Losange 3 (left) pts = [pa1,pa2,pa3,c,pb1,pb2,pb3,c,pc1,pc2,pc3,c] d = [] for point in pts: xd,yd,zd = deform(point) d.extend((xd,yd)) up() setpos(d[6],d[7])#Turtle resets to c down() col = [col1,col2,col3] i = 0 for e in col: color(e) begin_fill() goto(d[i],d[i+1]) goto(d[i+2],d[i+3]) goto(d[i+4],d[i+5]) goto(d[i+6],d[i+7]) end_fill() i += 8
def drawEyes(): """ Draw the pair of eyes. :pre: (relative) pos (0,0), heading (east), up :post: (relative) pos (0,0), heading (east), up :return: None """ # left eye turtle.forward(10) turtle.left(90) turtle.forward(10) turtle.right(90) turtle.down() turtle.begin_fill() turtle.circle(5) turtle.end_fill() turtle.up() # right eye turtle.forward(30) turtle.down() turtle.begin_fill() turtle.circle(5) turtle.end_fill() turtle.up() # return back turtle.back(30) turtle.left(90) turtle.back(10) turtle.right(90) turtle.back(10)
def drawY(): """ :pre: pos relative (0,0), heading (east), up :post: pos relative (0,0), heading (east), up :return: None """ turtle.up() turtle.forward(UNIT / 2) turtle.down() turtle.left(ANGLENINETY) turtle.forward(UNIT) turtle.left(ANGLENINETY) turtle.forward(UNIT / 2) turtle.right(ANGLENINETY) turtle.forward(UNIT) turtle.up() turtle.right(ANGLENINETY) turtle.forward(UNIT) turtle.down() turtle.right(ANGLENINETY) turtle.forward(UNIT) turtle.right(ANGLENINETY) turtle.forward(UNIT / 2) turtle.up() turtle.left(ANGLENINETY) turtle.forward(UNIT) turtle.right(ANGLENINETY) turtle.forward(UNIT / 2) turtle.right(180)
def drawNose(): """ Draw the nostrils. :pre: (relative) pos (0,0), heading (east), up :post: (relative) pos (0,0), heading (east), up :return: None """ turtle.forward(25) turtle.left(90) turtle.forward(30) turtle.left(45) turtle.forward(5) turtle.down() turtle.forward(1) turtle.back(1) turtle.up() turtle.back(5) turtle.right(90) turtle.forward(5) turtle.down() turtle.forward(1) turtle.back(1) turtle.up() turtle.back(5) turtle.left(45) turtle.up() turtle.back(30) turtle.right(90) turtle.back(25)
def drawTongue(): """ Draw the tongue. :pre: (relative) pos (0,0), heading (east), up :post: (relative) pos (0,0), heading (east), up :return: None """ turtle.color('red') turtle.forward(25) turtle.left(90) turtle.forward(60) turtle.down() turtle.forward(25) turtle.left(45) turtle.forward(10) turtle.back(10) turtle.right(90) turtle.forward(10) turtle.back(10) turtle.left(45) turtle.up() turtle.back(85) turtle.right(90) turtle.back(25) turtle.color('black')
def tSquare(size, level): """ The T-Square fractal. http://en.wikipedia.org/wiki/T-Square_%28fractal%29 """ if level < 1: drawSquare(size, True) else: drawSquare(size, True) bk(size / 4.0) left(90) fd(size / 4.0) right(90) tSquare(size / 2.0, level - 1) up() fd(size) down() tSquare(size / 2.0, level - 1) right(90) fd(size) left(90) tSquare(size / 2.0, level - 1) bk(size) tSquare(size / 2.0, level - 1) left(90) up() fd(size * 3 / 4.0) down() right(90) fd(size / 4.0)
def drawK(): """ Draw the alphabet K :pre: (relative) pos (0,0), heading (east), up :post: (relative) pos(CHAR_WIDTH + CHAR_GAP,0), heading (east), up :return: None """ turtle.down() turtle.left(90) turtle.forward(CHAR_HEIGHT) turtle.backward(CHAR_HEIGHT/2) angleK = math.degrees(math.atan(2 * CHAR_WIDTH/CHAR_HEIGHT)) turtle.right(angleK) #turtle.forward(math.sqrt(CHAR_HEIGHT^2 + CHAR_WIDTH^2)/2) turtle.forward(CHAR_HYPOT) turtle.backward(CHAR_HYPOT) turtle.right(180 - 2 * angleK) turtle.forward(CHAR_HYPOT) turtle.backward(CHAR_HYPOT) turtle.right(angleK) turtle.forward(CHAR_HEIGHT/2) turtle.left(90) turtle.up() turtle.forward(CHAR_WIDTH + CHAR_GAP)
def tree1(argv, x, y): lsys_filename1 = argv[1] lsys1 = ls.createLsystemFromFile( lsys_filename1 ) print lsys1 num_iter1 = int( 3 ) dist = float( 5 ) angle1 = float( 22 ) s1 = ls.buildString( lsys1, num_iter1 ) #draw lsystem1 '''this is my first lsystem with filename mysystem1.txt with 3 iterations and with angle = 45 dist = 10''' turtle.tracer(False) turtle.speed(50000000) turtle.up() turtle.goto(0,0) turtle.goto(x, y) turtle.down() turtle.pencolor('White') it.drawString( s1, dist, angle1 ) # wait and update turtle.update()
def drawBorder(): """Draw a circle for the outline of the thingy. that is a circle of radius 100""" turtle.right( 90 ) turtle.down() turtle.circle( 100 ) turtle.up() turtle.left( 90 )
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')
def questionMark(scale = 1): """ Draw a question mark. """ turtle.up() turtle.forward( 10 * scale ) turtle.down() turtle.left( 90 ) turtle.forward( 2 * scale ) turtle.up() turtle.forward( 3 * scale ) turtle.down() turtle.forward( 5 * scale) turtle.right( 90 ) turtle.forward( 10 * scale) turtle.left( 90 ) turtle.forward( 10 * scale ) turtle.left( 90 ) turtle.forward( 20 * scale ) turtle.left( 90 ) turtle.forward( 5 * scale ) turtle.up() turtle.forward( 15 * scale ) turtle.left( 90 ) turtle.forward ( 30 * scale )
def bezier(smooth, x1, y1, x2, y2, x3, y3, *others): if len(others) % 2 != 0: print("Missing point data.") return if smooth < 1: print("Invalid smooth value") return wasDown = turtle.isdown() points = list(others) xval = [x1, x2, x3] + points[0:len(points):2] yval = [y1, y2, y3] + points[1:len(points):2] t, n, factn, step = 0, len(xval) - 1, factoral(len(xval) - 1), 1.0/smooth turtle.up() turtle.goto(x1, y1) if wasDown: turtle.down() while(t <= 1): x, y = 0, 0 for i in range(0, n+1): b = factn / ((factoral(i)) * (factoral(n - i))) #binomial coefficient k = ((1 - t) ** (n - i)) * (t ** i) #powers x += b * k * xval[i] #parametric application y += b * k * yval[i] #to x and y turtle.goto(x, y) t += step
def newSnow(size,n): x=size/2 y=.4 if n<=0 or size<10: return else: for i in range(2): if n%2==0: turtle.color("#0099CC") elif n%3==0: turtle.color("#B2DFEE") else: turtle.color("#00B2EE") turtle.forward(y*size/2) turtle.left(60) newSnow(x,n-1) turtle.right(120) newSnow(x,n-1) turtle.left(60) x/=2 y+=.2 if n%2==0: turtle.color("#0099CC") elif n%3==0: turtle.color("#B2DFEE") else: turtle.color("#00B2EE") turtle.forward(.4*size/2) turtle.up() turtle.back(1.4*size/2) turtle.down() return
def sun(argv): lsys_filename3 = argv[3] lsys3 = ls.createLsystemFromFile( lsys_filename3 ) print lsys3 num_iter3 = int( 3 ) dist = 5 angle3 = float( 120 ) s3 = ls.buildString( lsys3, num_iter3 ) #draw lsystem3 '''this is my third lsystem with filename mysystem3.txt with 3 iterations and with angle = 45 dist = 10''' turtle.up() turtle.goto(0,0) turtle.goto(300, 200) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Red') it.drawString( s3, dist, angle3 ) # wait and update turtle.update()
def tree2(argv, x, y): lsys_filename2 = argv[2] lsys2 = ls.createLsystemFromFile( lsys_filename2 ) print lsys2 num_iter2 = int( 3 ) dist = float( 5 ) angle2 = float( 30 ) s2 = ls.buildString( lsys2, num_iter2 ) #draw lsystem2 '''this is my second lsystem with filename mysystem2.txt with 5 iterations and with angle = 120 dist = 10''' turtle.up() turtle.goto(0,0) turtle.goto(x,y) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('White') it.drawString( s2, dist, angle2 ) # wait and update turtle.update()
def line(x1, y1, x2, y2): turtle.up() turtle.goto(x1,y1) turtle.down() turtle.goto(x2,y2)
""" Нарисуйте, используя модуль turtle число: 9654 """ import turtle as t t.setup(800, 800) t.width(5) t.color('#ff0004') t.speed(2) t.up() for nine in range(1): t.goto(0, -100) t.down() t.fd(50) t.left(90) t.fd(100) t.left(90) t.fd(50) t.left(90) t.fd(50) t.left(90) t.fd(50) t.up() for six in range(1): t.goto(70, 0) t.down() t.fd(50) t.bk(50) t.right(90)
#__Author__:Administrator #__date__:2018/5/29 import turtle import math # 660*440 flag_length = 660 flag_width = 440 turtle.color('red') turtle.begin_fill() turtle.up() turtle.goto(-330, 220) turtle.down() turtle.goto(330, 220) turtle.goto(330, -220) turtle.goto(-330, -220) turtle.goto(-330, 220) turtle.end_fill() turtle.home() # 画一个五角星 def star(x, y, angle, length): turtle.up() turtle.goto(x, y) turtle.setheading(angle) distance = length * (1 + math.sin(18 / 360 * math.pi * 2)) / math.cos( 18 / 360 * math.pi * 2) turtle.fd(distance) turtle.color('yellow') turtle.rt(18)
def main(): # 1.读取原图 img = cv2.imread('../Origin/TurtleImg.png') # 2.对原图进行处理,提取线条边缘,并做Hough变换 edges = cv2.Canny(img, 50, 150) hough_lines = cv2.HoughLinesP(edges, 2, np.pi / 180, 10) # , 20) hough_lines = hough_lines.astype(np.int32) # 转成1280*720的形式 is_draw = np.zeros((len(hough_lines)), dtype=np.uint8) last_draw_dx = 0 # 上一次画了HoughLine的哪一条线 last_draw_x_y = [hough_lines[0][0][2], hough_lines[0][0][3]] # 上一个HoughLine直线结束时的横纵坐标 # 3.turtle初始化 turtle.screensize(1280, 720) turtle.setup(1305, 745, startx=0, starty=0) turtle.pensize(2) turtle.pencolor('blue') turtle.speed(10) turtle.up() turtle.goto(hough_lines[0][0][0] - 640, 360 - hough_lines[0][0][1]) turtle.down() turtle.goto(hough_lines[0][0][2] - 640, 360 - hough_lines[0][0][3]) is_draw[0] = 1 # 4.用turtle画出hough变换的结果 while True: if all(is_draw): break next_draw_dx = None # 接下来应该画HoughLine的哪一条线 min_dist = np.inf # 这条线的起始点和上一条线的终点的距离 for line_it in range(len(hough_lines)): if not is_draw[line_it]: next_draw_x_y = [ hough_lines[line_it][0][0], hough_lines[line_it][0][1] ] dist = abs(next_draw_x_y[0] - last_draw_x_y[0]) + abs(next_draw_x_y[1] - last_draw_x_y[1]) if dist < min_dist: min_dist = dist next_draw_dx = line_it if min_dist == 0: turtle.goto(hough_lines[next_draw_dx][0][2] - 640, 360 - hough_lines[next_draw_dx][0][3]) is_draw[next_draw_dx] = 1 last_draw_dx = next_draw_dx # 上一次画了HoughLine的哪一条线 last_draw_x_y = [ hough_lines[next_draw_dx][0][2], hough_lines[next_draw_dx][0][3] ] # 上一个HoughLine直线结束时的横纵坐标 else: turtle.up() turtle.goto(hough_lines[next_draw_dx][0][0] - 640, 360 - hough_lines[next_draw_dx][0][1]) turtle.down() turtle.goto(hough_lines[next_draw_dx][0][2] - 640, 360 - hough_lines[next_draw_dx][0][3]) is_draw[next_draw_dx] = 1 last_draw_dx = next_draw_dx # 上一次画了HoughLine的哪一条线 last_draw_x_y = [ hough_lines[next_draw_dx][0][2], hough_lines[next_draw_dx][0][3] ] # 上一个HoughLine直线结束时的横纵坐标 turtle.hideturtle() time.sleep(110)
def resetAndGoTo(turtle, x, y): turtle.clear() turtle.up() turtle.goto(x, y) turtle.seth(0) turtle.down()
def line(a, b, x, y): import turtle turtle.up() turtle.goto(a, b) turtle.down() turtle.goto(x, y)
def triange(origin, size): calc = size / 2 turtle.up() turtle.goto(origin[0], origin[1] + calc) turtle.down()
def Skip(step): t.up() t.fd(step) t.down()
def draw_all(x, y, z, major, minor, angle, fill=[0, 0, 0], box=None, intensity=None, screen_radius=None): global ellipsePoints global drawStars global lowestApparentMag global totalIncidentIntensity global FLARE_POLY_POINTS mask = (z > 0) mask = np.logical_and(mask, np.isnan(major) == False) mask = np.logical_and(mask, np.abs(x) < screen_width() / 2 + major) mask = np.logical_and(mask, np.abs(y) < screen_height() / 2 + major) sort_mask = np.argsort(z)[::-1] mask = mask[sort_mask] sort_and_mask = sort_mask[mask] if box: if mask[box]: box_x = x[box] box_y = y[box] box_maj = major[box] # box_min = minor[box] else: box = None x = x[sort_and_mask] y = y[sort_and_mask] major = major[sort_and_mask] minor = minor[sort_and_mask] angle = angle[sort_and_mask] # mask_map = np.flatnonzero(mask) # Indexes of True's in mask if _is_array(fill): fill = fill[sort_and_mask] if SMART_DRAW: perimApprox = 2 * np.pi * np.sqrt((major**2 + minor**2) / 2) points = np.int32(perimApprox / SMART_DRAW_PARAMETER) else: points = np.full(len(x), ellipsePoints) points[points > MAX_POINTS] = MAX_POINTS flareWidth = 5 # So it doesn't break later, normally this is 0 centre_array = np.array([x, y]).transpose() if box: # box 'inner' radius, ie half the width of a side boxRadius = max(MIN_BOX_WIDTH, box_maj * 1.4 + flareWidth) / 2 turtle.up() turtle.pencolor([1, 1, 1]) turtle.goto(box_x - boxRadius, box_y - boxRadius) turtle.down() turtle.goto(box_x - boxRadius, box_y + boxRadius) turtle.goto(box_x + boxRadius, box_y + boxRadius) turtle.goto(box_x + boxRadius, box_y - boxRadius) turtle.goto(box_x - boxRadius, box_y - boxRadius) turtle.up() #Draw the box if flareWidth < 0: return False if False and (points > 2) and screen_radius: # screenRadius # Assuming that the angle puts the major axs through # the screen centre we can clip points that are outside # of the screen: centreRadius = (x**2 + y**2)**(1 / 2) X = centreRadius - screenRadius if (X <= -major or points < 10): # The whole ellipse is on screen. # or the thing is small anyway clipAngle = -np.pi / 2 elif (X >= major): # The whole ellipse is probably off the screen return else: # Do some quik mafs: Y = minor / major * sqrt(major**2 - X**2) cosTheta = Y / sqrt(X**2 + Y**2) clipAngle = -acos(cosTheta) # 'clipAngle' gives the angle from the minor axis # that the perimeter clips the screens radius # +np.pi/2 ==> the centre end of the perimeter is # just touching the screen radius # (so the whole thing is probably out of view) # -np.pi/2 ==> the outer end is just touching, # ie, almost all of it will be in view. turtle.up() if np.any(points > 2) or True: clipAngle = np.full(len(x), -np.pi / 2) # Shifts an xy pair relative to major-minor axes # to the x-y axes of the screen, returns the new xy pair relative # to the centre of the oval and the screen x-y plane def localShift(local_angle, index=slice(None)): # coordAngle -= pi locX = major[index] / 2 * np.cos(local_angle) locY = minor[index] / 2 * np.sin(local_angle) shiftX = locX * np.cos(angle[index] - np.pi) - locY * np.sin(angle[index] - np.pi) shiftY = locY * np.cos(angle[index] - np.pi) + locX * np.sin(angle[index] - np.pi) return np.array([shiftX, shiftY]).transpose() # onScreen = True # Drawn = False # draw between <angle> and <np.pi - angle> clipAngle = np.pi / 2 - clipAngle start = centre_array + localShift(clipAngle) ### NUMPY TAKING OVER FROM HERE # print(start) try: fill = fill.tolist() except: pass for j in range(len(x)): try: fill[0][0] except: fill_ = fill else: try: fill_ = fill[j] except: # print(fill) raise KeyError turtle.fillcolor(fill_) turtle.pencolor(fill_) s = start[j] c = centre_array[j] c_a = clipAngle[j] # print(s) turtle.goto(*s) start_i = 0 end_i = points[j] if end_i <= 2: turtle.dot(2) else: turtle.begin_fill() for i in range(start_i, end_i): tempAngle = 2 * ((end_i / 2) - i) / end_i * c_a point = c + localShift(tempAngle, j) turtle.goto(*point) turtle.end_fill() # Draw the oval # if not j % 10: # turtle.write(f'fill: {fill_}') turtle.up() # else: # turtle.up() # turtle.goto() return True
# Use the slope values to calculate the tangent tangent = (abs(slope1 - slope2)) / (1 + slope1 * slope2) # Take the inverse of the tangent to calculate the angle in radians, then convert to degrees angle_in_radians = math.atan(tangent) angle_in_degrees = (angle_in_radians) * 180 / math.pi strAngle = str(angle_in_degrees) + " degrees" # title for the display window turtle.title("Lines and Angles and all that Cool Stuff") turtle.up() # lift the pen up, no drawing turtle.goto(0, 0) turtle.down() # pen is down, drawing now # Draw the first line turtle.goto(0, 0) turtle.goto(x1, y1) # Draw the second line turtle.goto(x2, y2) # Write the angle measurement turtle.write(strAngle) # IMPORTANT, must do this to finish the drawing or you'll get an infinite loop # and you'll have to CTRL-ALT-DEL to close it! Blech! turtle.done()
def forward(self, distance): if self.style == 'normal': turtle.forward(distance) elif self.style == 'jitter': (x0, y0) = turtle.position() turtle.up() turtle.forward(distance) (xf, yf) = turtle.position() curwidth = turtle.width() jx = random.gauss(0, self.jitterSigma) jy = random.gauss(0, self.jitterSigma) kx = random.gauss(0, self.jitterSigma) ky = random.gauss(0, self.jitterSigma) curwidth += random.randint(0,2) turtle.goto(x0+jx, y0+jy) turtle.down() turtle.goto(xf+kx, yf+ky) turtle.up() turtle.goto(xf,yf) curwidth = turtle.width() turtle.down() elif self.style == 'jitter3': (x0, y0) = turtle.position() turtle.up() turtle.forward(distance) (xf, yf) = turtle.position() curwidth = turtle.width() jx = random.gauss(0, self.jitterSigma) jy = random.gauss(0, self.jitterSigma) kx = random.gauss(0, self.jitterSigma) ky = random.gauss(0, self.jitterSigma) lx = random.gauss(0, self.jitterSigma) ly = random.gauss(0, self.jitterSigma) mx = random.gauss(0, self.jitterSigma) my = random.gauss(0, self.jitterSigma) nx = random.gauss(0, self.jitterSigma) ny = random.gauss(0, self.jitterSigma) ox = random.gauss(0, self.jitterSigma) oy = random.gauss(0, self.jitterSigma) curwidth += random.randint(0,2) turtle.goto(x0+jx, y0+jy) turtle.down() turtle.goto(xf+kx, yf+ky) turtle.up() turtle.goto(x0+lx, y0+ly) turtle.down() turtle.goto(xf+mx, yf+my) turtle.up() turtle.goto(x0+nx, y0+ny) turtle.down() turtle.goto(xf+ox, yf+oy) curwidth = turtle.width() turtle.down() elif self.style == 'dotted': num_dots = int(distance/(self.dotSize*4)) (x0, y0) = turtle.position() turtle.up() turtle.forward(distance) (xf, yf) = turtle.position() curwidth = turtle.width() turtle.goto(x0, y0) for i in range(num_dots): turtle.down() turtle.circle(self.dotSize) turtle.up() turtle.forward(self.dotSize*4) turtle.goto(xf, yf) # EXTENSION 1 elif self.style == 'slash': num_slash = int(distance/10) (x0, y0) = turtle.position() turtle.up() turtle.forward(distance) (xf, yf) = turtle.position() curwidth = turtle.width() turtle.goto(x0, y0) for i in range(num_slash): turtle.left(45) turtle.forward(distance/25) turtle.up() turtle.right(180) turtle.down() turtle.forward(distance/25) turtle.up() turtle.right(225) turtle.forward(num_slash) turtle.down()
def drawString(self, dstring, distance, angle): stack = [] cstack = [] modstring = '' modval = None modgrab = False for c in dstring: if c == '(': modstring = '' modgrab = True continue elif c == ')': modval = float(modstring) modgrab = False continue elif modgrab: modstring += c continue elif c == 'F' or c == 'f': if modval == None: self.forward(distance) else: self.forward(distance*modval) elif c == '-': if modval == None: turtle.right(angle) else: turtle.right(modval) elif c == '+': if modval == None: turtle.left(angle) else: turtle.left(modval) elif c == '!': if modval == None: w = turtle.width() if w > 1: turtle.width(w-1) else: turtle.width(modval) elif c == '[': stack.append(turtle.position()) stack.append(turtle.heading()) elif c == ']': turtle.up() turtle.setheading(stack.pop()) turtle.goto(stack.pop()) turtle.down() elif c == 'L': #draws a leaf #begin and end fil calls work better in this section of code turtle.begin_fill() turtle.circle(5) turtle.end_fill() elif c == 'Q': #created for task3 #draws a flower pos = turtle.position() heading = turtle.heading() turtle.begin_fill() turtle.right(90) turtle.forward(5) turtle.left(120) turtle.forward(10) turtle.left(120) turtle.forward(10) turtle.left(120) turtle.forward(10) turtle.end_fill() turtle.up() turtle.goto(pos) turtle.setheading(heading) turtle.down() elif c == 'P': #draws a petal #CREATED FOR EXTENSION1 turtle.begin_fill() for i in range(12): turtle.forward(5) turtle.right(108) turtle.forward(5) turtle.left(144) turtle.end_fill() elif c == '<': color = turtle.color()[0] cstack.append(color) elif c == '>': turtle.color(cstack.pop()) elif c == 'g': #makes the leaf color medium orchid turtle.color("Medium Orchid") elif c == 'y': #makes the leaf color turquoise turtle.color("Turquoise") elif c == 'r': #makes the leaf color salmon turtle.color("Salmon") elif c == 'b': #CREATED FOR EXTENSION1 #makes the leaf color salmon turtle.color("Plum") elif c == 'o': #CREATED FOR EXTENSION1 #makes the leaf color salmon turtle.color("Khaki") elif c == '{': turtle.fill(True) elif c == '}': turtle.fill(False) modval = None turtle.update()
def place(self, xpos, ypos, angle=None): turtle.up() turtle.goto( xpos, ypos ) if angle != None: turtle.setheading(angle) turtle.down()
def goto(self, xpos, ypos): turtle.up() turtle.goto( xpos, ypos ) turtle.down()
def InterpretarString(iniciador,gerador,ae,ad,Lado,NG,randomL = 0,randomAn = 0): turtle.speed(0) tela = turtle.getscreen() tela.tracer(8,25) turtle.up() turtle.bk(100) turtle.down() expressao = ReescreverString(iniciador,gerador,NG) p,h = [0,0],0 ultimo = 0 stack = [] turtle.hideturtle() i = 0 while(i < len(expressao)): if(expressao[i].isalpha() and expressao[i] != 'f' and expressao[i] != 'b' and expressao[i] != 'S'): if(randomL > 0): LadoR = random.randint(int((Lado - (randomL * Lado)/100)),int((Lado + (randomL * Lado)/100))) turtle.fd(LadoR) else: turtle.fd(Lado) if(expressao[i] == 'f'): if(randomL > 0): LadoR = random.randint(int((Lado - (randomL * Lado)/100)),int((Lado + (randomL * Lado)/100))) turtle.up() turtle.fd(LadoR) turtle.down() else: turtle.up() turtle.fd(Lado) turtle.down() if(expressao[i] == 'S'): Lado = Lado/2 if(expressao[i] == 'b'): turtle.up() turtle.bk(100) turtle.down() if expressao[i] == '-': if(randomAn > 0): aeR = random.randint(int((ae - (randomAn * ae)/100)),int((ae + (randomAn * ae)/100))) turtle.left(aeR) else: turtle.left(ae) if(expressao[i] == '<'): turtle.left(90) if(expressao[i] == '>'): turtle.right(90) if(expressao[i] == '|'): turtle.left(180) if expressao[i] == '+': if(randomAn > 0): adR = random.randint(int((ad - (randomAn * ad)/100)),int((ad + (randomAn * ad)/100))) turtle.right(adR) else: turtle.right(ad) if expressao[i] == '[': p = turtle.position() h = turtle.heading() stack.insert(ultimo,(p,h,Lado)) ultimo+=1 if expressao[i] == ']': ultimo-=1 turtle.up() turtle.setposition(stack[ultimo][0][0],stack[ultimo][0][1]) turtle.setheading(stack[ultimo][1]) Lado = stack[ultimo][2] turtle.down() if(expressao[i] == '('): j = i ang = '' rotacao = '' while(expressao[j] != ')'): if(expressao[j] == '-'): rotacao = '-' elif(expressao[j] == '+'): rotacao = '+' elif(expressao[j].isdigit()): ang += expressao[j] j+=1 angInt = int(ang) if(rotacao == '-'): turtle.left(angInt) elif rotacao == '+': turtle.right(angInt) i = j i+=1 turtle.update()
# -*- coding: utf-8 -*- """ Created on Mon Oct 20 12:29:58 2014 @author: Yuanze LEO """ import turtle as tl import math tl.reset() tl.up() tl.pensize(1) a = math.pi x = -a*100 tl.goto(x,0) tl.down() tl.goto(-x,0) tl.stamp() tl.up() tl.left(90) tl.goto(0,x) tl.down() tl.goto(0,-x) tl.stamp() tl.penup() tl.pensize(3) tl.color('red') tl.goto(x,0) tl.pendown() n = 100 m = 10 i = 0
def kuai(): # 点 x1 = x + 280 y1 = y - 65 t1 = (x1, y1) t2 = (x1 - 6, y1 - 25) t.up() t.goto(t1) t.down() t.goto(t2) # 竖 x2 = x1 + 10 y2 = y - 15 t3 = (x2, y2) t4 = (x2, y2 - 130) t.up() t.goto(t3) t.down() t.goto(t4) # 点 x3 = x2 + 10 y3 = y1 - 8 t5 = (x3, y3) t6 = (x3 + 6, y3 - 10) t.up() t.goto(t5) t.down() t.goto(t6) # 横 x4 = x3 + 25 y4 = y - 60 t7 = (x4, y4) t8 = (x4 + 60, y4) t9 = (x4 + 60, y4 - 28) t.up() t.goto(t7) t.down() t.goto(t8) t.goto(t9) # 长横 x5 = x4 - 10 y5 = y4 - 28 t10 = (x5, y5) t11 = (x5 + 90, y5) t.up() t.goto(t10) t.down() t.goto(t11) # 撇 x6 = x4 + 30 y6 = y2 - 5 t12 = (x6, y6) t13 = (x6 - 18, y6 - 125) t.up() t.goto(t12) t.down() t.goto(t13) # 捺 x7 = x6 + 8 y7 = y5 - 20 t14 = (x7, y7) t15 = (x7 + 12, y7 - 38) t.up() t.goto(t14) t.down() t.goto(t15)
def txt(): t1 = (x, y) t2 = (x + 12, y - 12) # 点、 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()
def Go_to(x, y): turtle.up() turtle.goto(x, y) turtle.down()
def nian(): # 撇 x1 = x + 180 y1 = y - 10 t1 = (x1, y1) t2 = (x1 - 18, y1 - 28) t.up() t.goto(t1) t.down() t.goto(t2) # 横 x2 = x1 - 8 y2 = y - 25 t3 = (x2, y2) t4 = (x2 + 60, y2) t.up() t.goto(t3) t.down() t.goto(t4) # 横 x3 = x2 - 8 y3 = y - 65 t5 = (x3, y3) t6 = (x3 + 65, y3) t.up() t.goto(t5) t.down() t.goto(t6) # 小竖 x4 = x3 y4 = y3 - 25 t7 = (x4, y4) t.up() t.goto(t5) t.down() t.goto(t7) # 长横 x5 = x4 - 10 y5 = y4 t8 = (x5, y5) t9 = (x5 + 85, y5) t.up() t.goto(t8) t.down() t.goto(t9) # 长竖 x6 = x2 + 25 y6 = y2 t10 = (x6, y6) t11 = (x6, y6 - 120) t.up() t.goto(t10) t.down() t.goto(t11)
def cercle(position, rayon): init_geometrie() turtle.goto(position.x, position.y - rayon) turtle.down() turtle.circle(rayon)
def go_to(x=0, y=0): t.up() t.goto(x, y) t.down()
def Skib(x, y): t.up() t.goto(x, y) t.down()
def ligne(position1, position2): init_geometrie() turtle.goto(position1.x, position1.y) turtle.down() turtle.goto(position2.x, position2.y)
def ShowFrenselDraw():# Show Frensel Draw to U and I to RCL import turtle from turtle import forward, backward, up, down, left, right, width, color, write, reset, title from time import sleep global enter, Um, Im, Fi, rdFi, ZR, ZC, ZL, U, I, UR, UC, UL, fi, fiward U = Um/2 print(U) I = Im print(I) UR = (ZR*Im)/2 print(UR) UC = (ZC*Im)/2 print(UC) UL = (ZL*Im)/2 print(UL) fi = Fi print(fi) fiward = int(fi) print(fiward) title('Frensel Draw') reset() width(5) if(enter == "None"): print("None") I = I/2 up() backward(I) down() # I color('black') forward(I) write('I') forward(I) sleep(1) up() backward(I*2) down() # fi left(fi) # U color('green') forward(U*2) write('U') sleep(1) up() backward(U*2) right(fi) forward(I+I/2) down() # Fi color('red') if(fi>0):left(90) elif(fi<0):right(90) i = 0 if(fiward>0):fiward = fiward*1 elif(fiward<0):fiward = fiward*(-1) while(i<fiward): i = i+1 if(fi>0): forward(2) left(1) elif(fi<0): forward(2) right(1) if(i == fiward):write(' Fi') elif(enter == "RCL"): print("RCL") up() backward(UR) down() # I color('black') forward(I) write('I') sleep(1) up() backward(I) down() # fi left(fi) # U color('green') forward(U*2) write('U') sleep(1) up() backward(U*2) down() # UR width(2.5) color('red') right(fi) # Fi forward(UR) write(' UR') forward(UR) sleep(1) # UL color('blue') left(90) forward(UL) write(' UL') forward(UL) up() left(-90) forward(1.5) down() # UC sleep(1) color('dark red') left(-90) forward(UC) write(' UC') forward(UC) sleep(1) up() backward(UC*2) right(90) backward(2) right(90) backward(UL*2) right(90) backward(UR+UR/2) down() # Fi color('black') if(fi>0):left(90) elif(fi<0):right(90) i = 0 if(fiward>0):fiward = fiward*1 elif(fiward<0):fiward = fiward*(-1) while(i<fiward): i = i+1 if(fi>0): forward(1) left(1) elif(fi<0): forward(1) right(1) if(i == fiward):write(' Fi') elif(enter == "RC"): print("RC") up() backward(UR) down() # I color('black') forward(I) write('I') sleep(1) up() backward(I) down() # fi left(fi) # U color('green') forward(U*2) write('U') sleep(1) up() backward(U*2) down() # UR width(2.5) color('red') right(fi) # Fi forward(UR) write(' UR') forward(UR) sleep(1) # UC color('dark red') left(-90) forward(UC) write(' UC') forward(UC) sleep(1) up() backward(UC*2) left(90) backward(UR) down() # Fi color('black') if(fi>0):left(90) elif(fi<0):right(90) i = 0 if(fiward>0):fiward = fiward*1 elif(fiward<0):fiward = fiward*(-1) while(i<fiward): i = i+1 if(fi>0): forward(2) left(1) elif(fi<0): forward(2) right(1) if(i == fiward):write(' Fi') elif(enter == "RL"): print("RL") up() backward(UR) down() # I color('black') forward(I) sleep(1) up() backward(I) down() # Fi left(fi) color('green') forward(U*2) write('U') sleep(1) up() backward(U*2) down() # UR width(2.5) color('red') right(fi) # Fi forward(UR) write(' UR') forward(UR) sleep(1) # UL color('blue') left(90) forward(UL) write(' UL') forward(UL) up() backward(UL*2) right(90) backward(UR) down() # Fi color('black') if(fi>0):left(90) elif(fi<0):right(90) i = 0 if(fiward>0):fiward = fiward*1 elif(fiward<0):fiward = fiward*(-1) while(i<fiward): i = i+1 if(fi>0): forward(2) left(1) elif(fi<0): forward(2) right(1) if(i == fiward):write(' Fi') elif(enter == "CL"): up() backward(I/2) down() # I color('black') forward(I) write('I') up() backward(I) sleep(1) left(fi) # Fi down() # U color('green') forward(U) write('U') forward(U) sleep(1) up() backward(U*2) down() right(fi)# -Fi left(90) width(2.5) # UL color('blue') forward(UL) write(' UL') forward(UL) sleep(1) up() left(-90) forward(1.5) left(-90) down() # UC color('dark red') forward(UC) write(' UC') forward(UC) sleep(1) elif(enter == "R"): up() backward(U) down() # I color('black') forward(I) write('I') sleep(1) up() backward(I) down() # U color('green') forward(U*2) write('U') sleep(1) up() backward(U*2) down() # UR color('red') forward(UR) write('UR') forward(UR) up() backward(UR) elif(enter == "C"): up() backward(I/2) down() # I color('black') forward(I) write('I') sleep(1) up() backward(I) left(fi) down() # U color('green') forward(U*2) write('U') sleep(1) up() backward(U*2) down() # UC color('dark red') forward(UC) write('UC') forward(UC) elif(enter == "L"): up() backward(I/2) down() # I color('black') forward(I) write('I') sleep(1) up() backward(I) left(fi) down() # U color('green') forward(U*2) write(' U') sleep(1) up() backward(U*2) down() # UL color('blue') forward(UL) write(' UL') forward(UL)
import turtle as t def polygon(n): for x in range(n): t.forward(50) t.left(360 / n) def polygon2(n, a): for x in range(n): t.forward(a) t.left(360 / n) polygon(3) # 삼각형을 그립니다. polygon(5) # 오각형을 그립니다. # 그림을 그리지 않고 거북이를 100만큼 이동합니다. t.up() # 꼬리를 올림 t.forward(100) # 앞으로 100 t.down() # 꼬리를 내림 polygon2(3, 75) # 한 변이 75인 삼각형을 그립니다. polygon2(5, 100) # 한 변이 100인 오각형을 그립니다.
def main(argv): # check if there are enough arguments if len(argv) < 10: print "Usage : python abstract.py 3*<in_filename> 3*<num_iterations>" exit() # assign lsys_filenames to command line filename arguments lsys_filename1 = argv[1] lsys_filename2 = argv[2] lsys_filename3 = argv[3] # create the lsystems from a file lsys1 = ls.createLsystemFromFile(lsys_filename1) lsys2 = ls.createLsystemFromFile(lsys_filename2) lsys3 = ls.createLsystemFromFile(lsys_filename3) print lsys1 print lsys2 print lsys3 # assign num_interations to command line number arguments num_iter1 = int(argv[4]) num_iter2 = int(argv[5]) num_iter3 = int(argv[6]) # build the lsystem string with given number of iterations s1 = ls.buildString(lsys1, num_iter1) s2 = ls.buildString(lsys2, num_iter2) s3 = ls.buildString(lsys3, num_iter3) print s1 print s2 print s3 # assign distances and angles to given command line inputs dist = float(argv[7]) angle1 = float(argv[8]) angle2 = float(argv[9]) angle3 = float(argv[10]) # draw the lsystems #draw lsystem1 '''this is my first lsystem with filename mysystem1.txt with 3 iterations and with angle = 45 dist = 10''' turtle.tracer(False) turtle.up() turtle.goto(-400, 0) turtle.down() turtle.left(90) turtle.pencolor('Green') it.drawString(s1, dist, angle1) #draw lsystem2 '''this is my second lsystem with filename mysystem2.txt with 5 iterations and with angle = 120 dist = 10''' turtle.up() turtle.goto(0, 0) turtle.goto(0, 0) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Red') it.drawString(s2, dist, angle2) #draw lsystem3 '''this is my third lsystem with filename mysystem3.txt with 3 iterations and with angle = 45 dist = 10''' turtle.up() turtle.goto(0, 0) turtle.goto(300, -100) turtle.down() turtle.setheading(0) turtle.left(90) turtle.pencolor('Blue') it.drawString(s3, dist, angle3) # wait and update turtle.update() it.hold()
def __move_pen(self,x,y): turtle.up() turtle.goto(x,y) turtle.down()
def setWidow() : turtle.penup() turtle.setposition(-250, -200) turtle.down()
def DrawAxes(): t.ht() t.color("white") t.rt(90) t.fd(10) t.up() t.fd(20) t.lt(90) t.down() t.write("1960", False, align="center") t.up() t.rt(90) t.bk(20) t.down() t.bk(10) t.lt(90) t.fd(400) t.rt(90) t.fd(10) t.up() t.fd(20) t.lt(90) t.down() t.write("2015", False, align="center") t.up() t.rt(90) t.bk(20) t.down() t.bk(10) t.lt(90) t.bk(200) t.up() t.rt(90) t.fd(25) t.lt(90) t.down() t.write("Year", False, align="center") t.up() t.lt(90) t.fd(25) t.rt(90) t.down() t.bk(200) t.bk(10) t.up() t.bk(20) t.down() t.write("0", False, align="center") t.up() t.fd(20) t.down() t.fd(10) t.lt(90) t.fd(200) t.lt(90) t.up() t.fd(25) t.down() t.write("Life\nExp.", False, align="center") t.up() t.bk(25) t.rt(90) t.down() t.fd(200) t.lt(90) t.fd(10) t.up() t.fd(20) t.down() t.rt(180) t.write("100", False, align="center") t.up() t.fd(20) t.fd(10) t.rt(90) t.fd(400) t.lt(90) t.update()