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

◆ horizontal_fader()

MAYAFLUX_API GeometryFn< 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 9 of file Geometry.cpp.

14{
15 return [bounds, handle_w, track_color, handle_color](
16 float v, std::vector<uint8_t>& out, Element& el) {
17 float x = bounds.min.x + v * (bounds.width() - handle_w);
18 float yt = bounds.min.y + bounds.height() * 0.35F;
19 float yb = bounds.min.y + bounds.height() * 0.65F;
20
21 Kinesis::AABB2D track { .min = glm::vec2(bounds.min.x, yt), .max = glm::vec2(bounds.max.x, yb) };
22 Kinesis::AABB2D handle { .min = glm::vec2(x, bounds.min.y), .max = glm::vec2(x + handle_w, bounds.max.y) };
23
24 auto verts = Kakshya::to_mesh_vertices(Kinesis::filled_rect(track, track_color));
25 auto herts = Kakshya::to_mesh_vertices(Kinesis::filled_rect(handle, handle_color));
26 verts.insert(verts.end(), herts.begin(), herts.end());
27
28 write_verts(out, verts);
29
30 el.bounds_hint = handle;
31 el.contains = {};
32 };
33}
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::filled_rect(), MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, MayaFlux::Kakshya::to_mesh_vertices(), MayaFlux::Kinesis::AABB2D::width(), and write_verts().

+ Here is the call graph for this function: