Example #1
0
def checker(boardsize_x, boardsize_y, blocksize_x, blocksize_y):
    print('Starting')

    xwt = 0
    ywt = 0
    temp = one_color.struc()
    bluepoints = [copy.deepcopy(one_color.struc)]
    redpoints = [copy.deepcopy(one_color.struc)]

    for y in range(boardsize_y):
        t2 = y % blocksize_y
        if t2 == 0:
            ywt = ywt + 1
        #end if on t2

        ywt2 = ywt % 2

        if ywt2 == 1:
            n = 1
        elif ywt2 == 0:
            n = 2
        #end if on ywt2

        for x in range(boardsize_x):
            temp.x = x
            temp.y = y
            t = x % blocksize_x
            if t == 0:
                xwt = xwt + 1
            #end if on t

            xwt2 = xwt % 2

            if n == 1:
                if xwt2 == 1:
                    bluepoints.append(copy.deepcopy(temp))
                elif xwt2 == 0:
                    redpoints.append(copy.deepcopy(temp))
                #end if on xwt2
            elif n == 2:
                if xwt2 == 1:
                    redpoints.append(copy.deepcopy(temp))
                elif xwt2 == 0:
                    bluepoints.append(copy.deepcopy(temp))
                #end if on xwt2
            #end if on n
        #end for loop on x
    #end for loop on y

    del redpoints[0]  #remove unused location
    del bluepoints[0]  #remove unused location

    image = one_color.main(boardsize_x, boardsize_y, 255, 255, 255)
    image = add_to_image.main(image, redpoints, 255, 0, 0)
    image = add_to_image.main(image, bluepoints, 0, 0, 255)

    write_ppm.main(image, 'test')
    print('Finish')
Example #2
0
def checker( boardsize_x, boardsize_y, blocksize_x, blocksize_y ):
    print ('Starting')

    xwt = 0
    ywt = 0
    temp = one_color.struc()
    bluepoints = [ copy.deepcopy( one_color.struc ) ]
    redpoints = [ copy.deepcopy( one_color.struc ) ]

    for y in range( boardsize_y ):
        t2 = y%blocksize_y
        if t2 == 0:
            ywt = ywt + 1
        #end if on t2

        ywt2 = ywt%2

        if ywt2 == 1:
            n = 1
        elif ywt2 == 0:
            n = 2
        #end if on ywt2

        for x in range( boardsize_x ):
            temp.x = x
            temp.y = y
            t = x%blocksize_x
            if t == 0:
                xwt = xwt + 1
            #end if on t

            xwt2 = xwt%2

            if n == 1:
                if xwt2 == 1:
                    bluepoints.append( copy.deepcopy( temp ) )
                elif xwt2 == 0:
                    redpoints.append( copy.deepcopy( temp ) )
                #end if on xwt2
            elif n == 2:
                if xwt2 == 1:
                    redpoints.append( copy.deepcopy( temp ) )
                elif xwt2 == 0:
                    bluepoints.append( copy.deepcopy( temp ) )
                #end if on xwt2
            #end if on n
        #end for loop on x
    #end for loop on y

    del redpoints[ 0 ] #remove unused location
    del bluepoints[ 0 ] #remove unused location

    image = one_color.main( boardsize_x, boardsize_y, 255, 255, 255 )
    image = add_to_image.main( image, redpoints, 255, 0, 0 )
    image = add_to_image.main( image, bluepoints, 0, 0, 255 )

    write_ppm.main( image, 'test' )
    print ('Finish')
Example #3
0
def Circle( boardsize_x, boardsize_y, x, y, majA, minB ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    circum = draw_ellipse.main( x, y, majA, minB )
    image = add_to_image.main( image, circum, 0, 0, 0 )

    write_ppm.main( image, 'test' )
    print ('Finish')
def FillPolygon( boardsize_x, boardsize_y ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    fill = fill_polygon_test.main( 60, 120, 110, 200, 110, 150, 200, 220, 160, 120 )
    image = add_to_image.main( image, fill, 255, 0, 255 )

    write_ppm.main( image, 'test' )
    print ('Finish')
def PolyTrans( boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    poly = trans_poly.main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt )
    image = add_to_image.main( image, poly, 255, 0, 0 )

    write_ppm.main( image, 'test' )
    print ('Finish')
def TDview( boardsize_x, boardsize_y, xVRP, yVRP, zVRP, d, a, b, xt, yt, sf, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8, x9, y9, z9, x10, y10, z10, x11, y11, z11, x12, y12, z12, x13, y13, z13, x14, y14, z14, x15, y15, z15, x16, y16, z16, x17, y17, z17, x18, y18, z18, x19, y19, z19, x20, y20, z20, x21, y21, z21, x22, y22, z22, x23, y23, z23, x24, y24, z24, x25, y25, z25, x26, y26, z26, x27, y27, z27, x28, y28, z28, x29, y29, z29, x30, y30, z30 ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    frame = TDviewDisplay.main( xVRP, yVRP, zVRP, d, a, b, xt, yt, sf, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8, x9, y9, z9, x10, y10, z10, x11, y11, z11, x12, y12, z12, x13, y13, z13, x14, y14, z14, x15, y15, z15, x16, y16, z16, x17, y17, z17, x18, y18, z18, x19, y19, z19, x20, y20, z20, x21, y21, z21, x22, y22, z22, x23, y23, z23, x24, y24, z24, x25, y25, z25, x26, y26, z26, x27, y27, z27, x28, y28, z28, x29, y29, z29, x30, y30, z30 )
    image = add_to_image.main( image, frame, 255, 0, 0 )

    write_ppm.main( image, 'test' )
    print ('Finish')
Example #7
0
def Circle( boardsize_x, boardsize_y, x, y, r ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    circum = draw_circle.main( x, y, r )
    image = add_to_image.main( image, circum, 0, 0, 255 )

    write_ppm.main( image, 'test' )
    print ('Finish')
def EllipseFill( boardsize_x, boardsize_y, x, y, majA, minB ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    circum = fill_ellipse.main( x, y, majA, minB )
    image = add_to_image.main( image, circum, 0, 0, 0 )

    write_ppm.main( image, 'test' )
    print ('Finish')
Example #9
0
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 PolyComp2( boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt, xTrans, yTrans, xs, ys, d ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    poly = comp_poly2.main( x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt, xTrans, yTrans, xs, ys, d )
    image = add_to_image.main( image, poly, 255, 0, 0 )

    write_ppm.main( image, 'test' )
    print ('Finish')
def CircleFill( boardsize_x, boardsize_y, x, y, r ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    circum = fill_circle.main( x, y, r )
    image = add_to_image.main( image, circum, 0, 0, 255 )

    write_ppm.main( image, 'test' )
    print ('Finish')
Example #12
0
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')
Example #13
0
def FillPolygon(boardsize_x, boardsize_y):

    print('Starting')

    image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245)
    fill = fill_polygon_test.main(60, 120, 110, 200, 110, 150, 200, 220, 160,
                                  120)
    image = add_to_image.main(image, fill, 255, 0, 255)

    write_ppm.main(image, 'test')
    print('Finish')
Example #14
0
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')
Example #15
0
def PolyTrans(boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5,
              xt, yt):

    print('Starting')

    image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245)
    poly = trans_poly.main(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, xt, yt)
    image = add_to_image.main(image, poly, 255, 0, 0)

    write_ppm.main(image, 'test')
    print('Finish')
Example #16
0
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')
Example #17
0
def TDline(boardsize_x, boardsize_y, d, xt, yt, sf, x1, y1, z1, x2, y2, z2):

    print('Starting')

    array = [x1, y1, z1, x2, y2, z2]

    image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245)
    frame = display.main(d, xt, yt, sf, array)
    image = add_to_image.main(image, frame, 255, 0, 0)

    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 Composite( boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, xt, yt, d, xs, ys, xTrans, yTrans ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    redLine = composition.main( x1, y1, x2, y2, xt, yt, d, xs, ys, xTrans, yTrans )
    greenLine = composition.main( x3, y3, x4, y4, xt, yt, d, xs, ys, xTrans, yTrans )
    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')
Example #20
0
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')
Example #21
0
def TDline( boardsize_x, boardsize_y, d, xt, yt, sf, x1, y1, z1, x2, y2, z2 ):
    
    print ('Starting')

    array = [ x1, y1, z1, x2, y2, z2 ]
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    frame = display.main( d, xt, yt, sf, array )
    image = add_to_image.main( image, frame, 255, 0, 0 )

    write_ppm.main( image, 'test' )
    print ('Finish')
def Translate( boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, xt, yt ):
    
    print ('Starting')
    
    image = one_color.main( boardsize_x, boardsize_y, 245, 245, 245 )
    redLine = translation.main( x1, y1, x2, y2, xt, yt )
    greenLine = translation.main( x3, y3, x4, y4, xt, yt )
    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')
Example #23
0
def Translate(boardsize_x, boardsize_y, x1, y1, x2, y2, x3, y3, x4, y4, xt,
              yt):

    print('Starting')

    image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245)
    redLine = translation.main(x1, y1, x2, y2, xt, yt)
    greenLine = translation.main(x3, y3, x4, y4, xt, yt)
    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')
Example #24
0
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')
Example #25
0
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 TDview(boardsize_x, boardsize_y, xVRP, yVRP, zVRP, d, a, b, xt, yt, sf, x1,
           y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6,
           x7, y7, z7, x8, y8, z8, x9, y9, z9, x10, y10, z10, x11, y11, z11,
           x12, y12, z12, x13, y13, z13, x14, y14, z14, x15, y15, z15, x16,
           y16, z16, x17, y17, z17, x18, y18, z18, x19, y19, z19, x20, y20,
           z20, x21, y21, z21, x22, y22, z22, x23, y23, z23, x24, y24, z24,
           x25, y25, z25, x26, y26, z26, x27, y27, z27, x28, y28, z28, x29,
           y29, z29, x30, y30, z30):

    print('Starting')

    image = one_color.main(boardsize_x, boardsize_y, 245, 245, 245)
    frame = TDviewDisplay.main(
        xVRP, yVRP, zVRP, d, a, b, xt, yt, sf, x1, y1, z1, x2, y2, z2, x3, y3,
        z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8, x9, y9,
        z9, x10, y10, z10, x11, y11, z11, x12, y12, z12, x13, y13, z13, x14,
        y14, z14, x15, y15, z15, x16, y16, z16, x17, y17, z17, x18, y18, z18,
        x19, y19, z19, x20, y20, z20, x21, y21, z21, x22, y22, z22, x23, y23,
        z23, x24, y24, z24, x25, y25, z25, x26, y26, z26, x27, y27, z27, x28,
        y28, z28, x29, y29, z29, x30, y30, z30)
    image = add_to_image.main(image, frame, 255, 0, 0)

    write_ppm.main(image, 'test')
    print('Finish')
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')
            #solve for corresponding x values using Eq. 2.4
            x_value = m_inverse * y - m_inverse * y1 + x1

            #Round x values to nearest integer value
            x_value = round(x_value)
            temp.x = int(x_value)

            #add x and y values to data structure
            points.append(copy.deepcopy(temp))

    del points[0]  # remove unused location
    return points


# draw light gray background
image = one_color.main(320, 240, 245, 245, 245)

# 1. Rotate original lines
# translate end and start pts to origin using translation algorithm
for i in range(0, len(line_list)):
    for k in range(0, len(line_list[i])):
        line_list[i][k][0] = line_list[i][k][0] - rotation_point[0]
        line_list[i][k][1] = line_list[i][k][1] - rotation_point[1]

# Rotate x values, y values, round them
for i in range(0, len(line_list)):
    for k in range(0, len(line_list[i])):
        x = line_list[i][k][0]
        y = line_list[i][k][1]
        line_list[i][k][0] = int(
            round((x) * (math.cos(math.radians(rotation_angle))) - (y) *
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')
Example #30
0
            #solve for corresponding x values using Eq. 2.4
            x_value = m_inverse * y - m_inverse * y1 + x1

            #Round x values to nearest integer value
            x_value = round(x_value)
            temp.x = int(x_value)

            #add x and y values to data structure
            points.append(copy.deepcopy(temp))

    del points[0]  # remove unused location
    return points


# draw yellow background
image = one_color.main(150, 150, 255, 255, 58)

# draw black lines to differentiate 9 50x50 blocks
for i in range(0, len(line_list)):
    image = add_to_image.main(
        image,
        line(line_list[i][0][0], line_list[i][0][1], line_list[i][1][0],
             line_list[i][1][1]), 0, 0, 0)

#draw each number 1-8 according to number_list vertexes
for i in range(0, len(number_list)):
    for k in range(0, len(number_list[i])):
        if k == len(number_list[i]) - 1:
            pass
        else:
            image = add_to_image.main(
            #solve for corresponding x values using Eq. 2.4
            x_value = m_inverse * y - m_inverse * y1 + x1

            #Round x values to nearest integer value
            x_value = round(x_value)
            temp.x = int(x_value)

            #add x and y values to data structure
            points.append(copy.deepcopy(temp))

    del points[0]  # remove unused location
    return points


image = one_color.main(150, 350, 245, 245, 245)
image = add_to_image.main(image, fill_polygon(vertexes), 255, 0, 255)

for i in range(0, len(vertexes)):
    if i == len(vertexes) - 1:
        image = add_to_image.main(
            image,
            line(vertexes[i][0], vertexes[i][1], vertexes[0][0],
                 vertexes[0][1]), 0, 0, 0)
    else:
        image = add_to_image.main(
            image,
            line(vertexes[i][0], vertexes[i][1], vertexes[i + 1][0],
                 vertexes[i + 1][1]), 0, 0, 0)

write_ppm.main(image, 'Chap2_Exercise8')
            big_y = y2
            small_y = y1
        
        for y in range(small_y, big_y+1):
            temp.y = y

            #solve for corresponding x values using Eq. 2.4
            x_value = m_inverse*y - m_inverse*y1 + x1

            #Round x values to nearest integer value
            x_value = round(x_value)
            temp.x = int(x_value)

            #add x and y values to data structure
            points.append(copy.deepcopy(temp))

    del points[0]   # remove unused location
    return points

image = one_color.main(320,240,245,245,245)

for i in range(0, len(vertexes)):
    if i == len(vertexes)-1:
        image = add_to_image.main(image,line(vertexes[i][0],vertexes[i][1],vertexes[0][0],vertexes[0][1]),255,0,255)
    else:
        image = add_to_image.main(image,line(vertexes[i][0],vertexes[i][1],vertexes[i+1][0],vertexes[i+1][1]),255,0,255)
    
write_ppm.main(image,'Chap2_Exercise4')

print 'printing done'
            #solve for corresponding x values using Eq. 2.4
            x_value = m_inverse*y - m_inverse*y1 + x1

            #Round x values to nearest integer value
            x_value = round(x_value)
            temp.x = int(x_value)

            #add x and y values to data structure
            points.append(copy.deepcopy(temp))

    del points[0]   # remove unused location
    return points

# draw yellow background
image = one_color.main(150,150,255,255,58)

# draw black lines to differentiate 9 50x50 blocks
for i in range(0, len(line_list)):
    image = add_to_image.main(image,line(line_list[i][0][0],line_list[i][0][1],line_list[i][1][0],line_list[i][1][1]),0,0,0)

# 1. Translate the lines for the number 4
# add xt, yt to the x values, y values
for i in range(0, len(number_list[4])):
    number_list[4][i][0] = number_list[4][i][0] + x_translation
    number_list[4][i][1] = number_list[4][i][1] + y_translation

#draw each number 1-8 according to number_list vertexes
for i in range(0, len(number_list)):
    for k in range(0, len(number_list[i])):
        if k == len(number_list[i])-1:
import one_color
import write_ppm

image = one_color.main(320, 240, 255, 0, 0)
write_ppm.main(image, 'Exercise2')
import one_color
import write_ppm

image = one_color.main(320,240,255,0,0)
write_ppm.main(image,'Exercise2')