diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rwxr-xr-x | calp | bin | 47272 -> 49584 bytes | |||
| -rw-r--r-- | src/calp.c | 22 | ||||
| -rw-r--r-- | src/date.o | bin | 5016 -> 4464 bytes | |||
| -rw-r--r-- | src/draw.c | 27 | ||||
| -rw-r--r-- | src/draw.h | 3 |
6 files changed, 35 insertions, 20 deletions
@@ -1,5 +1,6 @@ notes.md -output.pdf +*.pdf calp.o draw.o assets +assets.backup Binary files differ@@ -35,9 +35,6 @@ int main (void) { int num_of_months = 12; extern int days_in_month[12]; - // TBD: Add ability to choose filename - char *filename; - filename = "output.pdf"; // Create dimensions struct to hold measurements struct dimensions dim; @@ -55,6 +52,10 @@ int main (void) { } + // TBD: Add ability to choose filename + char filename[20]; + snprintf(filename, sizeof(filename), "%d.pdf", year); + //filename = "output.pdf"; // Initialization // -------------- @@ -83,16 +84,8 @@ int main (void) { // Construction // ------------ // Print dimensions, for debugging - //print_dimensions(&dim); - - // Draw all months - //struct RGB color; + print_dimensions(&dim); - //color = hex_to_rgb("81bbd3"); - - //printf("red: %f\n", color.r); - //printf("green: %f\n", color.g); - //printf("blue: %f\n", color.b); // Range of months to be rendered (Default: Full calendar year, 12 months) int first_month = 0; @@ -111,6 +104,11 @@ int main (void) { set_color(paper, BLACK); draw_month_title(paper, &dim, months[i]); + char path[20]; + + snprintf(path, 20, "assets/%d.png", i + 1); + + draw_month_art(paper, &dim, path); draw_month(paper, cd, day, &month, &dim); draw_month_grid(paper, &month, &dim); Binary files differ@@ -155,10 +155,10 @@ PangoRectangle get_logical_extents (cairo_t *c, char *font_family, int font_size // Used for determining where elements should be drawn on the page int calculate_dimensions(double pw, double ph, struct dimensions *d) { // Percentage of page that should be margin - double margin = 0.1 * pw; + double margin = 0.05 * pw; // Everything other than margin - double month_width = 0.8 * pw; + double month_width = 0.9 * pw; // width of day is 1/7th of total width double box_width = month_width / 7.0; @@ -332,6 +332,8 @@ int draw_month (cairo_t *c, cairo_t *cd, cairo_surface_t *s, struct month_info * // Draws the month being drawn at the top of the page int draw_month_title(cairo_t *c, struct dimensions *d, char *name) { + double height = d->paper_height - d->month_height - (d->margin * 2.0) - 40.0; + PangoRectangle rect; char *font = "Serif"; @@ -340,7 +342,7 @@ int draw_month_title(cairo_t *c, struct dimensions *d, char *name) { rect = get_logical_extents(c, font, font_size, name); double cursor_x = (d->paper_width / 2.0) - ((rect.width / 2.0)); - double cursor_y = d->margin; + double cursor_y = height + d->margin; draw_text(c, cursor_x, cursor_y, font, font_size, name); return 0; } @@ -363,10 +365,21 @@ int draw_image(cairo_t *c, char *path, double x, double y) { // Draw month art, if specified, above the calendar but below the // month's name. Images are cropped if they are too big or don't fit // the dimensions -//int draw_month_art(cairo_t *c, struct dimensions *d) { -// -// return 0; -//} +int draw_month_art(cairo_t *c, struct dimensions *d, char *path) { + cairo_save(c); + double width = d->month_width; + double height = d->paper_height - d->month_height - (d->margin * 2.0) - 40.0; + double cursor_x = d->margin; + double cursor_y = d->margin; + printf("drawing month...\n"); + cairo_rectangle (c, d->margin, d->margin, width, height); + cairo_clip(c); + + + draw_image(c, path, cursor_x, cursor_y); + cairo_restore(c); + return 0; +} //int draw_weekday_names(cairo_t *c, struct dimensions *d) { @@ -49,3 +49,6 @@ int calculate_minimum_rows(struct month_info *m, struct dimensions *d); int draw_image(cairo_t *c, char *path, double x, double y); +int draw_month_art(cairo_t *c, struct dimensions *d, char *path); + + |
