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

◆ position_picker()

MAYAFLUX_API Form< glm::vec2 > MayaFlux::Portal::Forma::Geometry::position_picker ( Kinesis::AABB2D  bounds,
glm::vec3  color = glm::vec3(0.9F),
float  size = 8.0F 
)

Geometry function for a 2D position picker in NDC space.

Parameters
boundsFull extent of the pick area in NDC.
colorPoint color.
sizePoint size in pixels.

Definition at line 123 of file FormFactory.cpp.

127{
128 GeometryFn<glm::vec2> fn = [bounds, color, size](
129 glm::vec2 v, std::vector<uint8_t>& out, Element& el) {
130 float x = bounds.min.x + v.x * bounds.width();
131 float y = bounds.min.y + v.y * bounds.height();
132
133 using V = Kakshya::PointVertex;
134 std::vector<V> verts = {
135 { .position = { x, y, 0 }, .color = color, .size = size },
136 };
137
138 write_verts(out, verts);
139
140 el.bounds_hint = bounds;
141 el.contains = Kinesis::polygon_bounds(std::span<const glm::vec2> {
142 std::array<glm::vec2, 4> {
143 bounds.min,
144 glm::vec2(bounds.max.x, bounds.min.y),
145 bounds.max,
146 glm::vec2(bounds.min.x, bounds.max.y) } });
147 };
148
149 return { std::move(fn),
150 Graphics::PrimitiveTopology::POINT_LIST,
151 sizeof(Kakshya::PointVertex),
152 drag_with<glm::vec2>(Kinesis::unit_square(bounds)) };
153}
std::function< void(T value, std::vector< uint8_t > &out_bytes, Element &element)> GeometryFn
Geometry function signature.
Definition Mapped.hpp:64
Vertex type for point primitives (POINT_LIST topology)
float height() const noexcept
Definition Bounds.hpp:38
bool contains(glm::vec2 p) const noexcept
Definition Bounds.hpp:25
float width() const noexcept
Definition Bounds.hpp:37
A bounded, renderable region on a window surface.
Definition Element.hpp:58

References MayaFlux::Kinesis::AABB2D::contains(), MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, MayaFlux::Portal::Graphics::POINT_LIST, MayaFlux::Kinesis::polygon_bounds(), MayaFlux::Kakshya::PointVertex::position, MayaFlux::Kinesis::unit_square(), MayaFlux::Kinesis::AABB2D::width(), and write_verts().

+ Here is the call graph for this function: