aboutsummaryrefslogtreecommitdiff
path: root/src/calp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/calp.c')
-rw-r--r--src/calp.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/calp.c b/src/calp.c
index d9f0d3a..6748fd0 100644
--- a/src/calp.c
+++ b/src/calp.c
@@ -1,3 +1,5 @@
+//calp: printable calendar generator
+
#include <stdio.h>
#include <stdlib.h>
#include <cairo/cairo-pdf.h>
@@ -5,6 +7,7 @@
#include "draw.h"
#include "date.h"
+#include "color.h"
// Metric
#define A4_WIDTH 210
@@ -21,9 +24,6 @@
int main (void) {
// Definitions
// -----------
- //double width = US_LETTER_WIDTH;
- //double height = US_LETTER_HEIGHT;
-
double width = A4_WIDTH;
double height = A4_HEIGHT;
@@ -42,10 +42,13 @@ int main (void) {
// Create dimensions struct to hold measurements
struct dimensions dim;
+ // Create dimensions struct to hold information about a
+ // month
struct month_info month;
- // Leap year adjustment: increment February day count by one
+ // Leap year adjustment: increment February day count by one if
+ // it is a leap year.
int year = 2026;
if (isleap(year)) {
days_in_month[1]++;
@@ -53,7 +56,6 @@ int main (void) {
-
// Initialization
// --------------
// Calculates measurements, stores them in dimensions struct. See "draw.h"
@@ -72,7 +74,7 @@ int main (void) {
// PangoRectangle logical_extents;
// Fill background with white color
- cairo_set_source_rgb (paper, 255.0, 255.0, 255.0);
+ set_color(paper, WHITE);
fill_bg(paper);
@@ -84,29 +86,36 @@ int main (void) {
//print_dimensions(&dim);
// Draw all months
- //
- struct RGB color;
+ //struct RGB color;
+
+ //color = hex_to_rgb("81bbd3");
- color = hex_to_rgb("#81bbd3");
+ //printf("red: %f\n", color.r);
+ //printf("green: %f\n", color.g);
+ //printf("blue: %f\n", color.b);
- 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;
+ int end_month = num_of_months;
- for (int i = 0; i < num_of_months; i++) {
- // Set the
+
+ // Month generation loop
+ for (int i = first_month; i < end_month; i++) {
+ // Initialize month struct
month.first_day = day_of_week(1, i + 1, year);
month.num_of_days = days_in_month[i];
- cairo_set_source_rgb (paper, 0.0, 0.0, 0.0);
+ //draw_image(paper, "assets/weather.png", 0, 0);
+
+
+ set_color(paper, BLACK);
draw_month_title(paper, &dim, months[i]);
- calculate_minimum_rows(&month, &dim);
draw_month(paper, cd, day, &month, &dim);
draw_month_grid(paper, &month, &dim);
- // Go to next page in pdf
+ // Go to the next page in pdf
cairo_show_page(paper);
}