feat(untested): add handle dragging

This commit is contained in:
Beriff
2026-03-12 11:20:43 +07:00
parent f96d6066ee
commit 7bc94d3a96
5 changed files with 80 additions and 21 deletions

View File

@@ -207,8 +207,6 @@ void vektor_rectangle_create_handles(VektorRectangle* rectangle, V2** handleArr,
V2 halfdist = vec2_scale(vec2_sub(rectangle->end, rectangle->start), 0.5f);
V2 center = vec2_add(rectangle->start, halfdist);
g_print("boobs: %f %f\n", rectangle->start.x, rectangle->start.y);
g_print("pussy: %f %f\n", rectangle->end.x, rectangle->end.y);
(*handleArr)[0] = center;
(*handleArr)[1] = vec2_add(center, vec2_mul(halfdist, (V2){-1.0f, 1.0f}));
@@ -238,6 +236,23 @@ void vektor_shape_create_handles(VektorShape* shape) {
}
}
// ------ AUXILIARY HANDLE METHODS ------
void vektor_shape_add_handle(VektorShape* shape, V2 handle) {
// could be optimised with capacity property
// but this function is only called when adding new
// points to polyline and polygon, so it should
// not be that much of an overhead
shape->handles =
realloc(shape->handles, sizeof(V2) * shape->handleCount + 1);
shape->handles[shape->handleCount++] = handle;
}
VektorBBox vektor_shape_get_handle_bbox(V2 handle) {
return vektor_bbox_fromcenter(handle, 0.02);
}
// ------ PRIMITIVE HANDLES UPDATING ------
void vektor_polyline_handles_updated(VektorPolyline* polyline, V2** handles,
@@ -335,16 +350,6 @@ void vektor_shape_handles_updated(VektorShape* shape) {
}
}
void vektor_shape_add_handle(VektorShape* shape, V2 handle) {
// could be optimised with capacity property
// but this function is only called when adding new
// points to polyline and polygon, so it should
// not be that much of an overhead
shape->handles =
realloc(shape->handles, sizeof(V2) * shape->handleCount + 1);
shape->handles[shape->handleCount++] = handle;
}
// ------ BBOX METHODS ------
bool vektor_bbox_isinside(VektorBBox bbox, V2 point) {