Shapes
Geometric primitives. Every shape except DocraftLoomLine derives from
DocraftLoomShape, which composes one DocraftLoomShapeStyle member —
style is composition, not a shared style base class across the node
hierarchy (see About Docraft).
DocraftLoomShapeStyle
Background color, border color, and border width shared by every shape.
-
struct DocraftLoomShapeStyle
Shared background/border styling for shape nodes (Rectangle, Circle, Triangle, Polygon).
Composition over inheritance: each shape node holds one of these as a plain member, following the same idiom as DocraftLoomNode::layout_box().
Public Members
-
DocraftColor background_color = DocraftColor::fromRGB(0.0F, 0.0F, 0.0F, 0.0F)
-
DocraftColor border_color = DocraftColor::fromRGB(0.0F, 0.0F, 0.0F, 0.0F)
-
float border_width = 1.0F
-
DocraftLineStyle border_style = DocraftLineStyle::kSolid
-
DocraftColor background_color = DocraftColor::fromRGB(0.0F, 0.0F, 0.0F, 0.0F)
DocraftLoomShape
Base class for Circle/Triangle/Polygon/Rectangle (via
DocraftLoomLayoutContainer, see Containers); composes
DocraftLoomShapeStyle.
-
class DocraftLoomShape : public docraft::loom::nodes::DocraftLoomNode
Common base for shape nodes (Rectangle, Circle, Triangle, Polygon), holding the shared background/border styling.
Concrete shapes still implement accept() themselves (DocraftLoomShape is never instantiated directly).
Subclassed by docraft::loom::nodes::DocraftLoomCircle, docraft::loom::nodes::DocraftLoomLayoutContainer, docraft::loom::nodes::DocraftLoomPolygon, docraft::loom::nodes::DocraftLoomTriangle
Public Functions
-
DocraftLoomShape() = default
-
~DocraftLoomShape() override = default
-
const DocraftLoomShapeStyle &style() const
-
DocraftLoomShapeStyle &edit_style()
-
DocraftLoomShape() = default
DocraftLoomCircle
<Circle> — an ellipse held as two semi-axes: radius sets both (a
circle), width/height inscribe an oval in that bounding box. The
node’s frame position is the box’s top-left corner, not the center.
-
class DocraftLoomCircle : public docraft::loom::nodes::DocraftLoomShape
Circle/ellipse node, sized by its two semi-axes.
A circle is just the
radius_x() == radius_y()case, so both are stored: the Craftradiusattribute sets them together (see set_radius()), whilewidth/heightinscribe an ellipse in that bounding box (see set_radii()) — its four extreme points touch the middle of each box side. The node’s frame position is the bounding box’s top-left corner, not the center; the center isposition + (radius_x, radius_y).Public Functions
-
DocraftLoomCircle() = default
-
~DocraftLoomCircle() override = default
-
virtual void accept(loom::interfaces::DocraftLoomIVisitor &visitor) override
-
float radius_x() const
-
float radius_y() const
-
void set_radius(float radius)
Sets both semi-axes to the same value, i.e.
an actual circle.
-
void set_radii(float radius_x, float radius_y)
Sets the two semi-axes independently, i.e.
an ellipse (oval).
-
bool is_circle() const
True when the two semi-axes are equal, which lets the rendering stage pick the backend’s dedicated circle primitive over the ellipse one.
-
void set_arc(float start_angle, float end_angle)
Restricts drawing to the arc between two angles instead of the whole outline.
Angles are degrees from 12 o’clock, increasing clockwise on the page, and the arc is swept from
starttoendin that direction — swapping the two therefore yields the complementary arc.endmay exceed 360 to express an arc wrapping past 12 o’clock. An arc is stroked and never filled, since it is an open path; only the circular case is supported (see is_circle()).
-
void clear_arc()
-
bool has_arc() const
-
float arc_start_angle() const
-
float arc_end_angle() const
-
DocraftLoomCircle() = default
DocraftLoomTriangle
<Triangle> — exactly 3 points (Y-down offsets from the node’s own
origin); throws InvalidInputException otherwise.
-
class DocraftLoomTriangle : public docraft::loom::nodes::DocraftLoomShape
Triangle node defined by exactly 3 points.
Points are stored as Y-down offsets from the node’s own origin (frame.position), consistent with loom’s coordinate convention — unlike legacy, which stores them Y-up and flips at render time.
Public Functions
-
DocraftLoomTriangle() = default
-
~DocraftLoomTriangle() override = default
-
virtual void accept(loom::interfaces::DocraftLoomIVisitor &visitor) override
-
void set_points(const std::vector<Position> &points)
Sets the triangle’s 3 points.
- Throws:
exception::InvalidInputException – if points.size() != 3.
-
DocraftLoomTriangle() = default
DocraftLoomPolygon
<Polygon> — an arbitrary-point-count closed shape (needs ≥3 points to
render). Always closed; an open curve is DocraftLoomCurveLine.
-
class DocraftLoomPolygon : public docraft::loom::nodes::DocraftLoomShape
Polygon node defined by an arbitrary number of points: a closed, fillable shape needing at least 3 points to render.
Points are stored as Y-down offsets from the node’s own origin (frame.position), consistent with loom’s coordinate convention.
For an open curve through a set of points, see
DocraftLoomCurveLine— that is a separate node rather than a mode of this one, so a polygon is only ever a polygon.
DocraftLoomCurveLine
<CurveLine> — an open curve interpolating ≥2 points. Stroke-only and, like
DocraftLoomLine, not a DocraftLoomShape: an open curve has no interior
to fill.
-
class DocraftLoomCurveLine : public docraft::loom::nodes::DocraftLoomStrokedLine
An open curve passing smoothly through an arbitrary number of points.
Deliberately not a
DocraftLoomShapeand, likeDocraftLoomLine, stroke-only: an open curve has no interior, so there is no background color to compose. WhereDocraftLoomLineis a single segment between two points, this interpolates every point it is given — with exactly 2 points the two coincide, since the interpolation degenerates to a straight segment.Points are Y-down offsets from the node’s own origin (frame.position), the same convention as
DocraftLoomPolygon/DocraftLoomTriangle. The curve is rendered throughIDocraftLineRenderingBackend::draw_curve(), which interpolates a uniform Catmull-Rom spline: it passes exactly through every point rather than near them.
DocraftLoomLine
<Line> — a stroke-only primitive with start/end points,
border_color, and border_width. Not a DocraftLoomShape (no
background color). Both points are Y-down offsets from the node’s own
origin, like DocraftLoomTriangle’s points.
-
class DocraftLoomLine : public docraft::loom::nodes::DocraftLoomStrokedLine