Refactor RectBase to allow blit to RenderTarget

This commit is contained in:
2025-02-04 19:43:57 -05:00
parent 83ffecb91d
commit 663355726b
2 changed files with 9 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
#include <Event.h>
#include <Color4.hpp>
#include "JGL/types/RenderTarget.h"
namespace JUI
{
@@ -77,5 +78,7 @@ namespace JUI
Color4 border_color = {192, 192, 192, 0};
bool clips_descendants = false; // Controls if child objects can render outside of their parent's rectangle bounds.
float corner_rounding_radius = 0.f; // Curves the rectangle corners by N degrees.
void Draw(JGL::RenderTarget *canvas, const Color4 &bgColor, const Color4 &borderColor, const Vector2 &abs_pos,
const Vector2 &abs_size);
};
}

View File

@@ -35,7 +35,12 @@ namespace JUI {
void RectBase::Draw(const Color4& bgColor, const Color4& borderColor, const Vector2 &abs_pos, const Vector2 &abs_size) {
J2D::Begin();
Draw(nullptr, bgColor, borderColor, abs_pos, abs_size);
}
void RectBase::Draw(JGL::RenderTarget* canvas, const Color4& bgColor, const Color4& borderColor, const Vector2 &abs_pos, const Vector2 &abs_size) {
J2D::Begin(canvas, false);
// Background rect
if (corner_rounding_radius > 0)