def main(*args): temp = one_color.struc() points = [copy.deepcopy(one_color.struc)] length = len(args) for x1 in range(0, length - 3, 2): y1 = x1 + 1 x2 = y1 + 1 y2 = x2 + 1 line = draw_line.main(args[x1], args[y1], args[x2], args[y2]) length2 = len(line) for i in range(length2): temp.x = line[i].x temp.y = line[i].y points.append(copy.deepcopy(temp)) line = draw_line.main(args[length - 2], args[length - 1], args[0], args[1]) length2 = len(line) for i in range(length2): temp.x = line[i].x temp.y = line[i].y points.append(copy.deepcopy(temp)) del points[0] return points
def main( *args ): temp = one_color.struc() points = [ copy.deepcopy( one_color.struc ) ] length = len( args ) for x1 in range( 0, length - 3, 2 ): y1 = x1 + 1 x2 = y1 + 1 y2 = x2 + 1 line = draw_line.main( args[ x1 ], args[ y1 ], args[ x2 ], args[ y2 ] ) length2 = len( line ) for i in range( length2 ): temp.x = line[ i ].x temp.y = line[ i ].y points.append( copy.deepcopy( temp ) ) line = draw_line.main( args[ length - 2 ], args[ length - 1 ], args[ 0 ], args[ 1 ] ) length2 = len( line ) for i in range( length2 ): temp.x = line[ i ].x temp.y = line[ i ].y points.append( copy.deepcopy( temp ) ) del points[ 0 ] return points
def Line(boardsize_x, boardsize_y, x1, y1, x2, y2, xx1, yy1, xx2, yy2): print('Starting') image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245) redline = draw_line.main(x1, y1, x2, y2) greenline = draw_line.main(xx1, yy1, xx2, yy2) image = add_to_image.main(image, redline, 255, 0, 0) image = add_to_image.main(image, greenline, 0, 255, 0) write_ppm.main(image, 'test') print('Finish')
def Line( boardsize_x, boardsize_y, x1, y1, x2, y2, xx1, yy1, xx2, yy2 ): print ('Starting') image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 ) redline = draw_line.main( x1, y1, x2, y2 ) greenline = draw_line.main( xx1, yy1, xx2, yy2 ) image = add_to_image.main( image, redline, 255, 0, 0 ) image = add_to_image.main( image, greenline, 0, 255, 0 ) write_ppm.main( image, 'test' ) print ('Finish')
def Scale( boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, xt, yt, xs, ys ): print ('Starting') image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 ) redPoints = scale.main( x1, y1, x2, y2, xt, yt, xs, ys ) greenPoints = scale.main( x3, y3, x4, y4, xt, yt, xs, ys ) redLine = draw_line.main( redPoints[ 0 ].x, redPoints[ 0 ].y, redPoints[ 1 ].x, redPoints[ 1 ].y ) greenLine = draw_line.main( greenPoints[ 0 ].x, greenPoints[ 0 ].y, greenPoints[ 1 ].x, greenPoints[ 1 ].y ) image = add_to_image.main( image, redLine, 255, 0, 0 ) image = add_to_image.main( image, greenLine, 0, 255, 0 ) write_ppm.main( image, 'test' ) print ('Finish')
def main( x, y, r ): border = draw_circle.main( x, y, r ) temp = one_color.struc() points = [ copy.deepcopy( one_color.struc ) ] length = len( border ) for i in range( length - 1 ): for t in range( 1, length ): if border[ i ].y == border[ t ].y: fill = draw_line.main( border[ i ].x, border[ i ].y, border[ t ].x, border[ t ].y ) length2 = len( fill ) for e in range( length2 ): temp.x = fill[ e ].x temp.y = fill[ e ].y points.append( copy.deepcopy( temp ) ) #end e for loop #end of if-else statement #end of t for loop #end of i for loop del points[ 0 ] return points
def main(d, xl, yl, sf, args): display = [] transP = [] scaleP = [] temp = one_color.struc() #get projection points line = projection.main(d, args) length = len(line) #Find center point and max values xMax = line[0].x xMin = line[0].x yMax = line[0].y yMin = line[0].y for i in range(length): if line[i].x > xMax: xMax = line[i].x if line[i].x < xMin: xMin = line[i].x if line[i].y > yMax: yMax = line[i].y if line[i].x < xMin: yMin = line[i].y xc = (xMax + xMin) / 2 yc = (yMax + yMin) / 2 #Find translation amount based on center xt = xl - xc yt = yl - yc #Composite #translate, scale, and draw a line based on the points found for i in range(0, len(line) - 1, 2): point = translation.main(line[i].x, line[i].y, line[i + 1].x, line[i + 1].y, xt, yt) for i in range(len(point)): temp.x = point[i].x temp.y = point[i].y transP.append(copy.deepcopy(temp)) for i in range(0, len(transP) - 1, 2): point = scale.main(transP[i].x, transP[i].y, transP[i + 1].x, transP[i + 1].y, xl, yl, sf, sf) for i in range(len(point)): temp.x = point[i].x temp.y = point[i].y scaleP.append(copy.deepcopy(temp)) for i in range(0, len(scaleP) - 1, 2): point = draw_line.main(scaleP[i].x, scaleP[i].y, scaleP[i + 1].x, scaleP[i + 1].y) for i in range(len(point)): temp.x = point[i].x temp.y = point[i].y display.append(copy.deepcopy(temp)) return display
def Rotate(boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, xf, yf, d): print('Starting') image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245) redPoints = rotation.main(x1, y1, x2, y2, xf, yf, d) greenPoints = rotation.main(x3, y3, x4, y4, xf, yf, d) redLine = draw_line.main(redPoints[0].x, redPoints[0].y, redPoints[1].x, redPoints[1].y) greenLine = draw_line.main(greenPoints[0].x, greenPoints[0].y, greenPoints[1].x, greenPoints[1].y) image = add_to_image.main(image, redLine, 255, 0, 0) image = add_to_image.main(image, greenLine, 0, 255, 0) write_ppm.main(image, 'test') print('Finish')
def main(x1, y1, x2, y2, xt, yt, xf, yf, d, xs, ys): line = translation.main(x1, y1, x2, y2, xt, yt) line = rotation.main(line[0].x, line[0].y, line[1].x, line[1].y, xf, yf, d) line = scale.main(line[0].x, line[0].y, line[1].x, line[1].y, xf, yf, xs, ys) line = draw_line.main(line[0].x, line[0].y, line[1].x, line[1].y) return line
def main( x1, y1, x2, y2, xt, yt, xf, yf, d, xs, ys ): line = translation.main( x1, y1, x2, y2, xt, yt ) line = rotation.main( line[ 0 ].x, line[ 0 ].y, line[ 1 ].x, line[ 1 ].y, xf, yf, d ) line = scale.main( line[ 0 ].x, line[ 0 ].y, line[ 1 ].x, line[ 1 ].y, xf, yf, xs, ys ) line = draw_line.main( line[ 0 ].x, line[ 0 ].y, line[ 1 ].x, line[ 1 ].y ) return line
def main( x, y, majA, minB ): border = draw_ellipse.main( x, y, majA, minB ) temp = one_color.struc() points = [ copy.deepcopy( one_color.struc ) ] length = len( border ) for i in range( length - 1 ): for t in range( 1, length ): if border[ i ].y == border[ t ].y: fill = draw_line.main( border[ i ].x, border[ i ].y, border[ t ].x, border[ t ].y ) length2 = len( fill ) for e in range( length2 ): temp.x = fill[ e ].x temp.y = fill[ e ].y points.append( copy.deepcopy( temp ) ) #end e for loop #end of if-else statement #end of t for loop #end of i for loop del points[ 0 ] return points
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 main( *args ): temp = one_color.struc() points = [ copy.deepcopy( one_color.struc ) ] fillpoints = [ copy.deepcopy( one_color.struc ) ] del points[ 0 ] del fillpoints[ 0 ] #find the smallest and largest y values #will be used as the limit of scan line minY = args[ 0 ] maxY = args[ 0 ] length = len( args ) for i in range( 1, length, 2 ): if args[ i ] < minY: minY = args[ i ] elif args[ i ] > maxY: maxY = args[ i ] #end of if-else statement #end of i for loop print( 'Found scan borders' ) print( 'minY = ', minY ) print( 'maxY = ', maxY ) scan = minY + 1 start = 0 while scan < maxY: while start <= length - 4: #find scan intersection with all sides except last side y1 = start + 1 x2 = y1 + 1 y2 = x2 + 1 line = draw_line.main( args[ start ], args[ y1 ], args[ x2 ], args[ y2 ] ) point = scan_line.main( line, scan ) if len( point ) == 0: start = start + 2 else: points = points + point start = start + 2 #If on the last side find its scan intersection line = draw_line.main( args[ length - 2 ], args[ length - 1 ], args[ 0 ], args[ 1 ] ) point = scan_line.main( line, scan ) if len( point ) == 0: pass else: points = points + point #Begin of sort lengthp = len( points ) done = False head = 0 tail = 1 while done == True: check = 0 if check == lengthp - 1: done = False if tail >= lengthp: 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 < lengthp - 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 start = 0 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')