reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL |
| 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY |
| 10 | |
| 11 | #ifndef sk_path_DEFINED |
| 12 | #define sk_path_DEFINED |
| 13 | |
| 14 | #include "sk_types.h" |
| 15 | |
| 16 | SK_C_PLUS_PLUS_BEGIN_GUARD |
| 17 | |
| 18 | typedef enum { |
| 19 | CW_SK_PATH_DIRECTION, |
| 20 | CCW_SK_PATH_DIRECTION, |
| 21 | } sk_path_direction_t; |
| 22 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 23 | /** Create a new, empty path. */ |
Brian Salomon | 7551898 | 2016-12-28 15:56:16 -0500 | [diff] [blame] | 24 | SK_API sk_path_t* sk_path_new(void); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 25 | /** Release the memory used by a sk_path_t. */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 26 | SK_API void sk_path_delete(sk_path_t*); |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 27 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 28 | /** Set the beginning of the next contour to the point (x,y). */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 29 | SK_API void sk_path_move_to(sk_path_t*, float x, float y); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 30 | /** |
| 31 | Add a line from the last point to the specified point (x,y). If no |
| 32 | sk_path_move_to() call has been made for this contour, the first |
| 33 | point is automatically set to (0,0). |
| 34 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 35 | SK_API void sk_path_line_to(sk_path_t*, float x, float y); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 36 | /** |
| 37 | Add a quadratic bezier from the last point, approaching control |
| 38 | point (x0,y0), and ending at (x1,y1). If no sk_path_move_to() call |
| 39 | has been made for this contour, the first point is automatically |
| 40 | set to (0,0). |
| 41 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 42 | SK_API void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 43 | /** |
| 44 | Add a conic curve from the last point, approaching control point |
| 45 | (x0,y01), and ending at (x1,y1) with weight w. If no |
| 46 | sk_path_move_to() call has been made for this contour, the first |
| 47 | point is automatically set to (0,0). |
| 48 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 49 | SK_API void sk_path_conic_to(sk_path_t*, float x0, float y0, float x1, float y1, float w); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 50 | /** |
| 51 | Add a cubic bezier from the last point, approaching control points |
| 52 | (x0,y0) and (x1,y1), and ending at (x2,y2). If no |
| 53 | sk_path_move_to() call has been made for this contour, the first |
| 54 | point is automatically set to (0,0). |
| 55 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 56 | SK_API void sk_path_cubic_to(sk_path_t*, |
| 57 | float x0, float y0, |
| 58 | float x1, float y1, |
| 59 | float x2, float y2); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 60 | /** |
| 61 | Close the current contour. If the current point is not equal to the |
| 62 | first point of the contour, a line segment is automatically added. |
| 63 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 64 | SK_API void sk_path_close(sk_path_t*); |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 65 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 66 | /** |
| 67 | Add a closed rectangle contour to the path. |
| 68 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 69 | SK_API void sk_path_add_rect(sk_path_t*, const sk_rect_t*, sk_path_direction_t); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 70 | /** |
| 71 | Add a closed oval contour to the path |
| 72 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 73 | SK_API void sk_path_add_oval(sk_path_t*, const sk_rect_t*, sk_path_direction_t); |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * If the path is empty, return false and set the rect parameter to [0, 0, 0, 0]. |
| 77 | * else return true and set the rect parameter to the bounds of the control-points |
| 78 | * of the path. |
| 79 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 80 | SK_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*); |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 81 | |
| 82 | SK_C_PLUS_PLUS_END_GUARD |
| 83 | |
| 84 | #endif |