MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ radial()

MAYAFLUX_API Form< float > MayaFlux::Portal::Forma::Geometry::radial ( Kinesis::AABB2D  region,
float  angle_start,
float  angle_end,
glm::vec3  color = glm::vec3(0.9F) 
)

Geometry function for a radial indicator in NDC space.

Parameters
regionNDC region the arc is inscribed in.
angle_startStart angle in radians (value = 0).
angle_endEnd angle in radians (value = 1).
colorLine color.

Definition at line 70 of file FormFactory.cpp.

75{
76 const glm::vec2 center = region.center();
77 const float radius = std::min(region.width(), region.height()) * 0.5F;
78
79 GeometryFn<float> fn = [center, radius, angle_start, angle_end, color](
80 float v, std::vector<uint8_t>& out, Element& el) {
81 const float angle = angle_start + v * (angle_end - angle_start);
82 const glm::vec2 tip = center + radius * glm::vec2(std::cos(angle), std::sin(angle));
83
84 using V = Kakshya::LineVertex;
85 const std::vector<V> verts = {
86 { .position = { center.x, center.y, 0 }, .color = color },
87 { .position = { tip.x, tip.y, 0 }, .color = color },
88 };
89
90 write_verts(out, verts);
91
92 el.bounds_hint = Kinesis::AABB2D::from_ndc(center, glm::vec2(radius));
93 el.contains = Kinesis::circular_bounds(center, radius);
94 };
95
96 return { std::move(fn),
97 Graphics::PrimitiveTopology::LINE_LIST,
98 static_cast<size_t>(2) * sizeof(Kakshya::LineVertex),
99 drag_with<float>(Kinesis::angle_fraction(center, angle_start, angle_end)) };
100}
float radius
void write_verts(std::vector< uint8_t > &out, const std::vector< V > &verts)
Write a vertex array into a GeometryFn output buffer.
Definition Geometry.hpp:35
std::function< void(T value, std::vector< uint8_t > &out_bytes, Element &element)> GeometryFn
Geometry function signature.
Definition Mapped.hpp:64
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
float height() const noexcept
Definition Bounds.hpp:38
glm::vec2 center() const noexcept
Definition Bounds.hpp:40
float width() const noexcept
Definition Bounds.hpp:37
A bounded, renderable region on a window surface.
Definition Element.hpp:58

References MayaFlux::Kinesis::angle_fraction(), MayaFlux::Kinesis::AABB2D::center(), MayaFlux::Kinesis::circular_bounds(), MayaFlux::Kinesis::AABB2D::from_ndc(), MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Portal::Graphics::LINE_LIST, MayaFlux::Kakshya::LineVertex::position, radius, MayaFlux::Kinesis::AABB2D::width(), and write_verts().

+ Here is the call graph for this function: