From 587315ff1af819dbf17c52d2622fa48526563707 Mon Sep 17 00:00:00 2001 From: foswret Date: Thu, 30 Apr 2026 23:23:25 -0500 Subject: first commit --- .gitignore | 2 ++ Makefile | 27 +++++++++++++++++++++++++++ calp | Bin 0 -> 19904 bytes src/calp.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/calp.o | Bin 0 -> 7344 bytes src/draw.c | 8 ++++++++ src/draw.h | 1 + src/draw.o | Bin 0 -> 4720 bytes 8 files changed, 80 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 calp create mode 100644 src/calp.c create mode 100644 src/calp.o create mode 100644 src/draw.c create mode 100644 src/draw.h create mode 100644 src/draw.o diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f99b77 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +notes.md +output.pdf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4c8f544 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +VERSION = 0.0 +PREFIX = /usr/local +CC = cc +DIR = src +OBJS = $(DIR)/calp.o $(DIR)/draw.o +.PHONY: clean all install + +TARGET = calp + +CFLAGS = `pkg-config --cflags pangocairo` -O2 -g -Wall -Werror -Wextra -Winit-self -Wuninitialized -pedantic +LFLAGS = `pkg-config --libs pangocairo` -lm + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LFLAGS) + +clean: + -rm -f $(OBJS) calp + +install: all + mkdir -p ${DESTDIR}${PREFIX}/bin + cp -f calp ${DESTDIR}${PREFIX}/bin + chmod 755 ${DESTDIR}${PREFIX}/bin/calp + +uninstall: + rm -f ${DESTDIR}${PREFIX}/bin/calp diff --git a/calp b/calp new file mode 100755 index 0000000..fde67a1 Binary files /dev/null and b/calp differ diff --git a/src/calp.c b/src/calp.c new file mode 100644 index 0000000..9b0bb20 --- /dev/null +++ b/src/calp.c @@ -0,0 +1,42 @@ +#include +#include +#include + +#include "draw.h" + +// Metric +#define US_LETTER_WIDTH 216 +#define US_LETTER_HEIGHT 279 + +#define A4_WIDTH 210 +#define A4_HEIGHT 297 + +double width = A4_WIDTH; +double height = A4_HEIGHT; + +int main (int argc, char **argv) { + char *filename; + + // TBD clean this up + filename = argv[1]; + + if (argc == 1) { + filename = "output.pdf"; + } + + // Initialization + cairo_surface_t *surface = cairo_pdf_surface_create(filename, width, height); + cairo_t *cr = cairo_create(surface); + + // Draw stuff here + fill_bg(cr, width, height); + + // FUNCTIONS TO MAKE + // Draw Grid + // Draw Numbers + + // Clean up + cairo_destroy(cr); + cairo_surface_destroy(surface); + return 0; +} diff --git a/src/calp.o b/src/calp.o new file mode 100644 index 0000000..b7e4878 Binary files /dev/null and b/src/calp.o differ diff --git a/src/draw.c b/src/draw.c new file mode 100644 index 0000000..51cd862 --- /dev/null +++ b/src/draw.c @@ -0,0 +1,8 @@ +#include + +int fill_bg(cairo_t *c, double x, double y) { + cairo_set_source_rgb (c, 255.0, 255.0, 255.0); + cairo_rectangle(c, 0, 0, x, y); + cairo_fill(c); + return 0; +} diff --git a/src/draw.h b/src/draw.h new file mode 100644 index 0000000..3cfc460 --- /dev/null +++ b/src/draw.h @@ -0,0 +1 @@ +int fill_bg(cairo_t *c, double w, double h); diff --git a/src/draw.o b/src/draw.o new file mode 100644 index 0000000..e768c5d Binary files /dev/null and b/src/draw.o differ -- cgit v1.2.3