1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9cb93a386Sopenharmony_ci// DO NOT USE -- FOR INTERNAL TESTING ONLY 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#ifndef sk_path_DEFINED 12cb93a386Sopenharmony_ci#define sk_path_DEFINED 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_ci#include "include/c/sk_types.h" 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_BEGIN_GUARD 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_citypedef enum { 19cb93a386Sopenharmony_ci CW_SK_PATH_DIRECTION, 20cb93a386Sopenharmony_ci CCW_SK_PATH_DIRECTION, 21cb93a386Sopenharmony_ci} sk_path_direction_t; 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_citypedef struct sk_pathbuilder_t sk_pathbuilder_t; 24cb93a386Sopenharmony_ci 25cb93a386Sopenharmony_ci/** Create a new, empty path. */ 26cb93a386Sopenharmony_ciSK_API sk_pathbuilder_t* sk_pathbuilder_new(void); 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_ci/** Release the memory used by a sk_pathbuilder_t. */ 29cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_delete(sk_pathbuilder_t*); 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci/** Set the beginning of the next contour to the point (x,y). */ 32cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_move_to(sk_pathbuilder_t*, float x, float y); 33cb93a386Sopenharmony_ci/** 34cb93a386Sopenharmony_ci Add a line from the last point to the specified point (x,y). If no 35cb93a386Sopenharmony_ci sk_pathbuilder_move_to() call has been made for this contour, the first 36cb93a386Sopenharmony_ci point is automatically set to (0,0). 37cb93a386Sopenharmony_ci*/ 38cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_line_to(sk_pathbuilder_t*, float x, float y); 39cb93a386Sopenharmony_ci/** 40cb93a386Sopenharmony_ci Add a quadratic bezier from the last point, approaching control 41cb93a386Sopenharmony_ci point (x0,y0), and ending at (x1,y1). If no sk_pathbuilder_move_to() call 42cb93a386Sopenharmony_ci has been made for this contour, the first point is automatically 43cb93a386Sopenharmony_ci set to (0,0). 44cb93a386Sopenharmony_ci*/ 45cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_quad_to(sk_pathbuilder_t*, float x0, float y0, float x1, float y1); 46cb93a386Sopenharmony_ci/** 47cb93a386Sopenharmony_ci Add a conic curve from the last point, approaching control point 48cb93a386Sopenharmony_ci (x0,y01), and ending at (x1,y1) with weight w. If no 49cb93a386Sopenharmony_ci sk_pathbuilder_move_to() call has been made for this contour, the first 50cb93a386Sopenharmony_ci point is automatically set to (0,0). 51cb93a386Sopenharmony_ci*/ 52cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_conic_to(sk_pathbuilder_t*, float x0, float y0, float x1, float y1, float w); 53cb93a386Sopenharmony_ci/** 54cb93a386Sopenharmony_ci Add a cubic bezier from the last point, approaching control points 55cb93a386Sopenharmony_ci (x0,y0) and (x1,y1), and ending at (x2,y2). If no 56cb93a386Sopenharmony_ci sk_pathbuilder_move_to() call has been made for this contour, the first 57cb93a386Sopenharmony_ci point is automatically set to (0,0). 58cb93a386Sopenharmony_ci*/ 59cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_cubic_to(sk_pathbuilder_t*, 60cb93a386Sopenharmony_ci float x0, float y0, 61cb93a386Sopenharmony_ci float x1, float y1, 62cb93a386Sopenharmony_ci float x2, float y2); 63cb93a386Sopenharmony_ci/** 64cb93a386Sopenharmony_ci Close the current contour. If the current point is not equal to the 65cb93a386Sopenharmony_ci first point of the contour, a line segment is automatically added. 66cb93a386Sopenharmony_ci*/ 67cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_close(sk_pathbuilder_t*); 68cb93a386Sopenharmony_ci 69cb93a386Sopenharmony_ci/** 70cb93a386Sopenharmony_ci Add a closed rectangle contour to the path. 71cb93a386Sopenharmony_ci*/ 72cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_add_rect(sk_pathbuilder_t*, const sk_rect_t*, sk_path_direction_t); 73cb93a386Sopenharmony_ci/** 74cb93a386Sopenharmony_ci Add a closed oval contour to the path 75cb93a386Sopenharmony_ci*/ 76cb93a386Sopenharmony_ciSK_API void sk_pathbuilder_add_oval(sk_pathbuilder_t*, const sk_rect_t*, sk_path_direction_t); 77cb93a386Sopenharmony_ci 78cb93a386Sopenharmony_ci/**** path *****/ 79cb93a386Sopenharmony_ci 80cb93a386Sopenharmony_ci/** 81cb93a386Sopenharmony_ci* Return a Path from the builder, resetting the builder to its original empty state. 82cb93a386Sopenharmony_ci*/ 83cb93a386Sopenharmony_ciSK_API sk_path_t* sk_pathbuilder_detach_path(sk_pathbuilder_t*); 84cb93a386Sopenharmony_ci 85cb93a386Sopenharmony_ci/** 86cb93a386Sopenharmony_ci * Return a Path from the builder. The builder reamins in its current state. 87cb93a386Sopenharmony_ci */ 88cb93a386Sopenharmony_ciSK_API sk_path_t* sk_pathbuilder_snapshot_path(sk_pathbuilder_t*); 89cb93a386Sopenharmony_ci 90cb93a386Sopenharmony_ci/** Release the memory used by a sk_path_t. */ 91cb93a386Sopenharmony_ciSK_API void sk_path_delete(sk_path_t*); 92cb93a386Sopenharmony_ci 93cb93a386Sopenharmony_ci/** 94cb93a386Sopenharmony_ci * If the path is empty, return false and set the rect parameter to [0, 0, 0, 0]. 95cb93a386Sopenharmony_ci * else return true and set the rect parameter to the bounds of the control-points 96cb93a386Sopenharmony_ci * of the path. 97cb93a386Sopenharmony_ci */ 98cb93a386Sopenharmony_ciSK_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*); 99cb93a386Sopenharmony_ci 100cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_END_GUARD 101cb93a386Sopenharmony_ci 102cb93a386Sopenharmony_ci#endif 103