#NEWLINE# def transform_path( p , center = False , scale = 1 , rotate_angle = 0 , rotate_point = Point ( ) ) : #NEWLINE# #INDENT# '\n    transforms a path\n    ' #NEWLINE# ( p_tl , p_br ) = calculate_bounding_box_of_path ( p ) #NEWLINE# ( width , height ) = get_width_and_height_of_shape_from_two_points ( p_tl , p_br ) #NEWLINE# look_for = svg_grammar ( ) #NEWLINE# pd = look_for . parseString ( p ) #NEWLINE# first_point = Point ( pd [ 0 ] [ 1 ] [ 0 ] , pd [ 0 ] [ 1 ] [ 1 ] ) #NEWLINE# if ( center is True ) : #NEWLINE# #INDENT# origin_point = Point ( ( p_tl . x + ( width / 2 ) ) , ( p_tl . y - ( height / 2 ) ) ) #NEWLINE# new_first_point = Point ( ( first_point . x - origin_point . x ) , ( first_point . y - origin_point . y ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_first_point = Point ( first_point . x , first_point . y ) #NEWLINE# #UNINDENT# new_first_point . rotate ( tmpp , rotate_point ) #NEWLINE# new_first_point . mult ( scale ) #NEWLINE# new_p = ( 'm %f,%f ' % ( new_first_point . x , new_first_point . y ) ) #NEWLINE# tmpp = Point ( ) #NEWLINE# origin = Point ( ) #NEWLINE# for n in range ( 0 , len ( pd ) ) : #NEWLINE# #INDENT# if ( ( pd [ n ] [ 0 ] == 'm' ) and ( n == 0 ) ) : #NEWLINE# #INDENT# for m in range ( 2 , len ( pd [ n ] ) ) : #NEWLINE# #INDENT# tmpp . assign ( pd [ n ] [ m ] [ 0 ] , pd [ n ] [ m ] [ 1 ] ) #NEWLINE# tmpp . rotate ( rotate_angle , rotate_point ) #NEWLINE# tmpp . mult ( scale ) #NEWLINE# new_p += ( ( ( str ( tmpp . x ) + ',' ) + str ( tmpp . y ) ) + ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( pd [ n ] [ 0 ] == 'h' ) or ( pd [ n ] [ 0 ] == 'v' ) ) : #NEWLINE# #INDENT# new_p += 'l ' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# new_p += ( pd [ n ] [ 0 ] + ' ' ) #NEWLINE# #UNINDENT# for m in range ( 1 , len ( pd [ n ] ) ) : #NEWLINE# #INDENT# if ( pd [ n ] [ 0 ] == 'h' ) : #NEWLINE# #INDENT# tmpp . assign ( pd [ n ] [ m ] [ 0 ] , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( pd [ n ] [ 0 ] == 'v' ) : #NEWLINE# #INDENT# tmpp . assign ( 0 , pd [ n ] [ m ] [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tmpp . assign ( pd [ n ] [ m ] [ 0 ] , pd [ n ] [ m ] [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# tmpp . rotate ( rotate_angle , rotate_point ) #NEWLINE# tmpp . mult ( scale ) #NEWLINE# new_p += ( ( ( str ( tmpp . x ) + ',' ) + str ( tmpp . y ) ) + ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( width , height , new_p )