-
Автор темы
- #1
You can see how the animation looks like here:
C++:
// Warning: gheto code
// vars
/* for animation */
static int e_alpha3[ framework::e_maximum ];
static int e_alpha4[ framework::e_maximum ];
static bool clicked{};
static bool finished{true};
static bool dischanrged{ false };
static bool reverse{ false };
if ( !framework::g_framework->e_framework.e_colorpicker_open && object_handling::g_object_handling->is_possible( ) &&
input::g_input->key_pressed( VK_LBUTTON ) && input::g_input->mouse_pointer( { e_pos.x, e_pos.y + 17 }, { 173, 20 } ) ) {
reverse = false;
dischanrged = false;
finished = false;
clicked = !clicked;
}
auto run_animation = [ ]( int group_num, bool state ) -> void {
if ( state ) {
/* handle animation */
e_alpha3[ group_num ] -= 4;
e_alpha4[ group_num ] += 3;
}
else {
e_alpha3[ group_num ] += 4;
e_alpha4[ group_num ] -= 3;
}
/* setup it */
if ( e_alpha3[ group_num ] > 255 )
e_alpha3[ group_num ] = 255;
if ( e_alpha3[ group_num ] < 0 )
e_alpha3[ group_num ] = 0;
/* setup it 2 */
if ( e_alpha4[ group_num ] > 255 ) {
e_alpha4[ group_num ] = 255;
}
if ( e_alpha4[ group_num ] < 0 ) {
e_alpha4[ group_num ] = 0;
}
if ( e_alpha4[ group_num ] == 0 ) {
dischanrged = true;
}
/* clamp it */
std::clamp<int>( e_alpha3[ group_num ], 0, 255 );
std::clamp<int>( e_alpha4[ group_num ], 0, 255 );
};
run_animation( object_handling::g_object_handling->get_index( ), clicked );
int position;
position = ( ( this->e_pos.x + 219 + ( resize_x / 2 ) ) + 2 ) * ( e_alpha4[ object_handling::g_object_handling->get_index( ) ] / 255.f );
if ( position >= ( ( this->e_pos.x + 219 + ( resize_x / 2 ) ) + 2 ) - 50 ) {
clicked = false;
reverse = true;
if ( dischanrged )
finished = true;
}
if ( !finished && !dischanrged ) {
render::g_render->add_rect_filled( this->e_pos.x + ( 180 + ( resize_x / 2 ) ) * ( e_alpha4[ object_handling::g_object_handling->get_index( ) ] / 255.f ),
this->e_pos.y + 38, 50, 2, themes::g_theme->theme.accent, 2 );
}