feat: add stroke thickness

This commit is contained in:
2026-03-05 00:51:20 +05:30
parent 8ac783e6e0
commit eefd95e4d2
15 changed files with 379 additions and 356 deletions

View File

@@ -1,57 +1,57 @@
#include "primitives.h"
VektorPolyline *vektor_polyline_new(void) {
VektorPolyline *pl = malloc(sizeof(VektorPolyline));
pl->count = 0;
pl->capacity = 4;
pl->points = malloc(sizeof(V2) * pl->capacity);
return pl;
VektorPolyline *pl = malloc(sizeof(VektorPolyline));
pl->count = 0;
pl->capacity = 4;
pl->points = malloc(sizeof(V2) * pl->capacity);
return pl;
}
void vektor_polyline_add_point(VektorPolyline *pl, V2 point) {
if (pl->count >= pl->capacity) {
pl->capacity *= 2;
pl->points = realloc(pl->points, sizeof(V2) * pl->capacity);
}
pl->points[pl->count++] = point;
if (pl->count >= pl->capacity) {
pl->capacity *= 2;
pl->points = realloc(pl->points, sizeof(V2) * pl->capacity);
}
pl->points[pl->count++] = point;
}
void vektor_polyline_free(VektorPolyline *pl) {
if (!pl)
return;
free(pl->points);
free(pl);
if (!pl)
return;
free(pl->points);
free(pl);
}
VektorPolygon *vektor_polygon_new(void) {
VektorPolygon *pg = malloc(sizeof(VektorPolygon));
pg->count = 0;
pg->capacity = 4;
pg->points = malloc(sizeof(V2) * pg->capacity);
return pg;
VektorPolygon *pg = malloc(sizeof(VektorPolygon));
pg->count = 0;
pg->capacity = 4;
pg->points = malloc(sizeof(V2) * pg->capacity);
return pg;
}
void vektor_polygon_add_point(VektorPolygon *pg, V2 point) {
if (pg->count >= pg->capacity) {
pg->capacity *= 2;
pg->points = realloc(pg->points, sizeof(V2) * pg->capacity);
}
pg->points[pg->count++] = point;
if (pg->count >= pg->capacity) {
pg->capacity *= 2;
pg->points = realloc(pg->points, sizeof(V2) * pg->capacity);
}
pg->points[pg->count++] = point;
}
void vektor_polygon_free(VektorPolygon *pg) {
if (!pg)
return;
free(pg->points);
free(pg);
if (!pg)
return;
free(pg->points);
free(pg);
}
void vektor_primitivebuffer_add_primitive(VektorPrimitiveBuffer *buffer,
VektorPrimitive prim) {
if (buffer->count >= buffer->capacity) {
buffer->capacity = buffer->capacity ? buffer->capacity * 2 : 4;
buffer->primitives =
realloc(buffer->primitives, sizeof(VektorPrimitive) * buffer->capacity);
}
buffer->primitives[buffer->count++] = prim;
if (buffer->count >= buffer->capacity) {
buffer->capacity = buffer->capacity ? buffer->capacity * 2 : 4;
buffer->primitives = realloc(
buffer->primitives, sizeof(VektorPrimitive) * buffer->capacity);
}
buffer->primitives[buffer->count++] = prim;
}