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

◆ horizontal_fader()

MAYAFLUX_API Form< float > MayaFlux::Portal::Forma::Geometry::horizontal_fader ( Kinesis::AABB2D  bounds,
float  handle_w,
glm::vec3  track_color = glm::vec3(0.3F),
glm::vec3  handle_color = glm::vec3(0.9F) 
)

Geometry function for a horizontal fader in NDC space.

Parameters
boundsFull extent of the fader in NDC.
handle_wHandle width in NDC units.
track_colorTrack quad color.
handle_colorHandle quad color.

Definition at line 8 of file FormFactory.cpp.

13{
14 GeometryFn<float> fn = [bounds, handle_w, track_color, handle_color](
15 float v, std::vector<uint8_t>& out, Element& el) {
16 float x = bounds.min.x + v * (bounds.width() - handle_w);
17 float yt = bounds.min.y + bounds.height() * 0.35F;
18 float yb = bounds.min.y + bounds.height() * 0.65F;
19
20 Kinesis::AABB2D track { .min = glm::vec2(bounds.min.x, yt), .max = glm::vec2(bounds.max.x, yb) };
21 Kinesis::AABB2D handle { .min = glm::vec2(x, bounds.min.y), .max = glm::vec2(x + handle_w, bounds.max.y) };
22
23 auto verts = Kakshya::to_mesh_vertices(Kinesis::filled_rect(track, track_color));
24 auto herts = Kakshya::to_mesh_vertices(Kinesis::filled_rect(handle, handle_color));
25 verts.insert(verts.end(), herts.begin(), herts.end());
26
27 write_verts(out, verts);
28
29 el.bounds_hint = handle;
30 el.contains = {};
31 };
32
33 return { std::move(fn),
34 Graphics::PrimitiveTopology::TRIANGLE_STRIP,
35 static_cast<size_t>(8) * sizeof(Kakshya::MeshVertex),
36 drag_with<float>(Kinesis::axis_fraction(bounds, handle_w, true)) };
37}
std::function< void(T value, std::vector< uint8_t > &out_bytes, Element &element)> GeometryFn
Geometry function signature.
Definition Mapped.hpp:64
float height() const noexcept
Definition Bounds.hpp:38
float width() const noexcept
Definition Bounds.hpp:37
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:21
A bounded, renderable region on a window surface.
Definition Element.hpp:58

References MayaFlux::Kinesis::axis_fraction(), MayaFlux::Kinesis::filled_rect(), MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, MayaFlux::Kakshya::to_mesh_vertices(), MayaFlux::Portal::Graphics::TRIANGLE_STRIP, MayaFlux::Kinesis::AABB2D::width(), and write_verts().

+ Here is the call graph for this function: