PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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