libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiMesh Class Reference

Accumulates shapes as a triangle list of MeshVertex. More...

#include <GuiGeometry.h>

Public Member Functions

 GuiMesh (float featherWidth=1.0f, float curveTolerance=0.3f)
 Constructor.
 
void clear ()
 Removes all geometry (keeps the feather and tolerance settings)
 
size_t size () const
 Gets the number of vertices (a multiple of 3)
 
bool empty () const
 Checks whether the mesh has no geometry.
 
const std::vector< MeshVertex > & vertices () const
 Gets the triangle list.
 
float getFeather () const
 Gets the feather width the mesh was built with.
 
float getTolerance () const
 Gets the curve tolerance the mesh was built with.
 
void addRect (const GuiRect &r, const GuiFill &fill, bool edgeFringe=true)
 Adds a filled rectangle.
 
void addRoundRect (const GuiRect &r, const GuiCorners &corners, const GuiFill &fill, bool edgeFringe=true)
 Adds a filled rounded rectangle.
 
void addEllipse (const GuiRect &r, const GuiFill &fill, bool edgeFringe=true)
 Adds a filled ellipse inscribed in a rectangle (a circle when w == h)
 
void addPolygon (const std::vector< GuiPoint > &pts, const GuiFill &fill, bool edgeFringe=true)
 Adds a filled polygon (triangle, chevron, a controller silhouette, ...).
 
void addLine (GuiPoint a, GuiPoint b, float width, const GuiFill &fill)
 Adds a straight line with flat ends.
 
void strokeRoundRect (const GuiRect &r, const GuiCorners &corners, float width, STROKE align, const GuiFill &fill)
 Adds a rounded-rectangle outline.
 
void strokeEllipse (const GuiRect &r, float width, STROKE align, const GuiFill &fill)
 Adds an ellipse outline.
 
void strokePolygon (const std::vector< GuiPoint > &pts, float width, STROKE align, const GuiFill &fill)
 Adds a polygon outline with mitered corners (the miter is capped on very sharp corners).
 
void strokeArc (GuiPoint centre, float radius, float startDeg, float sweepDeg, float width, PixelColor color)
 Adds an arc stroke centered on a radius, with flat ends.
 
void addShadow (const GuiRect &r, const GuiCorners &corners, float blur, float spread, float dx, float dy, PixelColor color)
 Adds a soft drop shadow or glow for a rounded rectangle.
 

Detailed Description

Accumulates shapes as a triangle list of MeshVertex.

Build one when a shape's size or style changes and keep it; drawing it again is free of any geometry work.

Definition at line 127 of file GuiGeometry.h.

Constructor & Destructor Documentation

◆ GuiMesh()

GuiMesh::GuiMesh ( float featherWidth = 1.0f,
float curveTolerance = 0.3f )

Constructor.

Parameters
featherWidthWidth of the anti-aliasing fringe, in design-canvas pixels. Pass 1 / VideoDriver::getUIScale() for a one-physical-pixel fringe; 0 disables it.
curveToleranceLargest allowed distance between a true curve and its polygon approximation, in design-canvas pixels

Definition at line 477 of file GuiGeometry.cpp.

Member Function Documentation

◆ addEllipse()

void GuiMesh::addEllipse ( const GuiRect & r,
const GuiFill & fill,
bool edgeFringe = true )

Adds a filled ellipse inscribed in a rectangle (a circle when w == h)

Parameters
edgeFringesee addRoundRect()

Definition at line 565 of file GuiGeometry.cpp.

◆ addLine()

void GuiMesh::addLine ( GuiPoint a,
GuiPoint b,
float width,
const GuiFill & fill )

Adds a straight line with flat ends.

Definition at line 589 of file GuiGeometry.cpp.

◆ addPolygon()

void GuiMesh::addPolygon ( const std::vector< GuiPoint > & pts,
const GuiFill & fill,
bool edgeFringe = true )

Adds a filled polygon (triangle, chevron, a controller silhouette, ...).

The polygon may be concave but must not cross itself. A convex one is filled as a fan; a concave one is triangulated (ear clipping, quadratic in the vertex count, so build it once and keep the mesh).

Definition at line 575 of file GuiGeometry.cpp.

◆ addRect()

void GuiMesh::addRect ( const GuiRect & r,
const GuiFill & fill,
bool edgeFringe = true )

Adds a filled rectangle.

Definition at line 538 of file GuiGeometry.cpp.

◆ addRoundRect()

void GuiMesh::addRoundRect ( const GuiRect & r,
const GuiCorners & corners,
const GuiFill & fill,
bool edgeFringe = true )

Adds a filled rounded rectangle.

Corner radius h/2 makes a capsule.

Parameters
edgeFringefalse leaves out the anti-aliased edge, for a fill whose edge is entirely covered by an opaque outline drawn on top of it (saves a third of the fill's triangles)

Definition at line 548 of file GuiGeometry.cpp.

◆ addShadow()

void GuiMesh::addShadow ( const GuiRect & r,
const GuiCorners & corners,
float blur,
float spread,
float dx,
float dy,
PixelColor color )

Adds a soft drop shadow or glow for a rounded rectangle.

Draw it before the shape it belongs to.

Parameters
blurWidth of the soft edge
spreadGrows (positive) or shrinks (negative) the shadow's edge
dxHorizontal offset
dyVertical offset
colorShadow color; its alpha is the shadow's peak opacity

Definition at line 714 of file GuiGeometry.cpp.

◆ clear()

void GuiMesh::clear ( )

Removes all geometry (keeps the feather and tolerance settings)

Definition at line 482 of file GuiGeometry.cpp.

◆ empty()

bool GuiMesh::empty ( ) const
inline

Checks whether the mesh has no geometry.

Definition at line 142 of file GuiGeometry.h.

◆ getFeather()

float GuiMesh::getFeather ( ) const
inline

Gets the feather width the mesh was built with.

Definition at line 146 of file GuiGeometry.h.

◆ getTolerance()

float GuiMesh::getTolerance ( ) const
inline

Gets the curve tolerance the mesh was built with.

Definition at line 148 of file GuiGeometry.h.

◆ size()

size_t GuiMesh::size ( ) const
inline

Gets the number of vertices (a multiple of 3)

Definition at line 140 of file GuiGeometry.h.

◆ strokeArc()

void GuiMesh::strokeArc ( GuiPoint centre,
float radius,
float startDeg,
float sweepDeg,
float width,
PixelColor color )

Adds an arc stroke centered on a radius, with flat ends.

Used for progress rings. Angles are in degrees, 0 = +X (right), increasing clockwise on screen.

Definition at line 642 of file GuiGeometry.cpp.

◆ strokeEllipse()

void GuiMesh::strokeEllipse ( const GuiRect & r,
float width,
STROKE align,
const GuiFill & fill )

Adds an ellipse outline.

Definition at line 619 of file GuiGeometry.cpp.

◆ strokePolygon()

void GuiMesh::strokePolygon ( const std::vector< GuiPoint > & pts,
float width,
STROKE align,
const GuiFill & fill )

Adds a polygon outline with mitered corners (the miter is capped on very sharp corners).

A concave polygon works as long as the stroke is thin compared with its smallest notch.

Definition at line 633 of file GuiGeometry.cpp.

◆ strokeRoundRect()

void GuiMesh::strokeRoundRect ( const GuiRect & r,
const GuiCorners & corners,
float width,
STROKE align,
const GuiFill & fill )

Adds a rounded-rectangle outline.

Definition at line 604 of file GuiGeometry.cpp.

◆ vertices()

const std::vector< MeshVertex > & GuiMesh::vertices ( ) const
inline

Gets the triangle list.

Definition at line 144 of file GuiGeometry.h.


The documentation for this class was generated from the following files: