libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Shapes and geometry

Platform-agnostic tessellation of rounded rectangles, ellipses, polygons, strokes, arcs, gradients and soft shadows into anti-aliased triangle meshes (GuiMesh). More...

Classes

struct  GuiPoint
 A 2D point in design-canvas pixels. More...
 
struct  GuiRect
 An axis-aligned rectangle (top-left origin) in design-canvas pixels. More...
 
struct  GuiCorners
 Per-corner radii, in the order top-left, top-right, bottom-right, bottom-left. More...
 
struct  GuiFill
 A solid color or a two-color linear gradient. More...
 
struct  GuiPath
 A closed outline made of straight lines and cubic Beziers, in whatever units the caller likes. More...
 
class  GuiMesh
 Accumulates shapes as a triangle list of MeshVertex. More...
 
struct  GuiMeshKey
 Everything that decides what a shape's triangles are. More...
 
class  GuiSharedMesh
 One cached mesh. More...
 
class  GuiMeshCache
 Static, since there is one video backend. More...
 
class  GuiShape
 A code-drawn shape: a rectangle (optionally rounded) or ellipse with a fill, outline and shadow, and no image assets. More...
 
struct  GuiTheme
 Colors, metrics and the style recipes built from them. More...
 

Enumerations

enum class  STROKE { STROKE::INSIDE , STROKE::CENTRE , STROKE::OUTSIDE }
 Where a stroke sits relative to the shape's geometric edge. More...
 
enum class  SHAPE { SHAPE::RECTANGLE , SHAPE::ELLIPSE }
 Basic shape kinds a paint can be applied to. More...
 
enum class  SHAPE_STATE { NORMAL , SHAPE_STATE::FOCUSED , PRESSED , DISABLED }
 The states a styled shape distinguishes. More...
 

Functions

std::vector< std::vector< GuiPoint > > GuiFlattenPath (const GuiPath &path, float scale, float tolerance=0.15f)
 Turns a path into one polygon per contour, multiplied by scale.
 
GuiRect GuiPathBounds (const GuiPath &path, float scale=1.0f)
 Gets the bounding box of a path's points (control points included, so it can be a little larger than the drawn curve), multiplied by scale
 
std::vector< GuiPoint > GuiRoundRectPolygon (const GuiRect &r, float radius, float angleDeg, float tolerance=0.15f)
 A rounded rectangle as a convex polygon, rotated about its center.
 
PixelColor GuiMixColor (PixelColor a, PixelColor b, float t)
 Blends two colors per channel (alpha included): t = 0 gives a, t = 1 gives b.
 
void GuiAddPaintedShape (GuiMesh &mesh, SHAPE shape, const GuiRect &r, const GuiCorners &corners, const GuiPaint &paint)
 Adds a painted shape to a mesh: shadow first, then fill, then outline.
 

Variables

bool hasFill
 The look of a shape: an optional fill, an optional outline and an optional shadow or glow.
 

Detailed Description

Platform-agnostic tessellation of rounded rectangles, ellipses, polygons, strokes, arcs, gradients and soft shadows into anti-aliased triangle meshes (GuiMesh).

Enumeration Type Documentation

◆ SHAPE

enum class SHAPE
strong

Basic shape kinds a paint can be applied to.

Enumerator
RECTANGLE 

Rectangle, with optional rounded corners (see GuiCorners)

ELLIPSE 

Ellipse inscribed in the rectangle (a circle when it is square)

Definition at line 17 of file GuiPaint.h.

◆ SHAPE_STATE

enum class SHAPE_STATE
strong

The states a styled shape distinguishes.

Enumerator
FOCUSED 

Highlighted: under the cursor, or selected with the D-pad.

Definition at line 70 of file GuiPaint.h.

◆ STROKE

enum class STROKE
strong

Where a stroke sits relative to the shape's geometric edge.

Enumerator
INSIDE 

Entirely inside the edge (the shape keeps its size)

CENTRE 

Centered on the edge.

OUTSIDE 

Entirely outside the edge.

Definition at line 52 of file GuiGeometry.h.

Function Documentation

◆ GuiAddPaintedShape()

void GuiAddPaintedShape ( GuiMesh & mesh,
SHAPE shape,
const GuiRect & r,
const GuiCorners & corners,
const GuiPaint & paint )

Adds a painted shape to a mesh: shadow first, then fill, then outline.

For SHAPE::ELLIPSE the corner radii are ignored; the shadow of an ellipse follows its outline.

Definition at line 218 of file GuiPaint.cpp.

◆ GuiFlattenPath()

std::vector< std::vector< GuiPoint > > GuiFlattenPath ( const GuiPath & path,
float scale,
float tolerance = 0.15f )

Turns a path into one polygon per contour, multiplied by scale.

Curves are split until no part of the polygon is farther than tolerance from the true curve, so a flat stretch costs one segment and a tight corner costs more. A contour with fewer than 3 points is dropped.

Parameters
pathThe path
scaleMultiplies every coordinate
toleranceLargest allowed distance between the true curve and the polygon, in the scaled units

Definition at line 804 of file GuiGeometry.cpp.

◆ GuiMixColor()

PixelColor GuiMixColor ( PixelColor a,
PixelColor b,
float t )

Blends two colors per channel (alpha included): t = 0 gives a, t = 1 gives b.

Definition at line 250 of file GuiPaint.cpp.

◆ GuiPathBounds()

GuiRect GuiPathBounds ( const GuiPath & path,
float scale = 1.0f )

Gets the bounding box of a path's points (control points included, so it can be a little larger than the drawn curve), multiplied by scale

Definition at line 849 of file GuiGeometry.cpp.

◆ GuiRoundRectPolygon()

std::vector< GuiPoint > GuiRoundRectPolygon ( const GuiRect & r,
float radius,
float angleDeg,
float tolerance = 0.15f )

A rounded rectangle as a convex polygon, rotated about its center.

Use it where a shape has to be tilted, or where several shapes should merge into one silhouette (draw each piece's outline stroke first and the fills after, and the joins disappear).

Parameters
rRectangle before rotation
radiusCorner radius (clamped to half the shorter side)
angleDegRotation in degrees, clockwise on screen
toleranceLargest allowed distance between the true curve and the polygon

Definition at line 742 of file GuiGeometry.cpp.

Variable Documentation

◆ hasFill

bool hasFill

The look of a shape: an optional fill, an optional outline and an optional shadow or glow.

Setters chain, so a paint reads as a sentence: GuiPaint().gradient(top, bottom).stroke(2, edge).shadow(14, black, 0, 4) ! struct GuiPaint { GuiFill fill; /*!< Fill, used when hasFill. Whether the shape is filled.

Definition at line 28 of file GuiPaint.h.