C++ Swastika crosshair

Участник
Участник
Статус
Онлайн
Регистрация
18 Май 2023
Сообщения
1,078
Реакции
250
1759479989780.png

by yandexgpt:
Expand Collapse Copy
    if ( misc_settings.crosshair_enabled )
    {
        auto hsv_to_rgb = []( float h, float s, float v ) -> ImVec4
        {
            float r = v, g = v, b = v;
            if ( s > 0.0f )
            {
                h = std::fmod( h, 1.0f ) * 6.0f;
                int i = (int)h;
                float f = h - (float)i;
                float p = v * ( 1.0f - s );
                float q = v * ( 1.0f - s * f );
                float t = v * ( 1.0f - s * ( 1.0f - f ) );
                switch ( i )
                {
                case 0: r = v; g = t; b = p; break;
                case 1: r = q; g = v; b = p; break;
                case 2: r = p; g = v; b = t; break;
                case 3: r = p; g = q; b = v; break;
                case 4: r = t; g = p; b = v; break;
                default: r = v; g = p; b = q; break;
                }
            }
            return ImVec4( r, g, b, 1.0f );
        };

        static float angle = 0.0f;
        static float hue = 0.0f;
        const float dt = ImGui::GetIO( ).DeltaTime;
        angle += misc_settings.crosshair_speed * dt;
        if ( angle >= 360.0f ) angle -= 360.0f;
        
        hue += 0.1f * dt; if ( hue > 1.0f ) hue -= 1.0f;

        const ImVec2 c = center;
        const float s = misc_settings.crosshair_size;
        const float t = misc_settings.crosshair_thickness;

        const float rad = angle * ( 3.14159265f / 180.0f );
        const float cs = std::cos( rad ), sn = std::sin( rad );
        auto rot = [&]( float x, float y ) { return ImVec2( c.x + x * cs - y * sn, c.y + x * sn + y * cs ); };

        ImColor current_color;
        if ( misc_settings.crosshair_static_color )
        {
            current_color = ImColor( misc_settings.crosshair_color );
        }
        else
        {
            auto col_h = [&]( float h_off ) { return ImColor( hsv_to_rgb( std::fmod( hue + h_off, 1.0f ), 1.0f, 1.0f ) ); };
            current_color = col_h( 0.0f );
        }
        ImVec2 a1 = rot( 0, -s ); ImVec2 b1 = rot( +s, -s ); ImVec2 m1 = rot( 0, 0 );
        ImVec2 a2 = rot( +s, 0 ); ImVec2 b2 = rot( +s, +s );
        ImVec2 a3 = rot( 0, +s ); ImVec2 b3 = rot( -s, +s );
        ImVec2 a4 = rot( -s, 0 ); ImVec2 b4 = rot( -s, -s );
        
        drawlist->AddLine( m1, a1, current_color, t );
        drawlist->AddLine( a1, b1, current_color, t );
        drawlist->AddLine( m1, a2, current_color, t );
        drawlist->AddLine( a2, b2, current_color, t );
        drawlist->AddLine( m1, a3, current_color, t );
        drawlist->AddLine( a3, b3, current_color, t );
        drawlist->AddLine( m1, a4, current_color, t );
        drawlist->AddLine( a4, b4, current_color, t );
    }
 
for луп? Не, не слышали!
 
секретные натовские разработки:pikachu:
 
ебаный понос
 
Танее антипаста это вместо for сделать f0r
это на внимательность, нормальная антипаста это либо оверхед нагрузкой, либо ошибка логики/нехватка компонента
 

Похожие темы

Назад
Сверху Снизу