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

◆ vertical_fader()

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

Geometry function for a vertical fader in NDC space.

Parameters
boundsFull extent of the fader in NDC.
handle_hHandle height in NDC units.
track_colorTrack quad color.
handle_colorHandle quad color.

Definition at line 39 of file FormFactory.cpp.

44{
45 GeometryFn<float> fn = [bounds, handle_h, track_color, handle_color](
46 float v, std::vector<uint8_t>& out, Element& el) {
47 const float y = bounds.min.y + v * (bounds.height() - handle_h);
48 const float xl = bounds.min.x + bounds.width() * 0.35F;
49 const float xr = bounds.min.x + bounds.width() * 0.65F;
50
51 const Kinesis::AABB2D track { .min = { xl, bounds.min.y }, .max = { xr, bounds.max.y } };
52 const Kinesis::AABB2D handle { .min = { bounds.min.x, y }, .max = { bounds.max.x, y + handle_h } };
53
54 auto verts = Kakshya::to_mesh_vertices(Kinesis::filled_rect(track, track_color));
55 auto herts = Kakshya::to_mesh_vertices(Kinesis::filled_rect(handle, handle_color));
56 verts.insert(verts.end(), herts.begin(), herts.end());
57
58 write_verts(out, verts);
59
60 el.bounds_hint = handle;
61 el.contains = {};
62 };
63
64 return { std::move(fn),
65 Graphics::PrimitiveTopology::TRIANGLE_STRIP,
66 static_cast<size_t>(8) * sizeof(Kakshya::MeshVertex),
67 drag_with<float>(Kinesis::axis_fraction(bounds, handle_h, false)) };
68}
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
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: