MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
StaticGeometry.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "FactoryTable.hpp"
5#include "Containment.hpp"
6#include "Interaction.hpp"
7
9
10/**
11 * @brief A Form with no state that draws ordered vertices exactly as written.
12 *
13 * Positions are NDC, as Forma::slice and submit take them, so nothing maps them. The hit
14 * region is derived from the vertices: inside the triangles for triangle topologies, the
15 * circumscribing box otherwise.
16 */
17[[nodiscard]] MAYAFLUX_API Geometry::Form<std::monostate> vertex_form(const VertexGeometryInputs& input);
18
19/**
20 * @brief The binding of a vertex form: a topology and one or more vertex children, with an
21 * optional defaults child before them.
22 */
23template <typename Source, typename Access = Reflect::RecordAccess<Source>>
25{
27 input.required("topology")
28 .template repeated<&VertexGeometryInputs::vertices>("vertex", "defaults", "position", 1);
29 return input;
30}
31
32/**
33 * @brief A Form with no state that draws ordered vertices.
34 *
35 * Positions are x y in the unit square, mapped through the placement's rect
36 * onto the surface, with z kept. The hit region is derived from the placed
37 * vertices: inside the triangles for triangle topologies, the circumscribing
38 * box otherwise.
39 */
40[[nodiscard]] MAYAFLUX_API std::optional<Geometry::Form<std::monostate>> vertex_geometry_form(
41 const VertexGeometryInputs& input, const RectPlacementInputs& placement, std::string& error);
42
43/**
44 * @struct PolygonFactory
45 * @brief Factory for a bool state Form that fills or strokes an authored outline.
46 *
47 * Holes are cut out of a fill. The default hit region is the filled triangles,
48 * or the box of a stroke. The names in containment and interaction are resolved in the tables
49 * this value carries, which hold only what its builder registers.
50 */
51struct MAYAFLUX_API PolygonFactory {
54
55 [[nodiscard]] std::optional<Geometry::Form<bool>> operator()(
56 const PolygonInputs& input, const RectPlacementInputs& placement,
57 std::string& error) const;
58};
59
60/**
61 * @brief Register vertex_geometry_form under a name.
62 *
63 * The factory element needs a topology and one or more vertex children, with
64 * an optional defaults child before them. The instance needs a rect.
65 */
66template <typename Source, typename Access>
68{
69 table.template expose_typed<std::monostate>(std::move(name),
71 [](const VertexGeometryInputs&, const RectPlacementInputs&, std::string&)
72 -> std::optional<std::monostate> { return std::monostate {}; });
73}
74
75/**
76 * @brief Register a PolygonFactory under a name.
77 *
78 * The factory element needs points and may hold hole children. The instance
79 * needs a rect. The initial state is the element's on member.
80 */
81template <typename Source, typename Access>
82void expose_polygon(FactoryTable<Source, Access>& table, std::string name,
83 PolygonFactory factory)
84{
86 input.required("points")
87 .template repeated<&PolygonInputs::holes>("hole", {}, "points");
88
89 table.template expose_typed<bool>(std::move(name),
90 std::move(input), rect_placement_binding<Source, Access>(), std::move(factory),
92}
93
94}
Hit region providers by name.
Named factories that turn a template's factory element and an instance into placed Forma elements,...
Interaction providers for one state type, by name.
RecordBinding & required(std::string name)
Bind described attributes and configured child collections of a source element.
Geometry::Form< std::monostate > vertex_form(const VertexGeometryInputs &input)
A Form with no state that draws ordered vertices exactly as written.
std::optional< Geometry::Form< std::monostate > > vertex_geometry_form(const VertexGeometryInputs &input, const RectPlacementInputs &placement, std::string &error)
A Form with no state that draws ordered vertices.
Reflect::RecordBinding< VertexGeometryInputs, Source, Access > vertex_binding()
The binding of a vertex form: a topology and one or more vertex children, with an optional defaults c...
void expose_vertex_geometry(FactoryTable< Source, Access > &table, std::string name)
Register vertex_geometry_form under a name.
Reflect::RecordBinding< RectPlacementInputs, Source, Access > rect_placement_binding()
A binding for RectPlacementInputs that requires rect.
void expose_polygon(FactoryTable< Source, Access > &table, std::string name, PolygonFactory factory)
Register a PolygonFactory under a name.
A geometry function plus everything its realization requires.
Definition Geometry.hpp:83
std::optional< Geometry::Form< bool > > operator()(const PolygonInputs &input, const RectPlacementInputs &placement, std::string &error) const
Factory for a bool state Form that fills or strokes an authored outline.
An outline in unit space, filled or stroked, with a bool state.
A placement by origin and size: x, y, width, height.
A topology and ordered vertices in the Kakshya::Vertex field format.