libgpac
Documentation of the core library of GPAC
path2d.c File Reference
#include <gpac/path2d.h>
+ Include dependency graph for path2d.c:

Data Structures

struct  IterInfo
 
struct  GF_PathIterator
 path iterator More...
 

Macros

#define GF_2D_REALLOC(_gp)
 
#define GF_2D_DEFAULT_RES   64
 
#define isLeft(P0, P1, P2)    ( gf_mulfix((P1.x - P0.x), (P2.y - P0.y)) - gf_mulfix((P2.x - P0.x), (P1.y - P0.y)) )
 
#define ConvexCompare(delta)
 
#define ConvexGetPointDelta(delta, pprev, pcur)
 
#define ConvexCross(p, q)   gf_mulfix(p.x,q.y) - gf_mulfix(p.y,q.x);
 
#define ConvexCheckTriple
 

Functions

GF_EXPORT GF_Pathgf_path_new ()
 path constructor More...
 
GF_EXPORT void gf_path_reset (GF_Path *gp)
 path reset More...
 
GF_EXPORT GF_Pathgf_path_clone (GF_Path *gp)
 path copy constuctor More...
 
GF_EXPORT void gf_path_del (GF_Path *gp)
 path destructor More...
 
GF_EXPORT GF_Err gf_path_add_move_to (GF_Path *gp, Fixed x, Fixed y)
 path moveTo More...
 
GF_EXPORT GF_Err gf_path_add_move_to_vec (GF_Path *gp, GF_Point2D *pt)
 starts new contour More...
 
GF_EXPORT GF_Err gf_path_add_line_to (GF_Path *gp, Fixed x, Fixed y)
 adds line to path More...
 
GF_EXPORT GF_Err gf_path_add_line_to_vec (GF_Path *gp, GF_Point2D *pt)
 adds line to path More...
 
GF_EXPORT GF_Err gf_path_close (GF_Path *gp)
 path close More...
 
GF_EXPORT GF_Err gf_path_add_cubic_to (GF_Path *gp, Fixed c1_x, Fixed c1_y, Fixed c2_x, Fixed c2_y, Fixed x, Fixed y)
 adds cubic to path More...
 
GF_EXPORT GF_Err gf_path_add_cubic_to_vec (GF_Path *gp, GF_Point2D *c1, GF_Point2D *c2, GF_Point2D *pt)
 adds cubic to path More...
 
GF_EXPORT GF_Err gf_path_add_quadratic_to (GF_Path *gp, Fixed c_x, Fixed c_y, Fixed x, Fixed y)
 adds quadratic to path More...
 
GF_EXPORT GF_Err gf_path_add_quadratic_to_vec (GF_Path *gp, GF_Point2D *c, GF_Point2D *pt)
 adds quadratic to path More...
 
GF_EXPORT GF_Err gf_path_add_rect_center (GF_Path *gp, Fixed cx, Fixed cy, Fixed w, Fixed h)
 adds rectangle to path More...
 
GF_EXPORT GF_Err gf_path_add_rect (GF_Path *gp, Fixed ox, Fixed oy, Fixed w, Fixed h)
 adds rectangle to path More...
 
GF_EXPORT GF_Err gf_path_add_ellipse (GF_Path *gp, Fixed cx, Fixed cy, Fixed a_axis, Fixed b_axis)
 adds ellipse to path More...
 
GF_Err gf_path_add_subpath (GF_Path *gp, GF_Path *src, GF_Matrix2D *mx)
 concatenates path More...
 
static void NBezier (GF_Point2D *pts, s32 n, Double mu, GF_Point2D *pt_out)
 
static void gf_add_n_bezier (GF_Path *gp, GF_Point2D *newpts, u32 nbPoints)
 
GF_EXPORT GF_Err gf_path_add_bezier (GF_Path *gp, GF_Point2D *pts, u32 nbPoints)
 adds N-1 bezier curve to path More...
 
GF_EXPORT GF_Err gf_path_add_arc_to (GF_Path *gp, Fixed end_x, Fixed end_y, Fixed fa_x, Fixed fa_y, Fixed fb_x, Fixed fb_y, Bool cw)
 adds arc as described in MPEG-4 BIFS to path More...
 
GF_EXPORT GF_Err gf_path_add_svg_arc_to (GF_Path *gp, Fixed end_x, Fixed end_y, Fixed r_x, Fixed r_y, Fixed x_axis_rotation, Bool large_arc_flag, Bool sweep_flag)
 adds arc as described in SVG to path More...
 
GF_EXPORT GF_Err gf_path_add_arc (GF_Path *gp, Fixed radius, Fixed start_angle, Fixed end_angle, GF_Path2DArcCloseType close_type)
 adds arc to path More...
 
GF_EXPORT GF_Err gf_path_get_control_bounds (GF_Path *gp, GF_Rect *rc)
 gets path control bounds More...
 
static void gf_conic_check (Fixed y1, Fixed y2, Fixed y3, Fixed *min, Fixed *max)
 
static void gf_cubic_check (Fixed p1, Fixed p2, Fixed p3, Fixed p4, Fixed *min, Fixed *max)
 
GF_EXPORT GF_Err gf_path_get_bounds (GF_Path *gp, GF_Rect *rc)
 gets path bounds More...
 
static GF_Err gf_subdivide_cubic (GF_Path *gp, Fixed x0, Fixed y0, Fixed x1, Fixed y1, Fixed x2, Fixed y2, Fixed x3, Fixed y3, Fixed fineness)
 
GF_EXPORT GF_Pathgf_path_get_flatten (GF_Path *gp)
 gets flatten copy of path More...
 
GF_EXPORT void gf_path_flatten (GF_Path *gp)
 flattens path More...
 
static void gf_subdivide_cubic_hit_test (Fixed h_x, Fixed h_y, Fixed x0, Fixed y0, Fixed x1, Fixed y1, Fixed x2, Fixed y2, Fixed x3, Fixed y3, s32 *wn)
 
GF_EXPORT Bool gf_path_point_over (GF_Path *gp, Fixed x, Fixed y)
 point over path testing More...
 
GF_EXPORT Bool gf_path_is_empty (GF_Path *gp)
 path init testing More...
 
GF_EXPORT GF_PathIterator * gf_path_iterator_new (GF_Path *gp)
 path iterator constructor More...
 
GF_EXPORT Fixed gf_path_iterator_get_length (GF_PathIterator *it)
 get path length More...
 
GF_EXPORT Bool gf_path_iterator_get_transform (GF_PathIterator *path, Fixed offset, Bool follow_tangent, GF_Matrix2D *mat, Bool smooth_edges, Fixed length_after_point)
 gets transformation matrix at given point on path More...
 
GF_EXPORT void gf_path_iterator_del (GF_PathIterator *it)
 path iterator destructor More...
 
GF_EXPORT u32 gf_polygone2d_get_convexity (GF_Point2D *pts, u32 len)
 

Data Structure Documentation

◆ IterInfo

struct IterInfo
Data Fields
Fixed len
Fixed dx
Fixed dy
Fixed start_x
Fixed start_y

◆ _path_iterator

struct _path_iterator

The path iterator object is used to compute the length of a given path as well as transformation matrices along this path.

+ Collaboration diagram for GF_PathIterator:
Data Fields
u32 num_seg
IterInfo * seg
Fixed length

Macro Definition Documentation

◆ GF_2D_REALLOC

#define GF_2D_REALLOC (   _gp)
Value:
if (_gp->n_alloc_points < _gp->n_points+3) { \
_gp->n_alloc_points = (_gp->n_alloc_points<5) ? 10 : (_gp->n_alloc_points*2); \
_gp->points = (GF_Point2D *)gf_realloc(_gp->points, sizeof(GF_Point2D)*(_gp->n_alloc_points)); \
_gp->tags = (u8 *) gf_realloc(_gp->tags, sizeof(u8)*(_gp->n_alloc_points)); \
} \
2D point
Definition: maths.h:244
void * gf_realloc(void *ptr, size_t size)
Definition: alloc.c:158
uint8_t u8
Definition: setup.h:334

◆ GF_2D_DEFAULT_RES

#define GF_2D_DEFAULT_RES   64

◆ isLeft

#define isLeft (   P0,
  P1,
  P2 
)     ( gf_mulfix((P1.x - P0.x), (P2.y - P0.y)) - gf_mulfix((P2.x - P0.x), (P1.y - P0.y)) )

◆ ConvexCompare

#define ConvexCompare (   delta)
Value:
( (delta.x > 0) ? -1 : \
(delta.x < 0) ? 1 : \
(delta.y > 0) ? -1 : \
(delta.y < 0) ? 1 : \
0 )

◆ ConvexGetPointDelta

#define ConvexGetPointDelta (   delta,
  pprev,
  pcur 
)
Value:
/* Given a previous point 'pprev', read a new point into 'pcur' */ \
/* and return delta in 'delta'. */ \
pcur = pts[iread++]; \
delta.x = pcur.x - pprev.x; \
delta.y = pcur.y - pprev.y; \

◆ ConvexCross

#define ConvexCross (   p,
 
)    gf_mulfix(p.x,q.y) - gf_mulfix(p.y,q.x);

◆ ConvexCheckTriple

#define ConvexCheckTriple
Value:
if ( (thisDir = ConvexCompare(dcur)) == -curDir ) { \
++dirChanges; \
/* if ( dirChanges > 2 ) return NotConvex; */ \
} \
curDir = thisDir; \
cross = ConvexCross(dprev, dcur); \
if ( cross > 0 ) { \
if ( angleSign == -1 ) return GF_POLYGON_COMPLEX_CW; \
angleSign = 1; \
} \
else if (cross < 0) { \
if (angleSign == 1) return GF_POLYGON_COMPLEX_CCW; \
angleSign = -1; \
} \
pSecond = pThird; \
dprev.x = dcur.x; \
dprev.y = dcur.y; \
@ GF_POLYGON_COMPLEX_CW
Definition: path2d.h:485
@ GF_POLYGON_COMPLEX_CCW
Definition: path2d.h:483
#define ConvexCross(p, q)
Definition: path2d.c:1314
#define ConvexCompare(delta)
Definition: path2d.c:1300

Function Documentation

◆ NBezier()

static void NBezier ( GF_Point2D pts,
s32  n,
Double  mu,
GF_Point2D pt_out 
)
static
+ Here is the caller graph for this function:

◆ gf_add_n_bezier()

static void gf_add_n_bezier ( GF_Path gp,
GF_Point2D newpts,
u32  nbPoints 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_conic_check()

static void gf_conic_check ( Fixed  y1,
Fixed  y2,
Fixed  y3,
Fixed min,
Fixed max 
)
static
+ Here is the caller graph for this function:

◆ gf_cubic_check()

static void gf_cubic_check ( Fixed  p1,
Fixed  p2,
Fixed  p3,
Fixed  p4,
Fixed min,
Fixed max 
)
static
+ Here is the caller graph for this function:

◆ gf_subdivide_cubic()

static GF_Err gf_subdivide_cubic ( GF_Path gp,
Fixed  x0,
Fixed  y0,
Fixed  x1,
Fixed  y1,
Fixed  x2,
Fixed  y2,
Fixed  x3,
Fixed  y3,
Fixed  fineness 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_subdivide_cubic_hit_test()

static void gf_subdivide_cubic_hit_test ( Fixed  h_x,
Fixed  h_y,
Fixed  x0,
Fixed  y0,
Fixed  x1,
Fixed  y1,
Fixed  x2,
Fixed  y2,
Fixed  x3,
Fixed  y3,
s32 wn 
)
static
+ Here is the caller graph for this function: