summaryrefslogtreecommitdiffstats
path: root/graphics.c
diff options
context:
space:
mode:
Diffstat (limited to 'graphics.c')
-rw-r--r--graphics.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/graphics.c b/graphics.c
new file mode 100644
index 0000000..c03dc8e
--- /dev/null
+++ b/graphics.c
@@ -0,0 +1,35 @@
+#include "balls.h"
+
+void
+drawbg(Image *walls, Image *bg) {
+ draw(screen, screen->r, walls, nil, ZP);
+ draw(screen, screen->r, bg, nil, ZP);
+ flushimage(display, Refnone);
+}
+
+Image *
+alloccircle(int fg, int bg) {
+ Image *m, *fill;
+
+ m = allocimage(display, Rect(0, 0, 2*RADIUS, 2*RADIUS), RGBA32, 0, bg);
+ if (m == nil)
+ return nil;
+
+ fill = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, fg);
+ if (fill == nil) {
+ free(m);
+ return nil;
+ }
+
+ fillellipse(m, Pt(RADIUS, RADIUS), RADIUS, RADIUS, fill, ZP);
+ freeimage(fill);
+ return m;
+}
+
+void
+drawcircle(Image *m, Point pos) {
+ Rectangle r;
+
+ r = Rpt(subpt(pos, Pt(RADIUS, RADIUS)), addpt(pos, Pt(RADIUS, RADIUS)));
+ draw(screen, r, m, nil, ZP);
+}