void draw_green(t_env *e) { int length = get_both(e->xn, e->yn, e->xsym, e->yo[INC], e); // ft_putnbrendl(length); draw_polar(e->xn, e->yn, 180 - e->alpha, length, e, GREEN); length = e->b; draw_false_shit(e->xn, e->yn, 270, length, e, VIOLET); }
void draw_yellow(t_env *e, int i) { (void)i; int length = get_both(e->xn, e->yn, e->xo[INC - 1], e->yp, e); draw_polar(e->xsym, e->yn, e->beta - 90, length, e, YELLOW); draw_violet(e, 90); draw_blue(e, 1); // draw_light_red(e, 1); // draw_light_red(e, i); }
void do_the_thing(t_env *e, float angle, int length, int change) { (void)change; while (e->inc < 13) { // length = LY - e->yn; length = e->b; draw_polar(e->xn, e->yn, 270, length, e, VIOLET); length = e->mp - e->xn; e->mp = e->xn; draw_polar(XO, YO, 180, length, e, BLUE); length = get_both(XX(1), YY(1), LX, LY, e); draw_polar(XO, YO, angle, length, e, ORANGE); } }
std::function<bool( const item & )> item_filter_from_string( std::string filter ) { if( filter.empty() ) { // Variable without name prevents unused parameter warning return []( const item & ) { return true; }; } // remove curly braces (they only get in the way) if( filter.find( '{' ) != std::string::npos ) { filter.erase( std::remove( filter.begin(), filter.end(), '{' ) ); } if( filter.find( '}' ) != std::string::npos ) { filter.erase( std::remove( filter.begin(), filter.end(), '}' ) ); } if( filter.find( "," ) != std::string::npos ) { // functions which only one of which must return true std::vector<std::function<bool( const item & )> > functions; // Functions that must all return true std::vector<std::function<bool( const item & )> > inv_functions; size_t comma = filter.find( "," ); while( !filter.empty() ) { const auto ¤t_filter = trim( filter.substr( 0, comma ) ); if( !current_filter.empty() ) { auto current_func = item_filter_from_string( current_filter ); if( current_filter[0] == '-' ) { inv_functions.push_back( current_func ); } else { functions.push_back( current_func ); } } if( comma != std::string::npos ) { filter = trim( filter.substr( comma + 1 ) ); comma = filter.find( "," ); } else { break; } } return [functions, inv_functions]( const item & it ) { auto apply = [&]( const std::function<bool( const item & )> &func ) { return func( it ); }; bool p_result = std::any_of( functions.begin(), functions.end(), apply ); bool n_result = std::all_of( inv_functions.begin(), inv_functions.end(), apply ); if( !functions.empty() && inv_functions.empty() ) { return p_result; } if( functions.empty() && !inv_functions.empty() ) { return n_result; } return p_result && n_result; }; } bool exclude = filter[0] == '-'; if( exclude ) { return [filter]( const item & i ) { return !item_filter_from_string( filter.substr( 1 ) )( i ); }; } size_t colon; char flag = '\0'; if( ( colon = filter.find( ":" ) ) != std::string::npos ) { if( colon >= 1 ) { flag = filter[colon - 1]; filter = filter.substr( colon + 1 ); } } switch( flag ) { case 'c'://category return [filter]( const item & i ) { return lcmatch( i.get_category().name, filter ); }; break; case 'm'://material return [filter]( const item & i ) { return std::any_of( i.made_of().begin(), i.made_of().end(), [&filter]( const material_id & mat ) { return lcmatch( mat->name(), filter ); } ); }; break; case 'b'://both return [filter]( const item & i ) { auto pair = get_both( filter ); return item_filter_from_string( pair.first )( i ) && item_filter_from_string( pair.second )( i ); }; break; default://by name return [filter]( const item & a ) { return lcmatch( a.tname(), filter ); }; break; } }
void draw_orange(t_env *e, int i) { int length = get_both(e->xsym, e->yo[i] , e->xo[i], e->yo[2], e); draw_polar(e->xsym, e->yo[i], e->beta, length, e, ORANGE); }