12 if (input.
points.size() < 3) {
13 error =
"points needs at least three x y pairs";
16 const auto region =
region_of(placement, error);
21 if (triangles.empty()) {
22 error =
"the outline does not form a valid region";
28 [unit = input.
points, triangles, region = *region, color = input.
color,
29 horizontal = input.
horizontal](
const float& value, std::vector<uint8_t>& out) {
30 const float scale = std::clamp(value, 0.F, 1.F);
31 std::vector<Kakshya::Vertex> verts;
32 verts.reserve(triangles.size() * 3);
33 for (const auto& triangle : triangles) {
34 for (const uint32_t k : triangle) {
35 glm::vec2 point = unit[k];
36 (horizontal ? point.x : point.y) *= scale;
37 const glm::vec2 ndc = region.point_at(point);
38 verts.push_back(Kakshya::Vertex {
39 .position = { ndc.x, ndc.y, 0.F },
57 if (input.
points.size() < 2) {
58 error =
"points needs at least two x y pairs";
61 for (
const glm::vec2 point : input.
points) {
62 if (point.x < 0.F || point.x > 1.F || point.y < 0.F || point.y > 1.F) {
63 error =
"points must lie in the unit square";
68 error =
"thickness and handle_size may not be negative";
72 error =
"grab_radius needs to be positive";
75 const auto region =
region_of(placement, error);
std::vector< MeshVertex > to_mesh_vertices(std::span< const Vertex > vertices, glm::vec2 weight_range)
Batch-project raw Vertex vector to MeshVertex.
std::vector< std::array< uint32_t, 3 > > triangulate_polygon(std::span< const glm::vec2 > pts, std::span< const uint32_t > hole_starts)
Ear-clipping triangulation of a polygon with optional holes, as index triples.
std::function< float(glm::vec2)> axis_fraction(AABB2D bounds, float handle_extent=0.F, bool horizontal=true, const std::function< glm::vec2()> &live_offset={}) noexcept
Fraction along one axis of bounds, inverse to fader placement.
Vertex type for indexed triangle mesh primitives (TRIANGLE_LIST topology).