#include <gtk/gtk.h>
#include <math.h>
gboolean draw_the_specail_area(GtkWidget * area, cairo_t * cr, gpointer user_data)
{
GDateTime * now;
static int init = 0;
static gdouble second = 0;
static int min = 0;
static int hour = 0;
if (!init)
{
now = g_date_time_new_now_local();
second = g_date_time_get_hour(now);
min = g_date_time_get_minute(now);
hour = g_date_time_get_hour(now);
init = 1;
}
gdouble width = gtk_widget_get_allocated_width(area);
gdouble height = gtk_widget_get_allocated_height(area);
gdouble x_center = width / 2.0;
gdouble y_center = height / 2.0;
gdouble length = (x_center < y_center ? x_center : y_center) * 0.8;
gdouble arc_second = second * 2 * G_PI / 60;
gdouble arc_min = (min + second / 60.0) * 2 * G_PI / 60;
gdouble arc_hour = (hour + (min + second / 60.0) / 60.0) * 2 * G_PI / 12;
gdouble x_length;
gdouble
gtk 简单时钟
最新推荐文章于 2021-12-20 17:44:16 发布