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

◆ plot_grid()

MAYAFLUX_API std::vector< Kakshya::LineVertex > MayaFlux::Portal::Forma::Plot::plot_grid ( Kinesis::AABB2D  bounds,
uint32_t  x_divisions,
uint32_t  y_divisions,
glm::vec3  color = glm::vec3(0.12F),
float  thickness = 1.F 
)

LINE_LIST grid geometry for a plot area.

Produces x_divisions vertical lines and y_divisions horizontal lines evenly distributed within bounds. Intended as a static background buffer.

Parameters
boundsPlot area in NDC.
x_divisionsVertical line count (columns). 0 = no vertical lines.
y_divisionsHorizontal line count (rows). 0 = no horizontal lines.
colorLine color.
thicknessLineVertex::thickness value.

Definition at line 143 of file PlotSpec.cpp.

149{
150 std::vector<Kakshya::LineVertex> out;
151 out.reserve((static_cast<size_t>(x_divisions + y_divisions)) * 2);
152
153 auto lv = [&](glm::vec2 p) {
154 return Kakshya::LineVertex {
155 .position = { p.x, p.y, 0.F },
156 .color = color,
157 .thickness = thickness,
158 };
159 };
160
161 for (uint32_t i = 0; i < x_divisions; ++i) {
162 const float t = (x_divisions > 1)
163 ? static_cast<float>(i) / static_cast<float>(x_divisions - 1)
164 : 0.5F;
165 const float x = bounds.min.x + t * bounds.width();
166 out.push_back(lv({ x, bounds.min.y }));
167 out.push_back(lv({ x, bounds.max.y }));
168 }
169
170 for (uint32_t i = 0; i < y_divisions; ++i) {
171 const float t = (y_divisions > 1)
172 ? static_cast<float>(i) / static_cast<float>(y_divisions - 1)
173 : 0.5F;
174 const float y = bounds.min.y + t * bounds.height();
175 out.push_back(lv({ bounds.min.x, y }));
176 out.push_back(lv({ bounds.max.x, y }));
177 }
178
179 return out;
180}
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

References MayaFlux::Kinesis::AABB2D::height(), MayaFlux::Kinesis::AABB2D::max, MayaFlux::Kinesis::AABB2D::min, MayaFlux::Kakshya::LineVertex::position, and MayaFlux::Kinesis::AABB2D::width().

+ Here is the call graph for this function: