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

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()

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 Craft radius attribute sets them together (see set_radius()), while width/ height inscribe an ellipse in that bounding box (see set_radii()) &#8212; 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 is position + (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 start to end in that direction &#8212; swapping the two therefore yields the complementary arc. end may 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

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 &#8212; 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
const std::vector<Position> &points() const
void set_points(const std::vector<Position> &points)

Sets the triangle’s 3 points.

Throws:

exception::InvalidInputException – if points.size() != 3.

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 &#8212; that is a separate node rather than a mode of this one, so a polygon is only ever a polygon.

Public Functions

DocraftLoomPolygon() = default
~DocraftLoomPolygon() override = default
virtual void accept(loom::interfaces::DocraftLoomIVisitor &visitor) override
const std::vector<Position> &points() const
void set_points(const std::vector<Position> &points)

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 DocraftLoomShape and, like DocraftLoomLine, stroke-only: an open curve has no interior, so there is no background color to compose. Where DocraftLoomLine is a single segment between two points, this interpolates every point it is given &#8212; 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 through IDocraftLineRenderingBackend::draw_curve(), which interpolates a uniform Catmull-Rom spline: it passes exactly through every point rather than near them.

Public Functions

DocraftLoomCurveLine() = default
~DocraftLoomCurveLine() override = default
virtual void accept(loom::interfaces::DocraftLoomIVisitor &visitor) override
const std::vector<Position> &points() const
void set_points(const std::vector<Position> &points)

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

Public Functions

DocraftLoomLine() = default
~DocraftLoomLine() override = default
virtual void accept(loom::interfaces::DocraftLoomIVisitor &visitor) override
const Position &start() const
void set_start(const Position &start)
const Position &end() const
void set_end(const Position &end)