From 51b4786f58650c4a95f8a1c7e10d7302ae787ad9 Mon Sep 17 00:00:00 2001 From: Nikita <102851041+HyperNiki@users.noreply.github.com> Date: Mon, 18 Apr 2022 11:22:06 +0300 Subject: main: add the filled circle drawing routine --- UefiMonitorTest/UefiMonitorTest.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c index 5bd56cd..ecffb3c 100644 --- a/UefiMonitorTest/UefiMonitorTest.c +++ b/UefiMonitorTest/UefiMonitorTest.c @@ -309,6 +309,41 @@ PutRect ( } } +STATIC +VOID +DrawCircle ( + IN GRAPHICS_CONTEXT *Graphics, + IN UINTN X0, + IN UINTN Y0, + IN UINTN R, + GRAPHICS_PIXEL_COLOR *Color +) +{ + UINT32 *Buffer; + UINT32 Ucolor; + UINT32 Icolor; + UINT32 I, J; + + ASSERT (X0 >= 0 && X0 < Graphics->Width); + ASSERT (Y0 >= 0 && Y0 < Graphics->Height); + ASSERT (R > 0); + ASSERT ((X0 + R) < Graphics->Width && X0 >= R); + ASSERT ((Y0 + R) < Graphics->Height && Y0 >= R); + + Ucolor = *(UINT32 *)Color; + Icolor = GET_ICOLOR(Graphics, Ucolor); + Buffer = Graphics->BackBuffer + (Y0 - R) * Graphics->Pitch; + + for (J = (Y0 - R); J <= (Y0 + R); J++) { + for (I = (X0 - R); I <= (X0 + R); I++) { + if ((J - Y0) * (J - Y0) + (I - X0) * (I - X0) <= (R * R)) { + Buffer[I] = Icolor; + } + } + Buffer += Graphics->Pitch; + } +} + /** Draws a character to the screen -- cgit v1.2.3-18-g5258