int main(void) { int a = 0; while(1) { render_clock(a=(a+5)%360); usleep(100000); } }
void return_to_clock_screen() { pulse_blank_canvas(); current_screen = SCREEN_CLOCK; // Draw clock render_clock(clock_color); // Draw bluetooth status icon update_bluetooth_icon(bt_connected); prepare_to_sleep(); }
// Main loop. This function is called frequently. // No blocking calls are allowed in this function or else the watch will reset. // The inPulse watchdog timer will kick in after 5 seconds if a blocking // call is made. void main_app_loop() { pulse_get_time_date(¤t_time); if(current_screen == SCREEN_CLOCK) { // Update once a minute if(current_min != current_time.tm_min) { current_min = current_time.tm_min; pulse_blank_canvas(); // Draw clock render_clock(clock_color); update_bluetooth_icon(bt_connected); } } }
void render_panel(struct panel *p) { int ox = 0; char *e = theme->elements; while (*e) { switch (*e) { case 'c': render_clock(); ox += clock_width; break; case 's': render_switcher(p->desktops); ox += switcher_width; break; case 't': if (!p->trayicons) { /* we're skipping if no tray icons here, separator is being drawn only once */ e++; continue; } if (tray_width) tile_image(theme->tile_img, tray_pos, tray_width); ox += tray_width; break; case 'b': render_taskbar(p->tasks, p->desktops); ox += taskbar_width; break; } if (*++e && theme->separator_img) { draw_image(theme->separator_img, ox); ox += get_image_width(theme->separator_img); } } render_present(); }
void shadow_render (int w, int h) { double scale_x, scale_y; int move_done; double shadow_offset_x, shadow_offset_y; double light_x, light_y; light_x = w / 2.0; light_y = h / 2.0; cairo_save (cr); cairo_save (cr); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); scale_x = ((double) w) / (double) bg_width; scale_y = ((double) h) / (double) bg_height; cairo_scale (cr, scale_x, scale_y); cairo_set_source_surface (cr, bg_surface, 0.0, 0.0); cairo_paint (cr); cairo_restore (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); if (!(shadow_cnt % 10)) render_clock (); else if (!(shadow_cnt % 5)) render_fakewin (); shadow_cnt++; if (shadow_cnt >= 1000000) shadow_cnt = 0; cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); shadow_offset_x = max_shadow_offset * ((fw_x + fakewin_width / 2) - light_x) / (w / 2.0); shadow_offset_y = max_shadow_offset * ((fw_y + fakewin_height / 2) - light_y) / (h / 2.0); cairo_save (cr); cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, shadow_alpha); cairo_mask_surface (cr, fakewin_surface, fw_x + shadow_offset_x - 0.05 * fakewin_width, fw_y + shadow_offset_y - 0.05 * fakewin_height); cairo_paint (cr); cairo_restore (cr); cairo_save (cr); cairo_translate (cr, (int) fw_x, (int) fw_y); cairo_set_source_surface (cr, fakewin_surface, 0.0, 0.0); cairo_paint (cr); cairo_restore (cr); shadow_offset_x = max_shadow_offset * ((cl_x + CLOCK_W / 2) - light_x) / (w / 2.0); shadow_offset_y = max_shadow_offset * ((cl_y + CLOCK_H / 2) - light_y) / (h / 2.0); cairo_save (cr); cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, shadow_alpha); cairo_mask_surface (cr, clock_surface, cl_x + shadow_offset_x - 0.05 * CLOCK_W, cl_y + shadow_offset_y - 0.05 * CLOCK_H); cairo_paint (cr); cairo_restore (cr); cairo_save (cr); cairo_translate (cr, (int) cl_x, (int) cl_y); cairo_set_source_surface (cr, clock_surface, 0.0, 0.0); cairo_paint (cr); cairo_restore (cr); if (which) { move_done = shadow_move_towards_point (&fw_x, &fw_y); } else { move_done = shadow_move_towards_point (&cl_x, &cl_y); } if (move_done) { which = (int) (drand48 () + 0.5); dst_x = drand48 () * (w - ((which)? fakewin_width : CLOCK_W) - max_shadow_offset); dst_y = drand48 () * (h - ((which)? fakewin_height: CLOCK_H) - max_shadow_offset); if (which) { start_x = fw_x; start_y = fw_y; } else { start_x = cl_x; start_y = cl_y; } } cairo_restore (cr); }
void shadow_setup (cairo_t *_cr, int w, int h) { clock_surface = cairo_surface_create_similar (cairo_get_target (_cr), CAIRO_CONTENT_COLOR_ALPHA, CLOCK_W, CLOCK_H); clock_bg_surface = cairo_surface_create_similar (cairo_get_target (_cr), CAIRO_CONTENT_COLOR_ALPHA, CLOCK_W, CLOCK_H); bg_surface = cairo_glitz_surface_create_from_png (_cr, "desktop.png", &bg_width, &bg_height); if (cairo_surface_status (bg_surface)) { printf ("error reading desktop.png\n"); exit(1); } fakewin_surface = cairo_glitz_surface_create_from_png (_cr, "fakewin.png", &fakewin_width, &fakewin_height); if (cairo_surface_status (fakewin_surface)) { printf ("error reading fakewin.png\n"); exit(1); } glider_surface = cairo_glitz_surface_create_from_png (_cr, "glider.png", &glider_width, &glider_height); if (cairo_surface_status (glider_surface)) { printf ("error reading glider.png\n"); exit(1); } cr = cairo_create (clock_bg_surface); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.0); cairo_rectangle (cr, 0, 0, CLOCK_W, CLOCK_H); cairo_fill (cr); cairo_save (cr); cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.25); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_scale (cr, CLOCK_W, CLOCK_H); cairo_translate (cr, 0.5, 0.5); cairo_arc (cr, 0, 0, 0.5, 0, 2 * M_PI); cairo_fill (cr); cairo_restore (cr); cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); fdface_draw (cr, CLOCK_W, CLOCK_H); cairo_destroy (cr); render_clock (); render_fakewin (); cr = _cr; }