Add documentation to the main msdfgen-core functions

This commit is contained in:
KitsuneAlex 2024-05-04 18:36:33 +02:00
parent 98d4b31601
commit 5b2abedc83
No known key found for this signature in database
GPG Key ID: 6B0CE864BB69B7D0
1 changed files with 102 additions and 36 deletions

View File

@ -163,7 +163,7 @@ MSDF_API const msdf_allocator_t* msdf_allocator_get();
* @param width The width of the bitmap in pixels. * @param width The width of the bitmap in pixels.
* @param height The height of the bitmap in pixels. * @param height The height of the bitmap in pixels.
* @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to allocate a new bitmap into. * @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to allocate a new bitmap into.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_bitmap_alloc(int type, int width, int height, msdf_bitmap_t* bitmap); MSDF_API int msdf_bitmap_alloc(int type, int width, int height, msdf_bitmap_t* bitmap);
@ -171,7 +171,7 @@ MSDF_API int msdf_bitmap_alloc(int type, int width, int height, msdf_bitmap_t* b
* Retrieves the number of color channels used by the given bitmap. * Retrieves the number of color channels used by the given bitmap.
* @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to retrieve the channel count from. * @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to retrieve the channel count from.
* @param channel_count A pointer to a variable which is populated with the number of color channels used by the given bitmap. * @param channel_count A pointer to a variable which is populated with the number of color channels used by the given bitmap.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_bitmap_get_channel_count(const msdf_bitmap_t* bitmap, int* channel_count); MSDF_API int msdf_bitmap_get_channel_count(const msdf_bitmap_t* bitmap, int* channel_count);
@ -179,7 +179,7 @@ MSDF_API int msdf_bitmap_get_channel_count(const msdf_bitmap_t* bitmap, int* cha
* Retrieves the address of the raw pixel data of the given bitmap. * Retrieves the address of the raw pixel data of the given bitmap.
* @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to retrieve the raw pixel data from. * @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to retrieve the raw pixel data from.
* @param pixels A pointer to an address which is populated with the raw pixel data of the given bitmap. * @param pixels A pointer to an address which is populated with the raw pixel data of the given bitmap.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_bitmap_get_pixels(const msdf_bitmap_t* bitmap, void** pixels); MSDF_API int msdf_bitmap_get_pixels(const msdf_bitmap_t* bitmap, void** pixels);
@ -187,7 +187,7 @@ MSDF_API int msdf_bitmap_get_pixels(const msdf_bitmap_t* bitmap, void** pixels);
* Retrieves the size of the pixel data of the given bitmap in bytes. * Retrieves the size of the pixel data of the given bitmap in bytes.
* @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to retrieve the size of the raw pixel data from. * @param bitmap A pointer to an @code msdf_bitmap_t@endcode structure to retrieve the size of the raw pixel data from.
* @param size A pointer to a variable which is populated with the byte size of the raw pixel data of the given bitmap. * @param size A pointer to a variable which is populated with the byte size of the raw pixel data of the given bitmap.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_bitmap_get_byte_size(const msdf_bitmap_t* bitmap, size_t* size); MSDF_API int msdf_bitmap_get_byte_size(const msdf_bitmap_t* bitmap, size_t* size);
@ -203,7 +203,7 @@ MSDF_API void msdf_bitmap_free(msdf_bitmap_t* bitmap);
/** /**
* Allocates a new MSDF shape object using the internal allocator. * Allocates a new MSDF shape object using the internal allocator.
* @param shape A pointer to an address which is populated with the address of the newly allocated shape. * @param shape A pointer to an address which is populated with the address of the newly allocated shape.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_alloc(msdf_shape_handle* shape); MSDF_API int msdf_shape_alloc(msdf_shape_handle* shape);
@ -211,7 +211,7 @@ MSDF_API int msdf_shape_alloc(msdf_shape_handle* shape);
* Retrieves the bounds of the given shape. * Retrieves the bounds of the given shape.
* @param shape A pointer to a shape object to retrieve the bounds from. * @param shape A pointer to a shape object to retrieve the bounds from.
* @param bounds A pointer to a variable which is populated with the bounds of the given shape. * @param bounds A pointer to a variable which is populated with the bounds of the given shape.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_get_bounds(msdf_shape_const_handle shape, msdf_bounds_t* bounds); MSDF_API int msdf_shape_get_bounds(msdf_shape_const_handle shape, msdf_bounds_t* bounds);
@ -219,7 +219,7 @@ MSDF_API int msdf_shape_get_bounds(msdf_shape_const_handle shape, msdf_bounds_t*
* Adds a new contour to the given shape. * Adds a new contour to the given shape.
* @param shape A pointer to a shape object to add a new contour to. * @param shape A pointer to a shape object to add a new contour to.
* @param contour A pointer to an address which is populated with the address of the newly created contour. * @param contour A pointer to an address which is populated with the address of the newly created contour.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_handle* contour); MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_handle* contour);
@ -227,7 +227,7 @@ MSDF_API int msdf_shape_add_contour(msdf_shape_handle shape, msdf_contour_handle
* Retrieves the number of contours allocated within the given shape object. * Retrieves the number of contours allocated within the given shape object.
* @param shape A pointer to a shape object from which to retrieve the contour count. * @param shape A pointer to a shape object from which to retrieve the contour count.
* @param contour_count A pointer to a variable which is populated with the number of contours of the given shape. * @param contour_count A pointer to a variable which is populated with the number of contours of the given shape.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_get_contour_count(msdf_shape_const_handle shape, size_t* contour_count); MSDF_API int msdf_shape_get_contour_count(msdf_shape_const_handle shape, size_t* contour_count);
@ -236,7 +236,7 @@ MSDF_API int msdf_shape_get_contour_count(msdf_shape_const_handle shape, size_t*
* @param shape A pointer to a shape object from which to retrieve a contour. * @param shape A pointer to a shape object from which to retrieve a contour.
* @param index The index of the contour to retrieve. * @param index The index of the contour to retrieve.
* @param contour A pointer to an address which is populated with the address of the contour at the given index if present. * @param contour A pointer to an address which is populated with the address of the contour at the given index if present.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_get_contour(msdf_shape_const_handle shape, size_t index, msdf_contour_const_handle* contour); MSDF_API int msdf_shape_get_contour(msdf_shape_const_handle shape, size_t index, msdf_contour_const_handle* contour);
@ -244,7 +244,7 @@ MSDF_API int msdf_shape_get_contour(msdf_shape_const_handle shape, size_t index,
* Retrieves the number of edges of the given shape. * Retrieves the number of edges of the given shape.
* @param shape A pointer to a shape from which to retrieve the edge count. * @param shape A pointer to a shape from which to retrieve the edge count.
* @param edge_count A pointer to a variable which is populated with the number of edges defined by the given shape. * @param edge_count A pointer to a variable which is populated with the number of edges defined by the given shape.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_get_edge_count(msdf_shape_const_handle shape, size_t* edge_count); MSDF_API int msdf_shape_get_edge_count(msdf_shape_const_handle shape, size_t* edge_count);
@ -253,14 +253,14 @@ MSDF_API int msdf_shape_get_edge_count(msdf_shape_const_handle shape, size_t* ed
* @param shape A pointer to a shape from which to fetch the inverse-y-axis flag. * @param shape A pointer to a shape from which to fetch the inverse-y-axis flag.
* @param inverse_y_axis A pointer to a variable which is populated with @code MSDF_TRUE@endcode when the * @param inverse_y_axis A pointer to a variable which is populated with @code MSDF_TRUE@endcode when the
* y-axis of the given shape is inverted. Otherwise the variable will be set to @code MSDF_FALSE@endcode. * y-axis of the given shape is inverted. Otherwise the variable will be set to @code MSDF_FALSE@endcode.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_has_inverse_y_axis(msdf_shape_const_handle shape, int* inverse_y_axis); MSDF_API int msdf_shape_has_inverse_y_axis(msdf_shape_const_handle shape, int* inverse_y_axis);
/** /**
* Normalizes the given shape. * Normalizes the given shape.
* @param shape A pointer to a shape to normalize. * @param shape A pointer to a shape to normalize.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_normalize(msdf_shape_handle shape); MSDF_API int msdf_shape_normalize(msdf_shape_handle shape);
@ -269,7 +269,7 @@ MSDF_API int msdf_shape_normalize(msdf_shape_handle shape);
* @param shape A pointer to a shape to validate. * @param shape A pointer to a shape to validate.
* @param result A pointer to a variable which is populated with @code MSDF_TRUE@endcode when the * @param result A pointer to a variable which is populated with @code MSDF_TRUE@endcode when the
* validation was successful. Otherwise the variable will be set to @code MSDF_FALSE@endcode. * validation was successful. Otherwise the variable will be set to @code MSDF_FALSE@endcode.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_validate(msdf_shape_handle shape, int* result); MSDF_API int msdf_shape_validate(msdf_shape_handle shape, int* result);
@ -277,7 +277,7 @@ MSDF_API int msdf_shape_validate(msdf_shape_handle shape, int* result);
* Adjusts the given bounding box to fit the given shape. * Adjusts the given bounding box to fit the given shape.
* @param shape A pointer to a shape to fit into the given bounding box. * @param shape A pointer to a shape to fit into the given bounding box.
* @param bounds A pointer to a bounding box which should at least fit the given shape. * @param bounds A pointer to a bounding box which should at least fit the given shape.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_bound(msdf_shape_const_handle shape, msdf_bounds_t* bounds); MSDF_API int msdf_shape_bound(msdf_shape_const_handle shape, msdf_bounds_t* bounds);
@ -288,7 +288,7 @@ MSDF_API int msdf_shape_bound(msdf_shape_const_handle shape, msdf_bounds_t* boun
* @param border The size of the border. * @param border The size of the border.
* @param miter_limit The miter limit value. * @param miter_limit The miter limit value.
* @param polarity The miter polarity. * @param polarity The miter polarity.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_shape_bound_miters(msdf_shape_const_handle shape, msdf_bounds_t* bounds, double border, double miter_limit, int polarity); MSDF_API int msdf_shape_bound_miters(msdf_shape_const_handle shape, msdf_bounds_t* bounds, double border, double miter_limit, int polarity);
@ -304,7 +304,7 @@ MSDF_API void msdf_shape_free(msdf_shape_handle shape);
/** /**
* Allocates a new contour object using the internal allocator. * Allocates a new contour object using the internal allocator.
* @param contour A pointer to an address which is populated with the address of the newly allocated contour object. * @param contour A pointer to an address which is populated with the address of the newly allocated contour object.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_alloc(msdf_contour_handle* contour); MSDF_API int msdf_contour_alloc(msdf_contour_handle* contour);
@ -313,7 +313,7 @@ MSDF_API int msdf_contour_alloc(msdf_contour_handle* contour);
* @param contour A pointer to the contour to add a new edge (segment) to. * @param contour A pointer to the contour to add a new edge (segment) to.
* @param segment A pointer to an address which is populated with the address of the newly * @param segment A pointer to an address which is populated with the address of the newly
* added edge segment. * added edge segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_add_edge(msdf_contour_handle contour, msdf_segment_handle* segment); MSDF_API int msdf_contour_add_edge(msdf_contour_handle contour, msdf_segment_handle* segment);
@ -321,7 +321,7 @@ MSDF_API int msdf_contour_add_edge(msdf_contour_handle contour, msdf_segment_han
* Retrieves the edge count of the given contour. * Retrieves the edge count of the given contour.
* @param contour A pointer to the contour to retrieve the edge count from. * @param contour A pointer to the contour to retrieve the edge count from.
* @param edge_count A pointer to a variable which is populated with the edge count of the given contour. * @param edge_count A pointer to a variable which is populated with the edge count of the given contour.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_get_edge_count(msdf_contour_const_handle contour, size_t* edge_count); MSDF_API int msdf_contour_get_edge_count(msdf_contour_const_handle contour, size_t* edge_count);
@ -331,7 +331,7 @@ MSDF_API int msdf_contour_get_edge_count(msdf_contour_const_handle contour, size
* @param index The index from which to retrieve the edge segment. * @param index The index from which to retrieve the edge segment.
* @param segment A pointer to an address which is populated with the address of the * @param segment A pointer to an address which is populated with the address of the
* edge segment at the given index if present. * edge segment at the given index if present.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_get_edge(msdf_contour_const_handle contour, size_t index, msdf_segment_const_handle* segment); MSDF_API int msdf_contour_get_edge(msdf_contour_const_handle contour, size_t index, msdf_segment_const_handle* segment);
@ -339,7 +339,7 @@ MSDF_API int msdf_contour_get_edge(msdf_contour_const_handle contour, size_t ind
* Adjusts the given bounding box to fit at least the given contour. * Adjusts the given bounding box to fit at least the given contour.
* @param contour A pointer to the contour which should at least fit into the given bounding box. * @param contour A pointer to the contour which should at least fit into the given bounding box.
* @param bounds A pointer to the bounding box to fit the given contour into. * @param bounds A pointer to the bounding box to fit the given contour into.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_bound(msdf_contour_const_handle contour, msdf_bounds_t* bounds); MSDF_API int msdf_contour_bound(msdf_contour_const_handle contour, msdf_bounds_t* bounds);
@ -350,7 +350,7 @@ MSDF_API int msdf_contour_bound(msdf_contour_const_handle contour, msdf_bounds_t
* @param border The size of the border. * @param border The size of the border.
* @param miter_limit The miter limit value. * @param miter_limit The miter limit value.
* @param polarity The miter polarity. * @param polarity The miter polarity.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int MSDF_API int
msdf_contour_bound_miters(msdf_contour_const_handle contour, msdf_bounds_t* bounds, double border, double miter_limit, int polarity); msdf_contour_bound_miters(msdf_contour_const_handle contour, msdf_bounds_t* bounds, double border, double miter_limit, int polarity);
@ -359,14 +359,14 @@ MSDF_API int
* Retrieves the winding direction of the given contour. * Retrieves the winding direction of the given contour.
* @param contour A pointer to the contour of which to retrieve the winding direction. * @param contour A pointer to the contour of which to retrieve the winding direction.
* @param winding A pointer to a variables which is populated with the winding direction of the given contour. * @param winding A pointer to a variables which is populated with the winding direction of the given contour.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_get_winding(msdf_contour_const_handle contour, int* winding); MSDF_API int msdf_contour_get_winding(msdf_contour_const_handle contour, int* winding);
/** /**
* Reverses the order of edges in the given contour. * Reverses the order of edges in the given contour.
* @param contour A pointer to the contour which to reverse the edge order for. * @param contour A pointer to the contour which to reverse the edge order for.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_contour_reverse(msdf_contour_handle contour); MSDF_API int msdf_contour_reverse(msdf_contour_handle contour);
@ -386,7 +386,7 @@ MSDF_API void msdf_contour_free(msdf_contour_handle contour);
* @code MSDF_SEGMENT_TYPE_QUADRATIC@endcode or @code MSDF_SEGMENT_TYPE_CUBIC@endcode. * @code MSDF_SEGMENT_TYPE_QUADRATIC@endcode or @code MSDF_SEGMENT_TYPE_CUBIC@endcode.
* @param segment A pointer to an address which is populated with the address of the newly * @param segment A pointer to an address which is populated with the address of the newly
* allocated segment. * allocated segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_alloc(int type, msdf_segment_handle* segment); MSDF_API int msdf_segment_alloc(int type, msdf_segment_handle* segment);
@ -394,7 +394,7 @@ MSDF_API int msdf_segment_alloc(int type, msdf_segment_handle* segment);
* Retrieves the type of the given segment. * Retrieves the type of the given segment.
* @param segment A pointer to the segment of which to retrieve the type. * @param segment A pointer to the segment of which to retrieve the type.
* @param type A pointer to a variable which is populated with the type of the given segment. * @param type A pointer to a variable which is populated with the type of the given segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_get_type(msdf_segment_const_handle segment, int* type); MSDF_API int msdf_segment_get_type(msdf_segment_const_handle segment, int* type);
@ -402,7 +402,7 @@ MSDF_API int msdf_segment_get_type(msdf_segment_const_handle segment, int* type)
* Retrieves the point count of the given segment. * Retrieves the point count of the given segment.
* @param segment A pointer to the segment of which to retrieve the number of points. * @param segment A pointer to the segment of which to retrieve the number of points.
* @param point_count A pointer to a variable which is populated with * @param point_count A pointer to a variable which is populated with
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_get_point_count(msdf_segment_const_handle segment, size_t* point_count); MSDF_API int msdf_segment_get_point_count(msdf_segment_const_handle segment, size_t* point_count);
@ -412,7 +412,7 @@ MSDF_API int msdf_segment_get_point_count(msdf_segment_const_handle segment, siz
* @param index The index of the point to retrieve. * @param index The index of the point to retrieve.
* @param point A pointer to a point which is populated with the coordinates of the point * @param point A pointer to a point which is populated with the coordinates of the point
* at the given index if present. * at the given index if present.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_get_point(msdf_segment_const_handle segment, size_t index, msdf_vector2_t* point); MSDF_API int msdf_segment_get_point(msdf_segment_const_handle segment, size_t index, msdf_vector2_t* point);
@ -421,7 +421,7 @@ MSDF_API int msdf_segment_get_point(msdf_segment_const_handle segment, size_t in
* @param segment A pointer to the segment of which to set the point. * @param segment A pointer to the segment of which to set the point.
* @param index The index of the point to set. * @param index The index of the point to set.
* @param point A pointer to a point which is copied to the given index within the segment. * @param point A pointer to a point which is copied to the given index within the segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_set_point(msdf_segment_handle segment, size_t index, const msdf_vector2_t* point); MSDF_API int msdf_segment_set_point(msdf_segment_handle segment, size_t index, const msdf_vector2_t* point);
@ -429,7 +429,7 @@ MSDF_API int msdf_segment_set_point(msdf_segment_handle segment, size_t index, c
* Sets the color of the given segment. * Sets the color of the given segment.
* @param segment A pointer to the segment of which to set the color. * @param segment A pointer to the segment of which to set the color.
* @param color The color to set. Can be any @code MSDF_COLOR_@endcode value. * @param color The color to set. Can be any @code MSDF_COLOR_@endcode value.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_set_color(msdf_segment_handle segment, int color); MSDF_API int msdf_segment_set_color(msdf_segment_handle segment, int color);
@ -438,7 +438,7 @@ MSDF_API int msdf_segment_set_color(msdf_segment_handle segment, int color);
* @param segment A pointer to the segment of which to retrieve the color. * @param segment A pointer to the segment of which to retrieve the color.
* @param color A pointer to a variable which is populated with the color of the given segment. * @param color A pointer to a variable which is populated with the color of the given segment.
* Will be one of the constants prefixed with @code MSDF_COLOR_@endcode. * Will be one of the constants prefixed with @code MSDF_COLOR_@endcode.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_get_color(msdf_segment_const_handle segment, int* color); MSDF_API int msdf_segment_get_color(msdf_segment_const_handle segment, int* color);
@ -448,7 +448,7 @@ MSDF_API int msdf_segment_get_color(msdf_segment_const_handle segment, int* colo
* @param param The point at which to retrieve the segment direction. * @param param The point at which to retrieve the segment direction.
* @param direction A pointer to a variable which is populated with the direction of the given * @param direction A pointer to a variable which is populated with the direction of the given
* segment at the given point. * segment at the given point.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_get_direction(msdf_segment_const_handle segment, double param, msdf_vector2_t* direction); MSDF_API int msdf_segment_get_direction(msdf_segment_const_handle segment, double param, msdf_vector2_t* direction);
@ -458,7 +458,7 @@ MSDF_API int msdf_segment_get_direction(msdf_segment_const_handle segment, doubl
* @param param The point at which to retrieve the segment direction change. * @param param The point at which to retrieve the segment direction change.
* @param direction_change A pointer to a variable which is populated with the direction change * @param direction_change A pointer to a variable which is populated with the direction change
* of the given segment at the given point. * of the given segment at the given point.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_get_direction_change(msdf_segment_const_handle segment, double param, msdf_vector2_t* direction_change); MSDF_API int msdf_segment_get_direction_change(msdf_segment_const_handle segment, double param, msdf_vector2_t* direction_change);
@ -468,7 +468,7 @@ MSDF_API int msdf_segment_get_direction_change(msdf_segment_const_handle segment
* @param param The point at which to sample. * @param param The point at which to sample.
* @param point A pointer to a variable which is populated with the edge point * @param point A pointer to a variable which is populated with the edge point
* at the given location from the given segment. * at the given location from the given segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_point(msdf_segment_const_handle segment, double param, msdf_vector2_t* point); MSDF_API int msdf_segment_point(msdf_segment_const_handle segment, double param, msdf_vector2_t* point);
@ -476,7 +476,7 @@ MSDF_API int msdf_segment_point(msdf_segment_const_handle segment, double param,
* Adjusts the given bounding box to fit at least the given segment. * Adjusts the given bounding box to fit at least the given segment.
* @param segment A pointer to the segment which should at least fit in the given bounding box. * @param segment A pointer to the segment which should at least fit in the given bounding box.
* @param bounds A pointer to the bounding box which should at least fit the given segment. * @param bounds A pointer to the bounding box which should at least fit the given segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_bound(msdf_segment_const_handle segment, msdf_bounds_t* bounds); MSDF_API int msdf_segment_bound(msdf_segment_const_handle segment, msdf_bounds_t* bounds);
@ -484,7 +484,7 @@ MSDF_API int msdf_segment_bound(msdf_segment_const_handle segment, msdf_bounds_t
* Moves the start point of the given segment. * Moves the start point of the given segment.
* @param segment A pointer to the segment of which to adjust the start point. * @param segment A pointer to the segment of which to adjust the start point.
* @param point A pointer to the new start point of the given segment. * @param point A pointer to the new start point of the given segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_move_start_point(msdf_segment_handle segment, const msdf_vector2_t* point); MSDF_API int msdf_segment_move_start_point(msdf_segment_handle segment, const msdf_vector2_t* point);
@ -492,7 +492,7 @@ MSDF_API int msdf_segment_move_start_point(msdf_segment_handle segment, const ms
* Moves the end point of the given segment. * Moves the end point of the given segment.
* @param segment A pointer to the segment of which to adjust the end point. * @param segment A pointer to the segment of which to adjust the end point.
* @param point A pointer to the new end point of the given segment. * @param point A pointer to the new end point of the given segment.
* @returns @code MSDF_SUCCESS@endcode on success, one of the constants prefixed with @code MSDF_ERR_@endcode. * @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/ */
MSDF_API int msdf_segment_move_end_point(msdf_segment_handle segment, const msdf_vector2_t* point); MSDF_API int msdf_segment_move_end_point(msdf_segment_handle segment, const msdf_vector2_t* point);
@ -505,23 +505,89 @@ MSDF_API void msdf_segment_free(msdf_segment_handle segment);
// msdfgen-core API functions // msdfgen-core API functions
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_SDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_sdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform); MSDF_API int msdf_generate_sdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_PSDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_psdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform); MSDF_API int msdf_generate_psdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_MSDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_msdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform); MSDF_API int msdf_generate_msdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_MTSDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_mtsdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform); MSDF_API int msdf_generate_mtsdf(msdf_bitmap_t* output, msdf_shape_const_handle shape, const msdf_transform_t* transform);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_SDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @param config A pointer to the config which is applied to the sprite generator before rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_sdf_with_config(msdf_bitmap_t* output, MSDF_API int msdf_generate_sdf_with_config(msdf_bitmap_t* output,
msdf_shape_const_handle shape, msdf_shape_const_handle shape,
const msdf_transform_t* transform, const msdf_transform_t* transform,
const msdf_config_t* config); const msdf_config_t* config);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_PSDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @param config A pointer to the config which is applied to the sprite generator before rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_psdf_with_config(msdf_bitmap_t* output, MSDF_API int msdf_generate_psdf_with_config(msdf_bitmap_t* output,
msdf_shape_const_handle shape, msdf_shape_const_handle shape,
const msdf_transform_t* transform, const msdf_transform_t* transform,
const msdf_config_t* config); const msdf_config_t* config);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_MSDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @param config A pointer to the config which is applied to the sprite generator before rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_msdf_with_config(msdf_bitmap_t* output, MSDF_API int msdf_generate_msdf_with_config(msdf_bitmap_t* output,
msdf_shape_const_handle shape, msdf_shape_const_handle shape,
const msdf_transform_t* transform, const msdf_transform_t* transform,
const msdf_multichannel_config_t* config); const msdf_multichannel_config_t* config);
/**
* @param output A pointer to a bitmap that was allocated with @code msdf_bitmap_alloc@endcode to which
* the given shape is rendered. The bitmap must be of type @code MSDF_BITMAP_TYPE_MTSDF@endcode.
* @param shape A pointer to the shape to render to the given bitmap.
* @param transform The transform which is applied to the given shape during rendering.
* @param config A pointer to the config which is applied to the sprite generator before rendering.
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
*/
MSDF_API int msdf_generate_mtsdf_with_config(msdf_bitmap_t* output, MSDF_API int msdf_generate_mtsdf_with_config(msdf_bitmap_t* output,
msdf_shape_const_handle shape, msdf_shape_const_handle shape,
const msdf_transform_t* transform, const msdf_transform_t* transform,