-
Автор темы
- #1
Код:
if ( g_input.IsCursorInRect( picker ) && g_input.GetKeyState( VK_LBUTTON ) ) {
/* grab the color we want to update to and store it */
auto color_to_upd = Colorpicker::ColorFromPos( g_input.m_mouse.x - ( px + m_w - COLORPICKER_WIDTH ), g_input.m_mouse.y - ( py + COlORPICKER_HEIGHT + 2 ) );
/* set the color that we stored and update it to main color var, but dont update the color alpha */
m_color = { color_to_upd.r( ), color_to_upd.g( ), color_to_upd.b( ), m_color.a( ) };
/* kepp the window prioritized */
m_parent->m_active_element = this;
}
if ( g_input.IsCursorInRect( alpha_bar ) && g_input.GetKeyState( VK_LBUTTON ) ) {
int input_value = g_input.m_mouse.x - ( m_x + 6 );
int max_input_range = m_width - 12;
int mapped_value = static_cast< int >( 255.0f * ( input_value / static_cast< float >( max_input_range ) ) );
m_color.a( ) = std::max( 0, std::min( 255, mapped_value ) );
/* clamp this shit since our input system is alchoolic */
if ( m_color.a() <= 1 ) {
m_color.a( ) = 0;
}
/* clamp this shit since our input system is alchoolic */
if ( m_color.a() >= 250 ) {
m_color.a( ) = 255;
}
/* kepp the window prioritized */
m_parent->m_active_element = this;
}
Пожалуйста, авторизуйтесь для просмотра ссылки.
/ idax86how it works: