''' Purpose: run module do assignment code snippets ''' import do import url import random # images for testing snippets ml_url = 'ml.png' ml = url.get_image( ml_url ) tj_url = 'tj.png' tj = url.get_image( tj_url ) try : # function random_color() random.seed( 'cs' ) c1 = do.random_color() random.seed( '1112' ) c2 = do.random_color() print( c1, c2, '\n' ) except : print( 'random_color(): missing or blows up' ) try : # function get_width() ml = url.get_image( ml_url ) w1 = do.get_width( ml ) w2 = do.get_width( tj ) print( w1, w2, '\n' ) except : print( 'get_image(): missing or blows up' ) try : # function get_height() h1 = do.get_height( ml ) h2 = do.get_height( tj ) print( h1, h2, '\n' ) except : print( 'get_height(): missing or blows up' ) try : # function left() xy1 = ( 2, 4 ); xy2 = ( 3, 9 ) l1 = do.left( xy1 ) l2 = do.left( xy2 ) print( l1, l2, '\n' ) except : print( 'left(): missing or blows up' ) try : # function right() xy1 = ( 2, 4 ); xy2 = ( 3, 9 ) r1 = do.right( xy1 ); r2 = do.right( xy2 ); print( r1, r2, '\n' ) except : print( 'right(): missing or blows up' ) try : # function above() xy1 = ( 2, 4 ); xy2 = ( 3, 9 ); a1 = do.above( xy1 ); a2 = do.above( xy2 ); print( a1, a2, '\n' ) except : print( 'above(): missing or blows up' ) try : # function below() xy1 = ( 2, 4 ); xy2 = ( 3, 9 ); b1 = do.below( xy1 ); b2 = do.below( xy2 ); print( b1, b2, '\n' ) except : print( 'below(): missing or blows up' ) try : # function is_inbounds() w = do.get_width( ml ) h = do.get_height( ml ) xy1 = ( w // 2, h // 2 ) xy2 = ( w, h ) xy3 = ( -1, -1 ) i1 = do.is_inbounds( ml, xy1 ) i2 = do.is_inbounds( ml, xy2 ) i3 = do.is_inbounds( ml, xy3 ) print( i1, i2, i3, '\n' ) except : print( 'is_inbounds(): missing or blows up' ) try : # function get_color() w = do.get_width( ml ) h = do.get_height( ml ) xy1 = ( w // 4, h // 5 ) xy2 = ( w, h ) xy3 = ( -1, -1 ) c1 = do.get_color( ml, xy1 ) c2 = do.get_color( ml, xy2 ) c3 = do.get_color( ml, xy3 ) print( c1, c2, c3, '\n' ) except : print( 'get_color(): missing or blows up' ) try : # function is_colorable() w = do.get_width( ml ) h = do.get_height( ml ) xy1 = ( w // 5, h // 4 ) xy2 = ( w, h ) xy3 = ( -1, -1 ) xy4 = ( w // 4, h // 5 ) b1 = do.is_colorable( ml, xy1 ) b2 = do.is_colorable( ml, xy2, (255, 0, 255 ) ) b3 = do.is_colorable( ml, xy3 ) c = ml.getpixel( xy4 ) b4 = do.is_colorable( ml, xy4, c ) print( b1, b2, b3, b4, '\n' ) except : print( 'is_colorable(): missing or blows up' ) try : # function paint() for x in range( 228, 235 ) : for y in range( 175, 220 ) : xy = ( x, y ) bg = ml.getpixel( xy ) do.paint( ml, xy, ( 255, 215, 0 ), bg ) ml.show() except : print( 'paint=(): missing or blows up' )