PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
polygon.h
Go to the documentation of this file.
1#ifndef PATCHWORK_POLYGON
2#define PATCHWORK_POLYGON 1
3
4#include "cmd.h"
5#include "font.h"
6#include "pixel.h"
7#include "rect.h"
8#include "surface.h"
9
10#include <stdint.h>
11
12#if defined(__cplusplus)
13extern "C"
14{
15#endif
16
17typedef struct image image_t;
18
19/**
20 * @brief Polygon.
21 * @defgroup libpatchwork_polygon Polygon
22 * @ingroup libpatchwork
23 *
24 * @{
25 */
26
27/**
28 * @brief Rotate a polygon around a center point.
29 *
30 * @param points The points of the polygon.
31 * @param pointCount The number of points in the polygon.
32 * @param angle The angle to rotate by, in radians.
33 * @param center The center point to rotate around.
34 */
35void polygon_rotate(point_t* points, uint64_t pointCount, double angle, point_t center);
36
37/**
38 * @brief Check if a point is inside a polygon.
39 *
40 * We use doubles for the point coordinates instead of just `point_t` to allow for sub-pixel points.
41 *
42 * @param px The x coordinate of the point.
43 * @param py The y coordinate of the point.
44 * @param points The points of the polygon.
45 * @param pointCount The number of points in the polygon.
46 * @return `true` if the point is inside the polygon, `false` otherwise.
47 */
48bool polygon_contains(double px, double py, const point_t* points, uint64_t pointCount);
49
50/** @} */
51
52#if defined(__cplusplus)
53}
54#endif
55
56#endif
void polygon_rotate(point_t *points, uint64_t pointCount, double angle, point_t center)
Rotate a polygon around a center point.
Definition polygon.c:4
bool polygon_contains(double px, double py, const point_t *points, uint64_t pointCount)
Check if a point is inside a polygon.
Definition polygon.c:27
static image_t * image
Definition main.c:5
__UINT64_TYPE__ uint64_t
Definition stdint.h:17