/src/wrappers/cairo/library/cairo_pattern.e

http://github.com/tybor/Liberty · Specman e · 215 lines · 93 code · 21 blank · 101 comment · 2 complexity · 4db141778ceaaeee68265fb13973dc6a MD5 · raw file

  1. note
  2. description: "Patterns -- Gradients and filtered sources"
  3. copyright: "[
  4. Copyright (C) 2007-2017: Paolo Redaelli,
  5. Soluciones Informaticas Libres S.A. (Except),
  6. Cairo team
  7. This library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public License
  9. as published by the Free Software Foundation; either version 2.1 of
  10. the License, or (at your option) any later version.
  11. This library is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. 02110-1301 USA
  19. ]"
  20. date: "$Date:$"
  21. revision: "$Revision:$"
  22. wrapped_version: "1.2.4"
  23. class CAIRO_PATTERN
  24. inherit
  25. C_STRUCT
  26. REFERENCE_COUNTED
  27. insert
  28. CAIRO_PATTERN_EXTERNALS
  29. CAIRO_PATTERN_TYPE
  30. CAIRO_EXTEND
  31. CAIRO_FILTER
  32. CAIRO_STATUS
  33. create {ANY} make_rgb, make_rgba, from_external_pointer
  34. feature {} -- Creation
  35. make_rgb (a_red, a_green, a_blue: REAL)
  36. -- Creates a new cairo_pattern_t corresponding to an opaque
  37. -- color. The color components are floating point numbers in
  38. -- the range 0 to 1. If the values passed in are outside that
  39. -- range, they will be clamped.
  40. -- `a_red': red component of the color
  41. -- `a_green': green component of the color
  42. -- `a_blue' : blue component of the color
  43. do
  44. -- cairo_pattern_create_rgb the newly created cairo_pattern_t
  45. -- if succesful, or an error pattern in case of no
  46. -- memory. The caller owns the returned object and should
  47. -- call cairo_pattern_destroy() when finished with it. This
  48. -- function will always return a valid pointer, but if an
  49. -- error occurred the pattern status will be set to an error.
  50. -- To inspect the status of a pattern use
  51. -- cairo_pattern_status().
  52. from_external_pointer(cairo_pattern_create_rgb
  53. (a_red, a_green, a_blue))
  54. end
  55. make_rgba (a_red, a_green, a_blue, an_alpha: REAL)
  56. -- Creates a new pattern corresponding to a translucent
  57. -- color. The color components are floating point numbers in
  58. -- the range 0 to 1. If the values passed in are outside that
  59. -- range, they will be clamped.
  60. -- `a_red': red component of the color
  61. -- `a_green': green component of the color
  62. -- `a_blue': blue component of the color
  63. -- `an_alpha': alpha component of the color
  64. do
  65. from_external_pointer(cairo_pattern_create_rgba
  66. (a_red, a_green, a_blue, an_alpha))
  67. -- cairo_pattern_create_rgba returns the newly created
  68. -- cairo_pattern_t if succesful, or an error pattern in case
  69. -- of no memory. The caller owns the returned object and
  70. -- should call cairo_pattern_destroy() when finished with
  71. -- it. This function will always return a valid pointer, but
  72. -- if an error occurred the pattern status will be set to an
  73. -- error. To inspect the status of a pattern use
  74. -- cairo_pattern_status().
  75. end
  76. feature {ANY} -- Access
  77. status: INTEGER
  78. -- Pattern status; useful to check whether an error has
  79. -- previously occurred for this pattern.
  80. do
  81. Result:=cairo_pattern_status(handle)
  82. ensure valid: ((Result = cairo_status_success) or else
  83. (Result = cairo_status_no_memory) or else
  84. (Result = cairo_status_pattern_type_mismatch))
  85. end
  86. --
  87. -- --------------------------------------------------------------------------
  88. --
  89. -- cairo_pattern_set_matrix ()
  90. --
  91. -- void cairo_pattern_set_matrix (cairo_pattern_t *pattern,
  92. -- const cairo_matrix_t *matrix);
  93. --
  94. -- Sets the pattern's transformation matrix to matrix. This matrix is a
  95. -- transformation from user space to pattern space.
  96. --
  97. -- When a pattern is first created it always has the identity matrix for its
  98. -- transformation matrix, which means that pattern space is initially
  99. -- identical to user space.
  100. --
  101. -- Important: Please note that the direction of this transformation matrix is
  102. -- from user space to pattern space. This means that if you imagine the flow
  103. -- from a pattern to user space (and on to device space), then coordinates in
  104. -- that flow will be transformed by the inverse of the pattern matrix.
  105. --
  106. -- For example, if you want to make a pattern appear twice as large as it
  107. -- does by default the correct code to use is:
  108. --
  109. -- cairo_matrix_init_scale (&matrix, 0.5, 0.5);
  110. -- cairo_pattern_set_matrix (pattern, &matrix);
  111. --
  112. -- Meanwhile, using values of 2.0 rather than 0.5 in the code above would
  113. -- cause the pattern to appear at half of its default size.
  114. --
  115. -- Also, please note the discussion of the user-space locking semantics of
  116. -- cairo_set_source().
  117. --
  118. -- pattern : a cairo_pattern_t
  119. -- matrix : a cairo_matrix_t
  120. --
  121. -- --------------------------------------------------------------------------
  122. --
  123. -- cairo_pattern_get_matrix ()
  124. --
  125. -- void cairo_pattern_get_matrix (cairo_pattern_t *pattern,
  126. -- cairo_matrix_t *matrix);
  127. --
  128. -- Stores the pattern's transformation matrix into matrix.
  129. --
  130. -- pattern : a cairo_pattern_t
  131. -- matrix : return value for the matrix
  132. type: INTEGER
  133. -- This function returns the type a pattern. See CAIRO_PATTERN_TYPE
  134. -- for available types.
  135. do
  136. Result := cairo_pattern_get_type (handle)
  137. ensure
  138. is_valid_pattern_type (Result)
  139. end
  140. set_filter (a_filter: INTEGER)
  141. -- Sets the filter to be used for resizing when using this pattern.
  142. -- See CAIRO_FILTER for details on each filter.
  143. require
  144. is_valid_filter (a_filter)
  145. do
  146. cairo_pattern_set_filter (handle, a_filter)
  147. end
  148. filter: INTEGER
  149. -- Gets the current filter for a pattern. See CAIRO_FILTER for
  150. -- details on each filter.
  151. do
  152. Result := cairo_pattern_get_filter (handle)
  153. ensure
  154. is_valid_filter (Result)
  155. end
  156. set_extend (a_extend: INTEGER)
  157. -- Sets the mode to be used for drawing outside the area of a
  158. -- pattern. See CAIRO_EXTEND for details on the semantics of each
  159. -- extend strategy.
  160. require
  161. is_valid_extend (a_extend)
  162. do
  163. cairo_pattern_set_extend (handle, a_extend)
  164. end
  165. extend: INTEGER
  166. -- Gets the current extend mode for a pattern. See CAIRO_EXTEND for
  167. -- details on the semantics of each extend strategy.
  168. do
  169. Result := cairo_pattern_get_extend (handle)
  170. ensure
  171. is_valid_extend (Result)
  172. end
  173. feature {ANY} -- Memory handling
  174. unref
  175. -- Decreases the reference count on pattern by one. If the
  176. -- result is zero, then pattern and all associated resources
  177. -- are freed. See `ref'
  178. do
  179. cairo_pattern_destroy(handle)
  180. end
  181. ref
  182. -- Increases the reference count on pattern by one. This
  183. -- prevents pattern from being destroyed until a matching
  184. -- call to cairo_pattern_destroy() is made.
  185. --
  186. -- This feature is currently hidden because memory handling
  187. -- should be automatically done by Eiffel garbage collector.
  188. --
  189. -- Wrapped as 'ref' to not collide with C_STRUCT.reference
  190. local p: POINTER
  191. do
  192. p := cairo_pattern_reference(handle)
  193. end
  194. end -- class CAIRO_PATTERN