summaryrefslogtreecommitdiff
path: root/kms++util/src
diff options
context:
space:
mode:
Diffstat (limited to 'kms++util/src')
-rw-r--r--kms++util/src/drawing.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 4e5c6c1..8885112 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -1,4 +1,6 @@
+#include <cmath>
+
#include <kms++/kms++.h>
#include <kms++util/kms++util.h>
@@ -198,6 +200,22 @@ void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h,
}
}
+void draw_horiz_line(IFramebuffer& fb, uint32_t x1, uint32_t x2, uint32_t y, RGB color)
+{
+ for (uint32_t x = x1; x <= x2; ++x)
+ draw_rgb_pixel(fb, x, y, color);
+}
+
+void draw_circle(IFramebuffer& fb, int32_t xCenter, int32_t yCenter, int32_t radius, RGB color)
+{
+ int32_t r2 = radius * radius;
+
+ for (int y = -radius; y <= radius; y++) {
+ int32_t x = (int)(sqrt(r2 - y * y) + 0.5);
+ draw_horiz_line(fb, xCenter - x, xCenter + x, yCenter - y, color);
+ }
+}
+
static bool get_char_pixel(char c, uint32_t x, uint32_t y)
{
#include "font_8x8.h"