i'm trying to make a function that can switch a window from dark mode to light mode and vice-versa. I managed to do it but now i want to add a sort of transition to the colors, where the white gets darker, and the grey gets lighter.
I've got this so far:
void paint_fade(cairo_surface_t* surface){
cairo_t*cr=cairo_create(surface);
if(darkmode){
for(int i=1; i>0.2; i-=0.005){
cairo_set_source_rgb(cr, i, i, i);
cairo_rectangle(cr, 0, GUI_Y, getX_SizeWindow(), getY_SizeWindow()-GUI_Y);
cairo_fill(cr);
sleep(0.1);
}
}
else{
for(int i=0.2; i<1; i+=0.005){
cairo_set_source_rgb(cr, i, i, i);
cairo_rectangle(cr, 0, GUI_Y, getX_SizeWindow(), getY_SizeWindow()-GUI_Y);
cairo_fill(cr);
sleep(0.1);
}
}
cairo_destroy(cr);
}
But this doesn't seem like it works, does anyone know why?