📄 path2d.h
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) Jean Le Feuvre 2000-2005 * All rights reserved * * This file is part of GPAC / common tools sub-project * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */#ifndef _GF_PATH2D_H_#define _GF_PATH2D_H_/*! * \file <gpac/path2d.h> * \brief 2D Vectorial Path functions. */#ifdef __cplusplusextern "C" {#endif#include <gpac/math.h>#include <gpac/constants.h>/*! *\addtogroup path_grp path2d *\ingroup utils_grp *\brief Vectorial 2D Path manipulation functions * *This section documents the 2D path object used in the GPAC framework. * @{ */ /*!\brief 2D Path Object * *The 2D path object is used to construct complex 2D shapes for later drawing * or outlining. */typedef struct{ /*! number of contours in path*/ u32 n_contours; /*! number of points in path and alloc size*/ u32 n_points, n_alloc_points; /*! path points */ GF_Point2D *points; /*! point tags (one per point)*/ u8 *tags; /*! contour end points*/ u32 *contours; /*! path bbox - NEVER USE WITHOUT FIRST CALLING \ref gf_path_get_bounds*/ GF_Rect bbox; /*! path flags*/ s32 flags; /*! fineness to use whenever flattening the path - default is \ref FIX_ONE*/ Fixed fineness;} GF_Path;/*! * \brief path constructor * * Constructs an empty 2D path object * \return new path object */GF_Path *gf_path_new();/*! * \brief path destructor * * Destructs a 2D path object * \param gp the target path */void gf_path_del(GF_Path *gp);/*! * \brief path reset * * Resets the 2D path object * \param gp the target path */void gf_path_reset(GF_Path *gp);/*! * \brief path copy constuctor * * Resets a copy of a 2D path object * \param gp the target path * \return new path copy */GF_Path *gf_path_clone(GF_Path *gp);/*! * \brief path close * * Closes current path contour * \param gp the target path * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_close(GF_Path *gp);/*! * \brief path moveTo * * Starts a new contour from the specified point * \param gp the target path * \param x x-coordinate of the new point * \param y y-coordinate of the new point * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_move_to(GF_Path *gp, Fixed x, Fixed y);/*! * \brief starts new contour * * Starts a new contour from the specified point * \param gp the target path * \param pt pointer to the new start point * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_move_to_vec(GF_Path *gp, GF_Point2D *pt);/*! * \brief adds line to path * * Adds a line from the current point in path to the specified point * \param gp the target path * \param x x-coordinate of the line end * \param y y-coordinate of the line end * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_line_to(GF_Path *gp, Fixed x, Fixed y);/*! * \brief adds line to path * * Adds a line from the current point in path to the specified point * \param gp the target path * \param pt line end * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_line_to_vec(GF_Path *gp, GF_Point2D *pt);/*! * \brief adds cubic to path * * Adds a cubic bezier curve to the current contour, starting from the current path point * \param gp the target path * \param c1_x x-coordinate of the first control point of the cubic curve * \param c1_y y-coordinate of the first control point of the cubic curve * \param c2_x x-coordinate of the second control point of the cubic curve * \param c2_y y-coordinate of the second control point of the cubic curve * \param x x-coordinate of the end point of the cubic curve * \param y y-coordinate of the end point of the cubic curve * \return error code if any error, \ref GF_OK otherwise */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);/*! * \brief adds cubic to path * * Adds a cubic bezier curve to the current contour, starting from the current path point * \param gp the target path * \param c1 first control point of the cubic curve * \param c2 second control point of the cubic curve * \param pt end point of the cubic curve * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_cubic_to_vec(GF_Path *gp, GF_Point2D *c1, GF_Point2D *c2, GF_Point2D *pt);/*! * \brief adds quadratic to path * * Adds a quadratic bezier curve to the current contour, starting from the current path point * \param gp the target path * \param c_x x-coordinate of the control point of the quadratic curve * \param c_y y-coordinate of the control point of the quadratic curve * \param x x-coordinate of the end point of the cubic quadratic * \param y y-coordinate of the end point of the cubic quadratic * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_quadratic_to(GF_Path *gp, Fixed c_x, Fixed c_y, Fixed x, Fixed y);/*! * \brief adds quadratic to path * * Adds a quadratic bezier curve to the current contour, starting from the current path point * \param gp the target path * \param c control point of the quadratic curve * \param pt end point of the cubic quadratic * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_quadratic_to_vec(GF_Path *gp, GF_Point2D *c, GF_Point2D *pt);/*! * \brief adds rectangle to path * * Adds a rectangle contour to the path * \param gp the target path * \param cx x-coordinate of the rectangle center * \param cy y-coordinate of the rectangle center * \param w width of the rectangle * \param h height of the rectangle * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_rect_center(GF_Path *gp, Fixed cx, Fixed cy, Fixed w, Fixed h);/*! * \brief adds rectangle to path * * Adds a rectangle contour to the path * \param gp the target path * \param ox left-most coordinate of the rectangle * \param oy top-most coordinate of the rectangle * \param w width of the rectangle * \param h height of the rectangle * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_rect(GF_Path *gp, Fixed ox, Fixed oy, Fixed w, Fixed h);/*! * \brief adds ellipse to path * * Adds an ellipse contour to the path * \param gp the target path * \param cx x-coordinate of the ellipse center * \param cy y-coordinate of the ellipse center * \param a_axis length of the horizontal ellipse axis * \param b_axis length of the vertical ellipse axis * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_ellipse(GF_Path *gp, Fixed cx, Fixed cy, Fixed a_axis, Fixed b_axis);/*! * \brief adds N-bezier curve to path * * Adds an N-degree bezier curve to the path, starting from the current point * \param gp the target path * \param pts points used to define the curve * \param nb_pts number of points used to define the curve. The degree of the curve is therefore (nb_pts-1). * \return error code if any error, \ref GF_OK otherwise * \note the fineness of the path must be set before calling this function. */GF_Err gf_path_add_bezier(GF_Path *gp, GF_Point2D *pts, u32 nb_pts);/*! * \brief adds arc to path * * Adds an arc contour to the path from focal and end points. * \param gp the target path * \param end_x x-coordinate of the arc end point * \param end_y y-coordinate of the arc end point * \param fa_x x-coordinate of the arc first focal point * \param fa_y y-coordinate of the arc first focal point * \param fb_x x-coordinate of the arc second focal point * \param fb_y y-coordinate of the arc second focal point * \param cw if 1, the arc will be clockwise, otherwise counter-clockwise. * \return error code if any error, \ref GF_OK otherwise */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);/*! * \brief adds arc to path * * Adds an arc contour to the path. * \param gp the target path * \param radius radius of the arc * \param start_angle start angle of the arc in radians * \param end_angle end angle of the arc in radians * \param close_type closing type: 0 for open arc, 1 for close arc, 2 for pie * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_add_arc(GF_Path *gp, Fixed radius, Fixed start_angle, Fixed end_angle, u32 close_type);/*! * \brief gets path control bounds * * Gets the path control bounds, i.e. the rectangle covering all lineTo and bezier control points. * \param gp the target path * \param rc pointer to rectangle receiving the control rectangle * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_get_control_bounds(GF_Path *gp, GF_Rect *rc);/*! * \brief gets path bounds * * Gets the path bounds, i.e. the rectangle covering all points in path except bezier control points. * \param gp the target path * \param rc pointer to rectangle receiving the control rectangle * \return error code if any error, \ref GF_OK otherwise */GF_Err gf_path_get_bounds(GF_Path *gp, GF_Rect *rc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -