def main(x1, y1, x2, y2, x3, y3, xt, yt, xf, yf, d, xs, ys): points = [] temp = one_color.struc() line1 = translation.main(x1, y1, x2, y2, xt, yt) line2 = translation.main(x2, y2, x3, y3, xt, yt) line3 = translation.main(x3, y3, x1, y1, xt, yt) line1 = rotation.main(line1[0].x, line1[0].y, line1[1].x, line1[1].y, xf, yf, d) line2 = rotation.main(line2[0].x, line2[0].y, line2[1].x, line2[1].y, xf, yf, d) line3 = rotation.main(line3[0].x, line3[0].y, line3[1].x, line3[1].y, xf, yf, d) line1 = scale.main(line1[0].x, line1[0].y, line1[1].x, line1[1].y, xf, yf, xs, ys) line2 = scale.main(line2[0].x, line2[0].y, line2[1].x, line2[1].y, xf, yf, xs, ys) line3 = scale.main(line3[0].x, line3[0].y, line3[1].x, line3[1].y, xf, yf, xs, ys) line = draw_polygon.main(line1[0].x, line1[0].y, line2[0].x, line2[0].y, line3[0].x, line3[0].y) return line
def main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt, xTrans, yTrans, xs, ys, d): line1 = translation.main(x1, y1, x2, y2, xTrans, yTrans) line2 = translation.main(x2, y2, x3, y3, xTrans, yTrans) line3 = translation.main(x3, y3, x4, y4, xTrans, yTrans) line4 = translation.main(x4, y4, x5, y5, xTrans, yTrans) line5 = translation.main(x5, y5, x1, y1, xTrans, yTrans) x1 = line1[0].x y1 = line1[0].y x2 = line2[0].x y2 = line2[0].y x3 = line3[0].x y3 = line3[0].y x4 = line4[0].x y4 = line4[0].y x5 = line5[0].x y5 = line5[0].y line1 = scale.main(x1, y1, x2, y2, xt, yt, xs, ys) line2 = scale.main(x2, y2, x3, y3, xt, yt, xs, ys) line3 = scale.main(x3, y3, x4, y4, xt, yt, xs, ys) line4 = scale.main(x4, y4, x5, y5, xt, yt, xs, ys) line5 = scale.main(x5, y5, x1, y1, xt, yt, xs, ys) x1 = line1[0].x y1 = line1[0].y x2 = line2[0].x y2 = line2[0].y x3 = line3[0].x y3 = line3[0].y x4 = line4[0].x y4 = line4[0].y x5 = line5[0].x y5 = line5[0].y line1 = rotation.main(x1, y1, x2, y2, xt, yt, d) line2 = rotation.main(x2, y2, x3, y3, xt, yt, d) line3 = rotation.main(x3, y3, x4, y4, xt, yt, d) line4 = rotation.main(x4, y4, x5, y5, xt, yt, d) line5 = rotation.main(x5, y5, x1, y1, xt, yt, d) x1 = line1[0].x y1 = line1[0].y x2 = line2[0].x y2 = line2[0].y x3 = line3[0].x y3 = line3[0].y x4 = line4[0].x y4 = line4[0].y x5 = line5[0].x y5 = line5[0].y line = draw_polygon.main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5) return line
def main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt, xTrans, yTrans, xs, ys, d ): line1 = translation.main( x1, y1, x2, y2, xTrans, yTrans ) line2 = translation.main( x2, y2, x3, y3, xTrans, yTrans ) line3 = translation.main( x3, y3, x4, y4, xTrans, yTrans ) line4 = translation.main( x4, y4, x5, y5, xTrans, yTrans ) line5 = translation.main( x5, y5, x1, y1, xTrans, yTrans ) x1 = line1[ 0 ].x y1 = line1[ 0 ].y x2 = line2[ 0 ].x y2 = line2[ 0 ].y x3 = line3[ 0 ].x y3 = line3[ 0 ].y x4 = line4[ 0 ].x y4 = line4[ 0 ].y x5 = line5[ 0 ].x y5 = line5[ 0 ].y line1 = scale.main( x1, y1, x2, y2, xt, yt, xs, ys ) line2 = scale.main( x2, y2, x3, y3, xt, yt, xs, ys ) line3 = scale.main( x3, y3, x4, y4, xt, yt, xs, ys ) line4 = scale.main( x4, y4, x5, y5, xt, yt, xs, ys ) line5 = scale.main( x5, y5, x1, y1, xt, yt, xs, ys ) x1 = line1[ 0 ].x y1 = line1[ 0 ].y x2 = line2[ 0 ].x y2 = line2[ 0 ].y x3 = line3[ 0 ].x y3 = line3[ 0 ].y x4 = line4[ 0 ].x y4 = line4[ 0 ].y x5 = line5[ 0 ].x y5 = line5[ 0 ].y line1 = rotation.main( x1, y1, x2, y2, xt, yt, d ) line2 = rotation.main( x2, y2, x3, y3, xt, yt, d ) line3 = rotation.main( x3, y3, x4, y4, xt, yt, d ) line4 = rotation.main( x4, y4, x5, y5, xt, yt, d ) line5 = rotation.main( x5, y5, x1, y1, xt, yt, d ) x1 = line1[ 0 ].x y1 = line1[ 0 ].y x2 = line2[ 0 ].x y2 = line2[ 0 ].y x3 = line3[ 0 ].x y3 = line3[ 0 ].y x4 = line4[ 0 ].x y4 = line4[ 0 ].y x5 = line5[ 0 ].x y5 = line5[ 0 ].y line = draw_polygon.main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5 ) return line
def Polygon( boardsize_x, boardsize_y ): print ('Starting') image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 ) poly = draw_polygon.main( 60, 120, 110, 200, 110, 150, 200, 220, 160, 120 ) image = add_to_image.main( image, poly, 255, 0, 255 ) write_ppm.main( image, 'test' ) print ('Finish')
def Polygon(boardsize_x, boardsize_y): print('Starting') image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245) poly = draw_polygon.main(60, 120, 110, 200, 110, 150, 200, 220, 160, 120) image = add_to_image.main(image, poly, 255, 0, 255) write_ppm.main(image, 'test') print('Finish')
def FillPolygon2( boardsize_x, boardsize_y ): print ('Starting') image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 ) fill = fill_polygon2.main( 10, 10, 100, 10, 100, 300, 10, 150, 80, 150, 80, 50, 20, 50, 20, 100, 10, 100 ) image = add_to_image.main( image, fill, 255, 0, 255 ) border = draw_polygon.main( 10, 10, 100, 10, 100, 300, 10, 150, 80, 150, 80, 50, 20, 50, 20, 100, 10, 100 ) image = add_to_image.main( image, border, 0 , 0, 0 ) write_ppm.main( image, 'test' ) print ('Finish')
def Polygon( boardsize_x, boardsize_y ): print ('Starting') image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 ) poly = fill_polygon.main( 10, 10, 100, 10, 100, 300, 10, 150, 80, 150, 80, 50, 20, 50, 20, 100, 10, 100 ) border = draw_polygon.main( 10, 10, 100, 10, 100, 300, 10, 150, 80, 150, 80, 50, 20, 50, 20, 100, 10, 100 ) image = add_to_image.main( image, poly, 255, 0, 255 ) image = add_to_image.main( image, border, 0, 0, 0 ) write_ppm.main( image, 'test' ) print ('Finish')
def main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt ): line1 = translation.main( x1, y1, x2, y2, xt, yt ) line2 = translation.main( x2, y2, x3, y3, xt, yt ) line3 = translation.main( x3, y3, x4, y4, xt, yt ) line4 = translation.main( x4, y4, x5, y5, xt, yt ) line5 = translation.main( x5, y5, x1, y1, xt, yt ) x1 = line1[ 0 ].x y1 = line1[ 0 ].y x2 = line2[ 0 ].x y2 = line2[ 0 ].y x3 = line3[ 0 ].x y3 = line3[ 0 ].y x4 = line4[ 0 ].x y4 = line4[ 0 ].y x5 = line5[ 0 ].x y5 = line5[ 0 ].y line = draw_polygon.main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5 ) return line
def main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt): line1 = translation.main(x1, y1, x2, y2, xt, yt) line2 = translation.main(x2, y2, x3, y3, xt, yt) line3 = translation.main(x3, y3, x4, y4, xt, yt) line4 = translation.main(x4, y4, x5, y5, xt, yt) line5 = translation.main(x5, y5, x1, y1, xt, yt) x1 = line1[0].x y1 = line1[0].y x2 = line2[0].x y2 = line2[0].y x3 = line3[0].x y3 = line3[0].y x4 = line4[0].x y4 = line4[0].y x5 = line5[0].x y5 = line5[0].y line = draw_polygon.main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5) return line
def StickFigure( boardsize_x, boardsize_y ): print ('Starting') image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 ) head = draw_circle.main( 160, 200, 20 ) headFill = fill_circle.main( 160, 200, 20 ) neck = draw_line.main( 160, 180, 160, 170 ) body = draw_polygon.main( 130, 170, 190, 170, 190, 110, 130, 110 ) bodyFill = fill_polygon.main( 130, 170, 190, 170, 190, 110, 130, 110 ) rArm = draw_line.main( 130, 170, 100, 100 ) lArm = draw_line.main( 190, 170, 220, 100 ) rHand = draw_circle.main( 100, 100, 10 ) lHand = draw_circle.main( 220, 100, 10 ) rHandFill = fill_circle.main( 100, 100, 10 ) lHandFill = fill_circle.main( 220, 100, 10 ) rLeg = draw_line.main( 140, 110, 120, 50 ) lLeg = draw_line.main( 180, 110, 200, 50 ) rFoot = draw_ellipse.main( 120, 50, 20, 5 ) lFoot = draw_ellipse.main( 200, 50, 20, 5 ) rFootFill = fill_ellipse.main( 120, 50, 20, 5 ) lFootFill = fill_ellipse.main( 200, 50, 20, 5 ) #Translate, Rotate, and Scale Flag/Pole pole = pole_composition.main( 100, 125, 100, 50, 0, 35, 100, 100, 45, 1.25, 1.25 ) flagFill = flagFill_composition.main( 100, 125, 100, 95, 60, 110, 0, 35, 100, 100, 45, 1.25, 1.25 ) flag = flag_composition.main( 100, 125, 100, 95, 60, 110, 0, 35, 100, 100, 45, 1.25, 1.25 ) #Start adding pixels to fill image = add_to_image.main( image, headFill, 255, 255, 0 ) image = add_to_image.main( image, head, 0, 0, 0 ) image = add_to_image.main( image, neck, 0, 0, 0 ) image = add_to_image.main( image, bodyFill, 0, 0, 255 ) image = add_to_image.main( image, body, 255, 0, 0 ) image = add_to_image.main( image, rArm, 0, 0, 0 ) image = add_to_image.main( image, lArm, 0, 0, 0 ) image = add_to_image.main( image, rHandFill, 255, 0, 0 ) image = add_to_image.main( image, lHandFill, 255, 0, 0 ) image = add_to_image.main( image, rHand, 0, 255, 0 ) image = add_to_image.main( image, lHand, 0, 255, 0 ) image = add_to_image.main( image, rLeg, 0, 0, 0 ) image = add_to_image.main( image, lLeg, 0, 0, 0 ) image = add_to_image.main( image, rFootFill, 0, 255, 0 ) image = add_to_image.main( image, lFootFill, 0, 255, 0 ) image = add_to_image.main( image, rFoot, 0, 0, 255 ) image = add_to_image.main( image, lFoot, 0, 0, 255 ) image = add_to_image.main( image, pole, 0, 0, 0 ) image = add_to_image.main( image, flagFill, 255, 0 , 255 ) image = add_to_image.main( image, flag, 0, 0, 0 ) write_ppm.main( image, 'amos' ) print ('Finish')
def main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9): temp = one_color.struc() points = [copy.deepcopy(one_color.struc)] fillpoints = [copy.deepcopy(one_color.struc)] del points[0] del fillpoints[0] #Get all the points in an edge line1 = [x1, y1, x2, y2] line2 = [x2, y2, x3, y3] line3 = [x3, y3, x4, y4] line4 = [x4, y4, x5, y5] line5 = [x5, y5, x6, y6] line6 = [x6, y6, x7, y7] line7 = [x7, y7, x8, y8] line8 = [x8, y8, x9, y9] line9 = [x9, y9, x1, y1] border = draw_polygon.main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9) length = len(border) #find the smallest and largest y values #will be used as the limit of scan line minY = border[0].y maxY = border[0].y for i in range(length): if border[i].y < minY: minY = border[i].y elif border[i].y > maxY: maxY = border[i].y #end of if-else statement #end of i for loop print('Found scan borders') print('minY = ', minY) print('maxY = ', maxY) #Find all the intersection points in the edges #with the scan line scan = minY + 1 while scan < maxY: point1 = scan_line.main(line1, scan) point2 = scan_line.main(line2, scan) point3 = scan_line.main(line3, scan) point4 = scan_line.main(line4, scan) point5 = scan_line.main(line5, scan) point6 = scan_line.main(line6, scan) point7 = scan_line.main(line7, scan) point8 = scan_line.main(line8, scan) point9 = scan_line.main(line9, scan) if len(point1) == 0: pass else: points = points + point1 if len(point2) == 0: pass else: points = points + point2 if len(point3) == 0: pass else: points = points + point3 if len(point4) == 0: pass else: points = points + point4 if len(point5) == 0: pass else: points = points + point5 if len(point6) == 0: pass else: points = points + point6 if len(point7) == 0: pass else: points = points + point7 if len(point8) == 0: pass else: points = points + point8 if len(point9) == 0: pass else: points = points + point9 #Begin of sort length = len(points) print(length) done = False head = 0 tail = 1 while done == True: check = 0 if check == length - 1: done = False if tail >= length: head = 0 tail = 1 if points[head].x > points[tail].x: temp = points[tail] points[tail] = points[head] points[head] = temp head = head + 1 tail = tail + 1 else: head = head + 1 tail = tail + 1 check = check + 1 #End of while loop #Get pairs of points that need to be filled head = 0 tail = 1 while head < length - 1: fill = draw_line.main(points[head].x, points[head].y, points[tail].x, points[tail].y) fillpoints = fillpoints + fill #end of i for loop head = head + 2 tail = tail + 2 del points[:] scan = scan + 1 #add border points return fillpoints
def main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9 ): temp = one_color.struc() points = [ copy.deepcopy( one_color.struc ) ] fillpoints = [ copy.deepcopy( one_color.struc ) ] del points[ 0 ] del fillpoints[ 0 ] #Get all the points in an edge line1 = [ x1, y1, x2, y2 ] line2 = [ x2, y2, x3, y3 ] line3 = [ x3, y3, x4, y4 ] line4 = [ x4, y4, x5, y5 ] line5 = [ x5, y5, x6, y6 ] line6 = [ x6, y6, x7, y7 ] line7 = [ x7, y7, x8, y8 ] line8 = [ x8, y8, x9, y9 ] line9 = [ x9, y9, x1, y1 ] border = draw_polygon.main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9 ) length = len( border ) #find the smallest and largest y values #will be used as the limit of scan line minY = border[ 0 ].y maxY = border[ 0 ].y for i in range( length ): if border[ i ].y < minY: minY = border[ i ].y elif border[ i ].y > maxY: maxY = border[ i ].y #end of if-else statement #end of i for loop print( 'Found scan borders' ) print( 'minY = ', minY ) print( 'maxY = ', maxY ) #Find all the intersection points in the edges #with the scan line scan = minY + 1 while scan < maxY: point1 = scan_line.main( line1, scan ) point2 = scan_line.main( line2, scan ) point3 = scan_line.main( line3, scan ) point4 = scan_line.main( line4, scan ) point5 = scan_line.main( line5, scan ) point6 = scan_line.main( line6, scan ) point7 = scan_line.main( line7, scan ) point8 = scan_line.main( line8, scan ) point9 = scan_line.main( line9, scan ) if len( point1 ) == 0: pass else: points = points + point1 if len( point2 ) == 0: pass else: points = points + point2 if len( point3 ) == 0: pass else: points = points + point3 if len( point4 ) == 0: pass else: points = points + point4 if len( point5 ) == 0: pass else: points = points + point5 if len( point6 ) == 0: pass else: points = points + point6 if len( point7 ) == 0: pass else: points = points + point7 if len( point8 ) == 0: pass else: points = points + point8 if len( point9 ) == 0: pass else: points = points + point9 #Begin of sort length = len( points ) print( length ) done = False head = 0 tail = 1 while done == True: check = 0 if check == length - 1: done = False if tail >= length: head = 0 tail = 1 if points[ head ].x > points[ tail ].x: temp = points[ tail ] points[ tail ] = points[ head ] points[ head ] = temp head = head + 1 tail = tail + 1 else: head = head + 1 tail = tail + 1 check = check + 1 #End of while loop #Get pairs of points that need to be filled head = 0 tail = 1 while head < length - 1: fill = draw_line.main( points[ head ].x, points[ head ].y, points[ tail ].x, points[ tail ].y ) fillpoints = fillpoints + fill #end of i for loop head = head + 2 tail = tail + 2 del points[ : ] scan = scan + 1 #add border points return fillpoints
def StickFigure(boardsize_x, boardsize_y): print('Starting') image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245) head = draw_circle.main(160, 200, 20) headFill = fill_circle.main(160, 200, 20) neck = draw_line.main(160, 180, 160, 170) body = draw_polygon.main(130, 170, 190, 170, 190, 110, 130, 110) bodyFill = fill_polygon.main(130, 170, 190, 170, 190, 110, 130, 110) rArm = draw_line.main(130, 170, 100, 100) lArm = draw_line.main(190, 170, 220, 100) rHand = draw_circle.main(100, 100, 10) lHand = draw_circle.main(220, 100, 10) rHandFill = fill_circle.main(100, 100, 10) lHandFill = fill_circle.main(220, 100, 10) rLeg = draw_line.main(140, 110, 120, 50) lLeg = draw_line.main(180, 110, 200, 50) rFoot = draw_ellipse.main(120, 50, 20, 5) lFoot = draw_ellipse.main(200, 50, 20, 5) rFootFill = fill_ellipse.main(120, 50, 20, 5) lFootFill = fill_ellipse.main(200, 50, 20, 5) #Translate, Rotate, and Scale Flag/Pole pole = pole_composition.main(100, 125, 100, 50, 0, 35, 100, 100, 45, 1.25, 1.25) flagFill = flagFill_composition.main(100, 125, 100, 95, 60, 110, 0, 35, 100, 100, 45, 1.25, 1.25) flag = flag_composition.main(100, 125, 100, 95, 60, 110, 0, 35, 100, 100, 45, 1.25, 1.25) #Start adding pixels to fill image = add_to_image.main(image, headFill, 255, 255, 0) image = add_to_image.main(image, head, 0, 0, 0) image = add_to_image.main(image, neck, 0, 0, 0) image = add_to_image.main(image, bodyFill, 0, 0, 255) image = add_to_image.main(image, body, 255, 0, 0) image = add_to_image.main(image, rArm, 0, 0, 0) image = add_to_image.main(image, lArm, 0, 0, 0) image = add_to_image.main(image, rHandFill, 255, 0, 0) image = add_to_image.main(image, lHandFill, 255, 0, 0) image = add_to_image.main(image, rHand, 0, 255, 0) image = add_to_image.main(image, lHand, 0, 255, 0) image = add_to_image.main(image, rLeg, 0, 0, 0) image = add_to_image.main(image, lLeg, 0, 0, 0) image = add_to_image.main(image, rFootFill, 0, 255, 0) image = add_to_image.main(image, lFootFill, 0, 255, 0) image = add_to_image.main(image, rFoot, 0, 0, 255) image = add_to_image.main(image, lFoot, 0, 0, 255) image = add_to_image.main(image, pole, 0, 0, 0) image = add_to_image.main(image, flagFill, 255, 0, 255) image = add_to_image.main(image, flag, 0, 0, 0) write_ppm.main(image, 'amos') print('Finish')