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

◆ crosshair()

MAYAFLUX_API Form< glm::vec2 > MayaFlux::Portal::Forma::Geometry::crosshair ( float  arm_len = 0.04F,
glm::vec3  color = glm::vec3(0.9F),
float  thickness = 1.F,
float  hit_radius = 0.05F 
)

Geometry function for a crosshair indicator in NDC space.

Parameters
arm_lenHalf-length of each arm in NDC units.
colorLine color.
thicknessLine thickness (maps to LineVertex::thickness).
hit_radiusHit region radius in NDC units.

Definition at line 309 of file FormFactory.cpp.

314{
315 GeometryFn<glm::vec2> fn = [arm_len, color, thickness, hit_radius](
316 glm::vec2 pos, std::vector<uint8_t>& out, Element& el) {
317 using V = Kakshya::LineVertex;
318 const std::array<V, 4> verts { {
319 { .position = { pos.x - arm_len, pos.y, 0.F }, .color = color, .thickness = thickness },
320 { .position = { pos.x + arm_len, pos.y, 0.F }, .color = color, .thickness = thickness },
321 { .position = { pos.x, pos.y - arm_len, 0.F }, .color = color, .thickness = thickness },
322 { .position = { pos.x, pos.y + arm_len, 0.F }, .color = color, .thickness = thickness },
323 } };
324 write_verts(out, verts);
325 el.bounds_hint = Kinesis::AABB2D::from_ndc(pos, glm::vec2(arm_len));
326 el.contains = Kinesis::circular_bounds(pos, hit_radius);
327 };
328
329 return { std::move(fn),
330 Graphics::PrimitiveTopology::LINE_LIST,
331 static_cast<size_t>(4) * sizeof(Kakshya::LineVertex),
332 follow_move() };
333}
auto follow_move()
Produce a Form::wire that writes the cursor position on hover.
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
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
A bounded, renderable region on a window surface.
Definition Element.hpp:58

References MayaFlux::Kinesis::circular_bounds(), follow_move(), MayaFlux::Kinesis::AABB2D::from_ndc(), MayaFlux::Portal::Graphics::LINE_LIST, MayaFlux::Kakshya::LineVertex::position, and write_verts().

+ Here is the call graph for this function: