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

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

Definition at line 149 of file FormFactory.cpp.

154{
155 GeometryFn<glm::vec2> fn = [bounds, color, size, live_offset](
156 glm::vec2 v, std::vector<uint8_t>& out, Element& el) {
157 const glm::vec2 shift = live_offset ? live_offset() : glm::vec2(0.F);
158 const Kinesis::AABB2D live = bounds.translated(shift);
159
160 float x = live.min.x + v.x * live.width();
161 float y = live.min.y + v.y * live.height();
162
163 using V = Kakshya::PointVertex;
164 std::vector<V> verts = {
165 { .position = { x, y, 0 }, .color = color, .size = size },
166 };
167
168 write_verts(out, verts);
169
170 el.bounds_hint = live;
171 el.contains = Kinesis::polygon_bounds(std::span<const glm::vec2> {
172 std::array<glm::vec2, 4> {
173 live.min,
174 glm::vec2(live.max.x, live.min.y),
175 live.max,
176 glm::vec2(live.min.x, live.max.y) } });
177 };
178
179 return { std::move(fn),
180 Graphics::PrimitiveTopology::POINT_LIST,
181 sizeof(Kakshya::PointVertex),
182 drag_with<glm::vec2>(Kinesis::unit_square(bounds, live_offset)) };
183}
glm::vec3 color
Definition Decoder.cpp:97
bool size
std::vector< float > * out
std::function< void(T value, std::vector< uint8_t > &out_bytes, Element &element)> GeometryFn
Geometry function signature.
Definition Mapped.hpp:71
Vertex type for point primitives (POINT_LIST topology)
float height() const noexcept
Definition Bounds.hpp:80
bool contains(glm::vec2 p) const noexcept
Definition Bounds.hpp:67
AABB2D translated(glm::vec2 offset) const noexcept
Definition Bounds.hpp:84
float width() const noexcept
Definition Bounds.hpp:79
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:63
A bounded, renderable region on a window surface.
Definition Element.hpp:61

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

+ Here is the call graph for this function: