mirror of https://github.com/Chlumsky/msdfgen.git
Add msdf_shape_one_shot_distance function
This commit is contained in:
parent
79c242ae0b
commit
241d109db6
|
|
@ -13,7 +13,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../msdfgen-c.h"
|
#include "../msdfgen-c.h"
|
||||||
|
|
||||||
#include "../msdfgen.h"
|
#include "../msdfgen.h"
|
||||||
|
#include "ShapeDistanceFinder.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
@ -298,6 +300,15 @@ MSDF_API int msdf_shape_edge_colors_by_distance(msdf_shape_handle shape, const d
|
||||||
return MSDF_SUCCESS;
|
return MSDF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MSDF_API int msdf_shape_one_shot_distance(msdf_shape_const_handle shape, const msdf_vector2_t* origin, double* distance) {
|
||||||
|
if(shape == nullptr || origin == nullptr) {
|
||||||
|
return MSDF_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
*distance = msdfgen::SimpleTrueShapeDistanceFinder::oneShotDistance(*reinterpret_cast<const msdfgen::Shape*>(shape),
|
||||||
|
*reinterpret_cast<const msdfgen::Point2*>(origin));
|
||||||
|
return MSDF_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
MSDF_API void msdf_shape_free(msdf_shape_handle shape) {
|
MSDF_API void msdf_shape_free(msdf_shape_handle shape) {
|
||||||
delete reinterpret_cast<msdfgen::Shape*>(shape);
|
delete reinterpret_cast<msdfgen::Shape*>(shape);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
msdfgen-c.h
10
msdfgen-c.h
|
|
@ -319,6 +319,16 @@ MSDF_API int msdf_shape_edge_colors_ink_trap(msdf_shape_handle shape, double ang
|
||||||
*/
|
*/
|
||||||
MSDF_API int msdf_shape_edge_colors_by_distance(msdf_shape_handle shape, double angle_threshold);
|
MSDF_API int msdf_shape_edge_colors_by_distance(msdf_shape_handle shape, double angle_threshold);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the distance between shape and origin.
|
||||||
|
* Does not allocate result cache used to optimize performance of multiple queries.
|
||||||
|
* @param shape A pointer to the shape to find the distance to.
|
||||||
|
* @param origin The point to find the distance relative to the given shape to.
|
||||||
|
* @param distance A pointer to a variable to be populated with the calculated distance to the given shape.
|
||||||
|
* @returns @code MSDF_SUCCESS@endcode on success, otherwise one of the constants prefixed with @code MSDF_ERR_@endcode.
|
||||||
|
*/
|
||||||
|
MSDF_API int msdf_shape_one_shot_distance(msdf_shape_const_handle shape, const msdf_vector2_t* origin, double* distance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the destructor of the given bitmap and frees its memory using the
|
* Calls the destructor of the given bitmap and frees its memory using the
|
||||||
* internal allocator.
|
* internal allocator.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue