MayaFlux 1.0.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),
const std::function< glm::vec2()> &  live_offset = {} 
)

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.
live_offsetOptional. Current translation of the drawn indicator.

Definition at line 92 of file FormFactory.cpp.

98{
99 const glm::vec2 center = region.center();
100 const float radius = std::min(region.width(), region.height()) * 0.5F;
101
102 GeometryFn<float> fn = [center, radius, angle_start, angle_end, color, live_offset](
103 float v, std::vector<uint8_t>& out, Element& el) {
104 const glm::vec2 shift = live_offset ? live_offset() : glm::vec2(0.F);
105 const glm::vec2 live_center = center + shift;
106
107 const float angle = angle_start + v * (angle_end - angle_start);
108 const glm::vec2 tip = live_center + radius * glm::vec2(std::cos(angle), std::sin(angle));
109
110 using V = Kakshya::LineVertex;
111 const std::vector<V> verts = {
112 { .position = { live_center.x, live_center.y, 0 }, .color = color },
113 { .position = { tip.x, tip.y, 0 }, .color = color },
114 };
115
116 write_verts(out, verts);
117
118 el.bounds_hint = Kinesis::AABB2D::from_ndc(live_center, glm::vec2(radius));
119 el.contains = Kinesis::circular_bounds(live_center, radius);
120 };
121
122 return { std::move(fn),
123 Graphics::PrimitiveTopology::LINE_LIST,
124 static_cast<size_t>(2) * sizeof(Kakshya::LineVertex),
125 drag_with<float>(Kinesis::angle_fraction(center, angle_start, angle_end, live_offset)) };
126}
glm::vec3 color
Definition Decoder.cpp:97
float radius
std::vector< float > * out
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:71
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
float height() const noexcept
Definition Bounds.hpp:80
glm::vec2 center() const noexcept
Definition Bounds.hpp:82
float width() const noexcept
Definition Bounds.hpp:79
A bounded, renderable region on a window surface.
Definition Element.hpp:61

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

+ Here is the call graph for this function: