void draw_rframe(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 30, 45, 0); vrule(ucg, ox+50+45-1, 30, 20, 1); vrule(ucg, ox+50+1, 30+20-8, 8, 0); hrule(ucg, ox+50, 30+20-1-1, 8, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawRFrame(ucg, ox+50, 30, 45, 20, 8); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_rframe"); }
void draw_text_ascent_descent(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFont(ucg, ucg_font_ncenB24_tf); ucg_SetFontPosBaseline(ucg); ucg_SetColor(ucg, 0, 0, 0, 255); /* draw blue "baseline" */ ucg_DrawHLine(ucg, 42+ox, 30, ucg_GetStrWidth(ucg, "Ucg")); ucg_SetColor(ucg, 0, 255, 255, 255); /* draw white "Ucg" */ ucg_DrawString(ucg, 42+ox, 30, 0, "Ucg"); pos(ucg, 42+ox, 30, 0); ucg_SetFont(ucg, ucg_font_ncenB24_tf); vrule(ucg, 42+ox+ucg_GetStrWidth(ucg, "Ucg"), 30-ucg_GetFontAscent(ucg), ucg_GetFontAscent(ucg), 1); ucg_SetFont(ucg, ucg_font_ncenB24_tf); vrule(ucg, 42+ox+ucg_GetStrWidth(ucg, "Ucg"), 30, -ucg_GetFontDescent(ucg), 1); save_picture(ucg, "draw_text_ascent_descent"); }
void draw_vline(ucg_t *ucg) { prepare_picture(ucg); vrule(ucg, ox+50, 20, 25, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawVLine(ucg, ox+50, 20, 25); pos(ucg, ox+50, 20,0); save_picture(ucg, "draw_vline"); }
void draw_circle(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50+1, 30, 20, 0); vrule(ucg, ox+50+20-1, 30+1, 20, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawCircle(ucg, ox+50, 30, 20, UCG_DRAW_LOWER_RIGHT); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_circle"); }
void draw_box(ucg_t *ucg) { prepare_picture(ucg); hrule(ucg, ox+50, 30, 45, 0); vrule(ucg, ox+50+45-1, 30, 20, 1); ucg_SetColor(ucg, 0, 255, 255, 255); ucg_DrawBox(ucg, ox+50, 30, 45, 20); pos(ucg, ox+50, 30,0); save_picture(ucg, "draw_box"); }
void set_clip_range(ucg_t *ucg) { prepare_picture(ucg); ucg_SetFontPosBaseline(ucg); ucg_SetFont(ucg, ucg_font_ncenB18_tf); ucg_SetColor(ucg, 0, 255, 255, 255); /* draw white A */ ucg_DrawGlyph(ucg, 50, 40, 0, 'A'); ucg_SetClipRange(ucg, 57, 20, 30, 15); /* restrict area */ ucg_SetColor(ucg, 0, 0, 0, 127); ucg_DrawBox(ucg, 0, 0, 128, 64); /* fill the restricted area with dark blue */ ucg_SetColor(ucg, 0, 0, 0, 255); ucg_DrawGlyph(ucg, 50, 40, 0, 'A'); /* draw light blue A */ hrule(ucg, ox+57, 20, 30, 0); vrule(ucg, ox+57+30, 20, 15, 1); pos(ucg, ox+50, 40, 0); save_picture(ucg, "set_clip_range"); }
void do_page(const month_grid& m, bool left_half, bool right_half) { s_ps->black(); s_ps->font("Arial", 10); // s_ps->rectangle(X0, X0 + WIDTH, Y0, Y0 + HEIGHT); set_box(X0, RIGHT, Y0, TOP); thinline(); show_box(); // Line down the middle. vrule(X0 + WIDTH / 2); float column_width = WIDTH / 8; // Top row: day names. float top_row_height = 20; // Title. if (right_half) { // Right column; title & notes. float x = X0 + WIDTH - column_width; vrule(x); s_ps->printf(x + 10, s_y1 - 20, m.m_month_name); s_ps->printf(x + 10, s_y1 - 40, "%d", m.m_year); } if (left_half) { // Mini-title, for double-checking book layout. s_ps->printf(X0 + WIDTH / 2 - 90, s_y0 + 3, "%s %d", m.m_month_name, m.m_year); } for (int i = 0; i < 7; i++) { if (left_half == false && i < 4) continue; if (right_half == false && i >= 4) continue; static const char* day_name[7] = { "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY" }; float x = X0 + column_width * i; set_box(x, x + column_width, TOP - top_row_height, TOP); s_ps->gray(0.75f); fill_box(); s_ps->black(); show_box(); s_ps->font("Arial", 8); s_ps->printf(x + 5, TOP - top_row_height + 3, day_name[i]); } float row_height = (HEIGHT - top_row_height) / ROWS; // Days. for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { if (left_half == false && col < 4) continue; if (right_half == false && col >= 4) continue; int day_number = m.m_day_number[row][col]; if (day_number == 0) { // Not a day. continue; } // Show this day. float x = X0 + column_width * col; float y = Y0 + row_height * (ROWS - 1 - row); set_box(x, x + column_width, y, y + row_height); thickline(); show_box(); // Show lines. static const int LINES = 8; float line_height = row_height / LINES; for (int line = 0; line < LINES; line++) { thinline(); hrule(y + line_height * line); } // Show the day number. s_ps->printf(s_x1 - 11, s_y0 + 3, "%2d", day_number); } } }