19#include "../drivers/Mesh.h"
47 GuiCorners(
float tl_,
float tr_,
float br_,
float bl_) :
tl(tl_),
tr(tr_),
br(br_),
bl(bl_) {}
82 enum CMD : uint8_t { MOVE =
'M', LINE =
'L', CUBIC =
'C', CLOSE =
'Z' };
84 std::vector<float>
pts;
88 GuiPath& moveTo(
float x,
float y) {
cmds.push_back(MOVE);
pts.push_back(x);
pts.push_back(y);
return *
this; }
89 GuiPath& lineTo(
float x,
float y) {
cmds.push_back(LINE);
pts.push_back(x);
pts.push_back(y);
return *
this; }
90 GuiPath& cubicTo(
float x1,
float y1,
float x2,
float y2,
float x,
float y)
92 cmds.push_back(CUBIC);
93 pts.push_back(x1);
pts.push_back(y1);
pts.push_back(x2);
pts.push_back(y2);
pts.push_back(x);
pts.push_back(y);
96 GuiPath& close() {
cmds.push_back(CLOSE);
return *
this; }
106std::vector<std::vector<GuiPoint> >
GuiFlattenPath(
const GuiPath& path,
float scale,
float tolerance = 0.15f);
135 GuiMesh(
float featherWidth = 1.0f,
float curveTolerance = 0.3f);
140 size_t size()
const {
return verts.size(); }
142 bool empty()
const {
return verts.empty(); }
144 const std::vector<MeshVertex>&
vertices()
const {
return verts; }
162 void addPolygon(
const std::vector<GuiPoint>& pts,
const GuiFill& fill,
bool edgeFringe =
true);
186 std::vector<MeshVertex> verts;
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.
float getTolerance() const
Gets the curve tolerance the mesh was built with.
bool empty() const
Checks whether the mesh has no geometry.
void clear()
Removes all geometry (keeps the feather and tolerance settings)
GuiMesh(float featherWidth=1.0f, float curveTolerance=0.3f)
Constructor.
void addLine(GuiPoint a, GuiPoint b, float width, const GuiFill &fill)
Adds a straight line with flat ends.
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 strokeEllipse(const GuiRect &r, float width, STROKE align, const GuiFill &fill)
Adds an ellipse outline.
size_t size() const
Gets the number of vertices (a multiple of 3)
void addRoundRect(const GuiRect &r, const GuiCorners &corners, const GuiFill &fill, bool edgeFringe=true)
Adds a filled rounded rectangle.
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 addPolygon(const std::vector< GuiPoint > &pts, const GuiFill &fill, bool edgeFringe=true)
Adds a filled polygon (triangle, chevron, a controller silhouette, ...).
void addRect(const GuiRect &r, const GuiFill &fill, bool edgeFringe=true)
Adds a filled rectangle.
void strokeRoundRect(const GuiRect &r, const GuiCorners &corners, float width, STROKE align, const GuiFill &fill)
Adds a rounded-rectangle outline.
float getFeather() const
Gets the feather width the mesh was built with.
const std::vector< MeshVertex > & vertices() const
Gets the triangle list.
void addEllipse(const GuiRect &r, const GuiFill &fill, bool edgeFringe=true)
Adds a filled ellipse inscribed in a rectangle (a circle when w == h)
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.
STROKE
Where a stroke sits relative to the shape's geometric edge.
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 ...
@ INSIDE
Entirely inside the edge (the shape keeps its size)
@ OUTSIDE
Entirely outside the edge.
Per-corner radii, in the order top-left, top-right, bottom-right, bottom-left.
GuiCorners(float r=0)
Same radius on every corner (0 = square)
float bl
Bottom-left radius.
float tr
Top-right radius.
float br
Bottom-right radius.
A solid color or a two-color linear gradient.
bool gradient
true for a gradient, false for a solid color.
PixelColor from
Solid color, or the gradient's start color.
static GuiFill linear(PixelColor a, PixelColor b, float angleDeg)
A linear gradient across the shape's bounding box.
static GuiFill solid(PixelColor c)
A single flat color.
PixelColor to
The gradient's end color (unused when solid).
float angle
Gradient direction in degrees: 0 = left to right, 90 = top to bottom.
A closed outline made of straight lines and cubic Beziers, in whatever units the caller likes.
std::vector< uint8_t > cmds
One CMD per segment.
std::vector< float > pts
x, y pairs, as many as the commands consume.
bool empty() const
Checks whether the path has no commands.
A 2D point in design-canvas pixels.
An axis-aligned rectangle (top-left origin) in design-canvas pixels.
8-bit-per-channel RGBA color used by the video interfaces.