sk_paint.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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_paint_DEFINED
  10. #define sk_paint_DEFINED
  11. #include "include/c/sk_types.h"
  12. SK_C_PLUS_PLUS_BEGIN_GUARD
  13. /**
  14. Create a new paint with default settings:
  15. antialias : false
  16. stroke : false
  17. stroke width : 0.0f (hairline)
  18. stroke miter : 4.0f
  19. stroke cap : BUTT_SK_STROKE_CAP
  20. stroke join : MITER_SK_STROKE_JOIN
  21. color : opaque black
  22. shader : NULL
  23. maskfilter : NULL
  24. xfermode_mode : SRCOVER_SK_XFERMODE_MODE
  25. */
  26. SK_API sk_paint_t* sk_paint_new(void);
  27. /**
  28. Release the memory storing the sk_paint_t and unref() all
  29. associated objects.
  30. */
  31. SK_API void sk_paint_delete(sk_paint_t*);
  32. /**
  33. Return true iff the paint has antialiasing enabled.
  34. */
  35. SK_API bool sk_paint_is_antialias(const sk_paint_t*);
  36. /**
  37. Set to true to enable antialiasing, false to disable it on this
  38. sk_paint_t.
  39. */
  40. SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
  41. /**
  42. Return the paint's curent drawing color.
  43. */
  44. SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
  45. /**
  46. Set the paint's curent drawing color.
  47. */
  48. SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
  49. /* stroke settings */
  50. /**
  51. Return true iff stroking is enabled rather than filling on this
  52. sk_paint_t.
  53. */
  54. SK_API bool sk_paint_is_stroke(const sk_paint_t*);
  55. /**
  56. Set to true to enable stroking rather than filling with this
  57. sk_paint_t.
  58. */
  59. SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
  60. /**
  61. Return the width for stroking. A value of 0 strokes in hairline mode.
  62. */
  63. SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
  64. /**
  65. Set the width for stroking. A value of 0 strokes in hairline mode
  66. (always draw 1-pixel wide, regardless of the matrix).
  67. */
  68. SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
  69. /**
  70. Return the paint's stroke miter value. This is used to control the
  71. behavior of miter joins when the joins angle is sharp.
  72. */
  73. SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
  74. /**
  75. Set the paint's stroke miter value. This is used to control the
  76. behavior of miter joins when the joins angle is sharp. This value
  77. must be >= 0.
  78. */
  79. SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
  80. typedef enum {
  81. BUTT_SK_STROKE_CAP,
  82. ROUND_SK_STROKE_CAP,
  83. SQUARE_SK_STROKE_CAP
  84. } sk_stroke_cap_t;
  85. /**
  86. Return the paint's stroke cap type, controlling how the start and
  87. end of stroked lines and paths are treated.
  88. */
  89. SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
  90. /**
  91. Set the paint's stroke cap type, controlling how the start and
  92. end of stroked lines and paths are treated.
  93. */
  94. SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
  95. typedef enum {
  96. MITER_SK_STROKE_JOIN,
  97. ROUND_SK_STROKE_JOIN,
  98. BEVEL_SK_STROKE_JOIN
  99. } sk_stroke_join_t;
  100. /**
  101. Return the paint's stroke join type, specifies the treatment that
  102. is applied to corners in paths and rectangles
  103. */
  104. SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
  105. /**
  106. Set the paint's stroke join type, specifies the treatment that
  107. is applied to corners in paths and rectangles
  108. */
  109. SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
  110. /**
  111. * Set the paint's shader to the specified parameter. This will automatically call unref() on
  112. * any previous value, and call ref() on the new value.
  113. */
  114. SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
  115. /**
  116. * Set the paint's maskfilter to the specified parameter. This will automatically call unref() on
  117. * any previous value, and call ref() on the new value.
  118. */
  119. SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
  120. /**
  121. * Set the paint's xfermode to the specified parameter.
  122. */
  123. SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
  124. SK_C_PLUS_PLUS_END_GUARD
  125. #endif