feat: add rasterization primitives

This commit is contained in:
2026-03-04 15:41:20 +05:30
parent e7b99ed918
commit 1c3fc0c4bd
18 changed files with 386 additions and 152 deletions

50
src/core/primitives.h Normal file
View File

@@ -0,0 +1,50 @@
#ifndef PRIMITIVES_H_
#define PRIMITIVES_H_
#include "stddef.h"
#include "stdlib.h"
#include "vector.h"
typedef struct {
V2 p1;
V2 p2;
} Line;
typedef struct {
V2 *points;
size_t count;
size_t capacity;
} Polyline;
typedef struct {
V2 *points;
size_t count;
size_t capacity;
} Polygon;
typedef struct {
V2 center;
double radius;
} Circle;
typedef enum { LINE, POLYLINE, POLYGON, CIRCLE } PrimitiveKind;
typedef struct {
PrimitiveKind kind;
union {
Line line;
Polyline *polyline;
Polygon *polygon;
Circle circle;
};
} Primitive;
Polyline *mk_polyline(void);
void add_point_polyline(Polyline *pl, V2 point);
void free_polyline(Polyline *pl);
Polygon *mk_polygon(void);
void add_point_polygon(Polygon *pl, V2 point);
void free_polygon(Polygon *pl);
#endif // PRIMITIVES_H_