static void display_layer_update_callback(Layer *me, GContext* context) { time_t now = time(NULL); struct tm *t = localtime(&now); unsigned short hour = t->tm_hour; unsigned short hour_first_digit; unsigned short hour_second_digit; if(!clock_is_24h_style()) { unsigned short period; if(hour < 12) period = 0; // 0 for AM else period = 1; // 1 for PM hour = to_12_hour(hour); hour_first_digit = period; hour_second_digit = hour; } else { hour_first_digit = hour / 10; hour_second_digit = hour % 10; } draw_col( context, hour_first_digit, HOURS_FIRST_DIGIT_MAX_ROWS, HOURS_FIRST_DIGIT_COL ); draw_col(context, hour_second_digit, DEFAULT_MAX_ROWS, HOURS_SECOND_DIGIT_COL ); draw_col(context, t->tm_min / 10, MINUTES_FIRST_DIGIT_MAX_ROWS, MINUTES_FIRST_DIGIT_COL ); draw_col(context, t->tm_min % 10, DEFAULT_MAX_ROWS, MINUTES_SECOND_DIGIT_COL ); }
static void display_layer_update_callback(Layer *layer, GContext *ctx) { time_t now = time(NULL); struct tm *t = localtime(&now); draw_col(ctx, t->tm_year%100, DATE_TYPE, YEAR_COL, YEAR_MAX_ROWS); draw_col(ctx, t->tm_mon + 1, DATE_TYPE, MONTH_COL, MONTH_MAX_ROWS); draw_col(ctx, t->tm_mday, DATE_TYPE, DAY_COL, DAY_MAX_ROWS); draw_col(ctx, get_display_hour(t->tm_hour), TIME_TYPE, HOURS_COL, HOURS_MAX_ROWS); draw_col(ctx, t->tm_min, TIME_TYPE, MINUTES_COL, MINUTES_MAX_ROWS); draw_col(ctx, t->tm_sec, TIME_TYPE, SECONDS_COL, SECONDS_MAX_ROWS); }
void draw_pts(t_env *env) { int i; int j; int startx; int starty; t_point pt1; t_point pt2; t_point pt3; t_point pt4; startx = 20; starty = 20; printf("nb_lines = %d\n", env->map->len); while (env->map->lines[i]) { j = 0; pt3 = *env->map->lines[i]->pts[j]; if (env->map->lines[i + 1]) pt4= *env->map->lines[i + 1]->pts[j]; else pt4 = *env->map->lines[i]->pts[j]; printf("nb_lines = %d\n", env->map->len); while (env->map->lines[i]->pts[j]) { pt1 = *env->map->lines[i]->pts[j];// if (env->map->lines[i]->pts[j + 1]) pt2 = *env->map->lines[i]->pts[j + 1];// else pt2 = *env->map->lines[i]->pts[j]; mlx_pixel_put(env->mlx, env->mlx_win, (env->map->lines[i]->pts[j]->x + startx) * startx, (i + starty) * starty, 0xFFFFFF); draw_line(env, pt1, pt2); draw_col(env, pt3, pt4, pt1); j++; printf("nb_lines(j) = %d\n", env->map->len); } i++; printf("ICI"); } }