ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Geometry2D.hpp File Reference

Shared zero-allocation 2D tessellation helpers for IRenderer backends. More...

#include "CoreTypes.hpp"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <span>

Go to the source code of this file.

Classes

struct  ZenitUI::Geometry2D::StaticMesh< MaxVertices, MaxIndices >
 Fixed-capacity stack mesh returned by Geometry2D builders. More...
struct  ZenitUI::Geometry2D::RoundedBorderRing
 Outer and inner vertex loops of a CSS border-box rounded stroke. More...

Typedefs

using ZenitUI::Geometry2D::QuadMesh = StaticMesh<4, 6>
using ZenitUI::Geometry2D::RectStrokeMesh = StaticMesh<8, 24>
using ZenitUI::Geometry2D::BorderMesh = StaticMesh<16, 24>
using ZenitUI::Geometry2D::NineSliceMesh = StaticMesh<16, 54>
using ZenitUI::Geometry2D::CircleMesh = StaticMesh<kCircleMaxSegments + 1, kCircleMaxSegments * 3>
using ZenitUI::Geometry2D::RoundedFillMesh = StaticMesh<kRoundedRingPoints + 1, kRoundedRingPoints * 3>
using ZenitUI::Geometry2D::RoundedStrokeMesh = StaticMesh<kRoundedRingPoints * 2, kRoundedRingPoints * 6>

Functions

RoundedBorderRing ZenitUI::Geometry2D::buildRoundedBorderRing (Rect r, float radiusPx, float thickness)
 Build the inward-extruded rounded ring for IRenderer::strokeRoundedRect.
QuadMesh ZenitUI::Geometry2D::buildQuad (Rect r, Color c)
 Build a solid-color axis-aligned quad.
QuadMesh ZenitUI::Geometry2D::buildTexturedQuad (TextureHandle t, Rect src, Rect dst, Color tint)
 Build a textured quad mapping pixel sub-rect src onto logical dst.
NineSliceMesh ZenitUI::Geometry2D::buildNineSlice (TextureHandle t, NineSlice s, Rect dst, Color tint)
 Build a 9-slice mesh (up to 9 quads, single indexed draw call).
RectStrokeMesh ZenitUI::Geometry2D::buildRectStroke (Rect r, float thickness, Color c)
 Build a CSS border-box rectangular stroke strictly inside r without corner overdraw.
BorderMesh ZenitUI::Geometry2D::buildBorder (Rect r, EdgeInsets sides, Color c)
 Build per-edge rectangular borders in a single indexed draw call.
RoundedFillMesh ZenitUI::Geometry2D::buildRoundedRectFill (Rect r, float radiusPx, Color c)
 Build a filled rounded rectangle (fast-paths to a 4-vertex quad when radiusPx <= 0.01).
RoundedStrokeMesh ZenitUI::Geometry2D::buildRoundedRectStroke (Rect r, float radiusPx, float thickness, Color c)
 Build a CSS border-box rounded stroke mesh strictly inside r.
CircleMesh ZenitUI::Geometry2D::buildCircle (Vec2 center, float radius, Color c)
 Build a filled circle with adaptive segment count (16..kCircleMaxSegments).

Variables

constexpr int ZenitUI::Geometry2D::kRoundedCornerSegments = 12
constexpr int ZenitUI::Geometry2D::kRoundedRingPoints = 4 * (kRoundedCornerSegments + 1)
constexpr int ZenitUI::Geometry2D::kCircleMaxSegments = 48

Detailed Description

Shared zero-allocation 2D tessellation helpers for IRenderer backends.

Every builder emits counter-clockwise triangles in NDC (Y-down logical screen space) so backends with OpenGL back-face culling enabled render consistently without winding mismatches.