From 1d7319cdabef8ed161b30ea671e2cf308a995f42 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Thu, 28 Apr 2022 01:09:37 +0300 Subject: graphics: add the rounded rectangle drawing routine --- UefiMonitorTest/Graphics.c | 27 +++++++++++++++++++++++++++ UefiMonitorTest/Graphics.h | 11 +++++++++++ 2 files changed, 38 insertions(+) (limited to 'UefiMonitorTest') diff --git a/UefiMonitorTest/Graphics.c b/UefiMonitorTest/Graphics.c index fc9571c..7c76e37 100644 --- a/UefiMonitorTest/Graphics.c +++ b/UefiMonitorTest/Graphics.c @@ -358,6 +358,33 @@ DrawRectWithBorder ( PutRect (Graphics, X0 + BorderSize, Y0 + BorderSize, X1 - BorderSize, Y1 - BorderSize, MainColor); } +VOID +DrawRoundedRect ( + IN GRAPHICS_CONTEXT *Graphics, + IN UINTN X0, + IN UINTN Y0, + IN UINTN X1, + IN UINTN Y1, + IN UINTN CornerRadius, + IN CONST GRAPHICS_PIXEL_COLOR *Color + ) +{ + UINT8 Index; + + DrawCircle (Graphics, X0 + CornerRadius, Y0 + CornerRadius, CornerRadius, Color); + DrawCircle (Graphics, X1 - CornerRadius, Y0 + CornerRadius, CornerRadius, Color); + DrawCircle (Graphics, X0 + CornerRadius, Y1 - CornerRadius, CornerRadius, Color); + DrawCircle (Graphics, X1 - CornerRadius, Y1 - CornerRadius, CornerRadius, Color); + + for (Index = 0; Index < CornerRadius; Index++) { + DrawLine (Graphics, X0 + CornerRadius, Y0 + Index , X1 - 1 - CornerRadius, Y0 + Index, Color); + DrawLine (Graphics, X0 + Index , Y0 + CornerRadius, X0 + Index , Y1 - 1 - CornerRadius, Color); + DrawLine (Graphics, X1 - 1 - Index , Y0 + CornerRadius, X1 - 1 - Index , Y1 - 1 - CornerRadius, Color); + DrawLine (Graphics, X0 + CornerRadius, Y1 - 1 - Index , X1 - 1 - CornerRadius, Y1 - 1 - Index, Color); + } + PutRect (Graphics, X0 + CornerRadius, Y0 + CornerRadius, X1 - CornerRadius, Y1 - CornerRadius, Color); +} + VOID DrawCircle ( IN GRAPHICS_CONTEXT *Graphics, diff --git a/UefiMonitorTest/Graphics.h b/UefiMonitorTest/Graphics.h index 6396098..9e50cc4 100644 --- a/UefiMonitorTest/Graphics.h +++ b/UefiMonitorTest/Graphics.h @@ -149,6 +149,17 @@ DrawRectWithBorder ( IN CONST GRAPHICS_PIXEL_COLOR *BorderColor ); +VOID +DrawRoundedRect ( + IN GRAPHICS_CONTEXT *Graphics, + IN UINTN X0, + IN UINTN Y0, + IN UINTN X1, + IN UINTN Y1, + IN UINTN CornerRadius, + IN CONST GRAPHICS_PIXEL_COLOR *Color + ); + VOID DrawCircle ( IN GRAPHICS_CONTEXT *Graphics, -- cgit v1.2.3-18-g5258