aboutsummaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
authorfoswret2026-05-05 12:19:15 -0500
committerfoswret2026-05-05 12:19:15 -0500
commitf0c9538a77c942ac96aebe52319f3e127be230ee (patch)
tree783dbdb76eeb1a39eb335a3fb2c2cb6d0bc9313e /src/draw.c
parent567b98381670eb96264fb8ae3621595ebfba1c5b (diff)
implement sloppy month art rendering, positioning mechanisms must be improved
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/draw.c b/src/draw.c
index 3fc8244..d5dbe37 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -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) {