summaryrefslogtreecommitdiffstats
path: root/graphics.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-09-25 17:50:06 -0400
committerSam Anthony <sam@samanthony.xyz>2024-09-25 17:50:06 -0400
commitd6681412eeb19b49a308877a60c79e7b4b4c5303 (patch)
treefbe3a518bc4bb50c5edcd117b33c0badaebe6fd5 /graphics.c
parent44dd6ad61dfed5d89f8abf7e8f41797501f071cc (diff)
downloadballs-d6681412eeb19b49a308877a60c79e7b4b4c5303.zip
variable radius
Diffstat (limited to 'graphics.c')
-rw-r--r--graphics.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/graphics.c b/graphics.c
index c03dc8e..12ca8ea 100644
--- a/graphics.c
+++ b/graphics.c
@@ -8,10 +8,13 @@ drawbg(Image *walls, Image *bg) {
}
Image *
-alloccircle(int fg, int bg) {
+alloccircle(int fg, int bg, uint radius) {
Image *m, *fill;
+ uint d;
- m = allocimage(display, Rect(0, 0, 2*RADIUS, 2*RADIUS), RGBA32, 0, bg);
+ d = 2*radius; /* diameter */
+ printf("alloccircle: d=%u\n", d);
+ m = allocimage(display, Rect(0, 0, d, d), RGBA32, 0, bg);
if (m == nil)
return nil;
@@ -21,15 +24,17 @@ alloccircle(int fg, int bg) {
return nil;
}
- fillellipse(m, Pt(RADIUS, RADIUS), RADIUS, RADIUS, fill, ZP);
+ fillellipse(m, Pt(radius, radius), radius, radius, fill, ZP);
freeimage(fill);
return m;
}
void
drawcircle(Image *m, Point pos) {
+ uint radius;
Rectangle r;
- r = Rpt(subpt(pos, Pt(RADIUS, RADIUS)), addpt(pos, Pt(RADIUS, RADIUS)));
+ radius = Dx(m->r)/2;
+ r = Rpt(subpt(pos, Pt(radius, radius)), addpt(pos, Pt(radius, radius)));
draw(screen, r, m, nil, ZP);
}