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

◆ plot_cursor()

MAYAFLUX_API GeometryFn< float > MayaFlux::Portal::Forma::Plot::plot_cursor ( Kinesis::AABB2D  bounds,
bool  vertical = true,
glm::vec3  color = glm::vec3(0.75F),
float  thickness = 1.F 
)

GeometryFn<float> for a cursor or playhead line within a plot area.

Value in [0, 1] maps to a position within bounds. When vertical is true the line is vertical and the value maps to the X axis; when false the line is horizontal and the value maps to the Y axis.

Note
Pass PrimitiveTopology::LINE_LIST explicitly to create_element.
Parameters
boundsPlot area in NDC. The line spans the full perpendicular extent.
verticalTrue for a vertical playhead (X position), false for horizontal.
colorLine color.
thicknessLineVertex::thickness value.

Definition at line 182 of file PlotSpec.cpp.

187{
188 return [bounds, vertical, color, thickness](
189 float v, std::vector<uint8_t>& out, Element& el) {
190 const float t = std::clamp(v, 0.F, 1.F);
191 using V = Kakshya::LineVertex;
192 std::array<V, 2> verts;
193 if (vertical) {
194 const float x = bounds.min.x + t * bounds.width();
195 verts = { {
196 { .position = { x, bounds.min.y, 0.F }, .color = color, .thickness = thickness },
197 { .position = { x, bounds.max.y, 0.F }, .color = color, .thickness = thickness },
198 } };
199 el.bounds_hint = Kinesis::AABB2D {
200 .min = { x - 0.01F, bounds.min.y },
201 .max = { x + 0.01F, bounds.max.y },
202 };
203 } else {
204 const float y = bounds.min.y + t * bounds.height();
205 verts = { {
206 { .position = { bounds.min.x, y, 0.F }, .color = color, .thickness = thickness },
207 { .position = { bounds.max.x, y, 0.F }, .color = color, .thickness = thickness },
208 } };
209 el.bounds_hint = Kinesis::AABB2D {
210 .min = { bounds.min.x, y - 0.01F },
211 .max = { bounds.max.x, y + 0.01F },
212 };
213 }
214 Geometry::write_verts(out, verts);
215 };
216}
Vertex type for line primitives (LINE_LIST / LINE_STRIP topology)
float height() const noexcept
Definition Bounds.hpp:38
float width() const noexcept
Definition Bounds.hpp:37
A bounded, renderable region on a window surface.
Definition Element.hpp:58

References MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, MayaFlux::Kinesis::AABB2D::width(), and MayaFlux::Portal::Forma::Geometry::write_verts().

+ Here is the call graph for this function: