sk_path.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
  8. // DO NOT USE -- FOR INTERNAL TESTING ONLY
  9. #ifndef sk_path_DEFINED
  10. #define sk_path_DEFINED
  11. #include "include/c/sk_types.h"
  12. SK_C_PLUS_PLUS_BEGIN_GUARD
  13. typedef enum {
  14. CW_SK_PATH_DIRECTION,
  15. CCW_SK_PATH_DIRECTION,
  16. } sk_path_direction_t;
  17. /** Create a new, empty path. */
  18. SK_API sk_path_t* sk_path_new(void);
  19. /** Release the memory used by a sk_path_t. */
  20. SK_API void sk_path_delete(sk_path_t*);
  21. /** Set the beginning of the next contour to the point (x,y). */
  22. SK_API void sk_path_move_to(sk_path_t*, float x, float y);
  23. /**
  24. Add a line from the last point to the specified point (x,y). If no
  25. sk_path_move_to() call has been made for this contour, the first
  26. point is automatically set to (0,0).
  27. */
  28. SK_API void sk_path_line_to(sk_path_t*, float x, float y);
  29. /**
  30. Add a quadratic bezier from the last point, approaching control
  31. point (x0,y0), and ending at (x1,y1). If no sk_path_move_to() call
  32. has been made for this contour, the first point is automatically
  33. set to (0,0).
  34. */
  35. SK_API void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1);
  36. /**
  37. Add a conic curve from the last point, approaching control point
  38. (x0,y01), and ending at (x1,y1) with weight w. If no
  39. sk_path_move_to() call has been made for this contour, the first
  40. point is automatically set to (0,0).
  41. */
  42. SK_API void sk_path_conic_to(sk_path_t*, float x0, float y0, float x1, float y1, float w);
  43. /**
  44. Add a cubic bezier from the last point, approaching control points
  45. (x0,y0) and (x1,y1), and ending at (x2,y2). 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. */
  49. SK_API void sk_path_cubic_to(sk_path_t*,
  50. float x0, float y0,
  51. float x1, float y1,
  52. float x2, float y2);
  53. /**
  54. Close the current contour. If the current point is not equal to the
  55. first point of the contour, a line segment is automatically added.
  56. */
  57. SK_API void sk_path_close(sk_path_t*);
  58. /**
  59. Add a closed rectangle contour to the path.
  60. */
  61. SK_API void sk_path_add_rect(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
  62. /**
  63. Add a closed oval contour to the path
  64. */
  65. SK_API void sk_path_add_oval(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
  66. /**
  67. * If the path is empty, return false and set the rect parameter to [0, 0, 0, 0].
  68. * else return true and set the rect parameter to the bounds of the control-points
  69. * of the path.
  70. */
  71. SK_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*);
  72. SK_C_PLUS_PLUS_END_GUARD
  73. #endif