MayaFlux 1.0.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 360 of file FormFactory.cpp.

365{
366 GeometryFn<glm::vec2> fn = [arm_len, color, thickness, hit_radius](
367 glm::vec2 pos, std::vector<uint8_t>& out, Element& el) {
368 using V = Kakshya::LineVertex;
369 const std::array<V, 4> verts { {
370 { .position = { pos.x - arm_len, pos.y, 0.F }, .color = color, .thickness = thickness },
371 { .position = { pos.x + arm_len, pos.y, 0.F }, .color = color, .thickness = thickness },
372 { .position = { pos.x, pos.y - arm_len, 0.F }, .color = color, .thickness = thickness },
373 { .position = { pos.x, pos.y + arm_len, 0.F }, .color = color, .thickness = thickness },
374 } };
375 write_verts(out, verts);
376 el.bounds_hint = Kinesis::AABB2D::from_ndc(pos, glm::vec2(arm_len));
377 el.contains = Kinesis::circular_bounds(pos, hit_radius);
378 };
379
380 return { std::move(fn),
381 Graphics::PrimitiveTopology::LINE_LIST,
382 static_cast<size_t>(4) * sizeof(Kakshya::LineVertex),
383 follow_move() };
384}
glm::vec3 color
Definition Decoder.cpp:97
std::vector< float > * out
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:71
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
A bounded, renderable region on a window surface.
Definition Element.hpp:61

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

+ Here is the call graph for this function: