alternative to assert
[gtkD.git] / src / cairoLib / Pattern.d
blobbdbaa43dde1dcf58bb170f122dc3cb1659c0ce58
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = cairo-Patterns.html
26 * outPack = cairoLib
27 * outFile = Pattern
28 * strct = cairo_pattern_t
29 * realStrct=
30 * ctorStrct=
31 * clss = Pattern
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - cairo_pattern_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * structWrap:
45 * local aliases:
48 module cairoLib.Pattern;
50 private import cairoLib.cairoLibtypes;
52 private import lib.cairoLib;
55 /**
56 * Description
58 public class Pattern
61 /** the main Gtk struct */
62 protected cairo_pattern_t* cairo_pattern;
65 public cairo_pattern_t* getPatternStruct()
67 return cairo_pattern;
71 /** the main Gtk struct as a void* */
72 protected void* getStruct()
74 return cast(void*)cairo_pattern;
77 /**
78 * Sets our main struct and passes it to the parent class
80 public this (cairo_pattern_t* cairo_pattern)
82 this.cairo_pattern = cairo_pattern;
85 /**
89 /**
90 * Adds an opaque color stop to a gradient pattern. The offset
91 * specifies the location along the gradient's control vector. For
92 * example, a linear gradient's control vector is from (x0,y0) to
93 * (x1,y1) while a radial gradient's control vector is from any point
94 * on the start circle to the corresponding point on the end circle.
95 * The color is specified in the same way as in cairo_set_source_rgb().
96 * Note: If the pattern is not a gradient pattern, (eg. a linear or
97 * radial pattern), then the pattern will be put into an error status
98 * with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH.
99 * pattern:
100 * a cairo_pattern_t
101 * offset:
102 * an offset in the range [0.0 .. 1.0]
103 * red:
104 * red component of color
105 * green:
106 * green component of color
107 * blue:
108 * blue component of color
110 public void addColorStopRgb(double offset, double red, double green, double blue)
112 // void cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern, double offset, double red, double green, double blue);
113 cairo_pattern_add_color_stop_rgb(cairo_pattern, offset, red, green, blue);
117 * Adds a translucent color stop to a gradient pattern. The offset
118 * specifies the location along the gradient's control vector. For
119 * example, a linear gradient's control vector is from (x0,y0) to
120 * (x1,y1) while a radial gradient's control vector is from any point
121 * on the start circle to the corresponding point on the end circle.
122 * The color is specified in the same way as in cairo_set_source_rgba().
123 * Note: If the pattern is not a gradient pattern, (eg. a linear or
124 * radial pattern), then the pattern will be put into an error status
125 * with a status of CAIRO_STATUS_PATTERN_TYPE_MISMATCH.
126 * pattern:
127 * a cairo_pattern_t
128 * offset:
129 * an offset in the range [0.0 .. 1.0]
130 * red:
131 * red component of color
132 * green:
133 * green component of color
134 * blue:
135 * blue component of color
136 * alpha:
137 * alpha component of color
139 public void addColorStopRgba(double offset, double red, double green, double blue, double alpha)
141 // void cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha);
142 cairo_pattern_add_color_stop_rgba(cairo_pattern, offset, red, green, blue, alpha);
146 * Creates a new cairo_pattern_t corresponding to an opaque color. The
147 * color components are floating point numbers in the range 0 to 1.
148 * If the values passed in are outside that range, they will be
149 * clamped.
150 * red:
151 * red component of the color
152 * green:
153 * green component of the color
154 * blue:
155 * blue component of the color
156 * Returns:
157 * the newly created cairo_pattern_t if succesful, or
158 * an error pattern in case of no memory. The caller owns the
159 * returned object and should call cairo_pattern_destroy() when
160 * finished with it.
161 * This function will always return a valid pointer, but if an error
162 * occurred the pattern status will be set to an error. To inspect
163 * the status of a pattern use cairo_pattern_status().
165 public static cairo_pattern_t* createRgb(double red, double green, double blue)
167 // cairo_pattern_t* cairo_pattern_create_rgb (double red, double green, double blue);
168 return cairo_pattern_create_rgb(red, green, blue);
172 * Creates a new cairo_pattern_t corresponding to a translucent color.
173 * The color components are floating point numbers in the range 0 to
174 * 1. If the values passed in are outside that range, they will be
175 * clamped.
176 * red:
177 * red component of the color
178 * green:
179 * green component of the color
180 * blue:
181 * blue component of the color
182 * alpha:
183 * alpha component of the color
184 * Returns:
185 * the newly created cairo_pattern_t if succesful, or
186 * an error pattern in case of no memory. The caller owns the
187 * returned object and should call cairo_pattern_destroy() when
188 * finished with it.
189 * This function will always return a valid pointer, but if an error
190 * occurred the pattern status will be set to an error. To inspect
191 * the status of a pattern use cairo_pattern_status().
193 public static cairo_pattern_t* createRgba(double red, double green, double blue, double alpha)
195 // cairo_pattern_t* cairo_pattern_create_rgba (double red, double green, double blue, double alpha);
196 return cairo_pattern_create_rgba(red, green, blue, alpha);
200 * Create a new cairo_pattern_t for the given surface.
201 * surface:
202 * the surface
203 * Returns:
204 * the newly created cairo_pattern_t if succesful, or
205 * an error pattern in case of no memory. The caller owns the
206 * returned object and should call cairo_pattern_destroy() when
207 * finished with it.
208 * This function will always return a valid pointer, but if an error
209 * occurred the pattern status will be set to an error. To inspect
210 * the status of a pattern use cairo_pattern_status().
212 public static cairo_pattern_t* createForSurface(cairo_surface_t* surface)
214 // cairo_pattern_t* cairo_pattern_create_for_surface (cairo_surface_t *surface);
215 return cairo_pattern_create_for_surface(surface);
219 * Create a new linear gradient cairo_pattern_t along the line defined
220 * by (x0, y0) and (x1, y1). Before using the gradient pattern, a
221 * number of color stops should be defined using
222 * cairo_pattern_add_color_stop_rgb() or
223 * cairo_pattern_add_color_stop_rgba().
224 * Note: The coordinates here are in pattern space. For a new pattern,
225 * pattern space is identical to user space, but the relationship
226 * between the spaces can be changed with cairo_pattern_set_matrix().
227 * x0:
228 * x coordinate of the start point
229 * y0:
230 * y coordinate of the start point
231 * x1:
232 * x coordinate of the end point
233 * y1:
234 * y coordinate of the end point
235 * Returns:
236 * the newly created cairo_pattern_t if succesful, or
237 * an error pattern in case of no memory. The caller owns the
238 * returned object and should call cairo_pattern_destroy() when
239 * finished with it.
240 * This function will always return a valid pointer, but if an error
241 * occurred the pattern status will be set to an error. To inspect
242 * the status of a pattern use cairo_pattern_status().
244 public static cairo_pattern_t* createLinear(double x0, double y0, double x1, double y1)
246 // cairo_pattern_t* cairo_pattern_create_linear (double x0, double y0, double x1, double y1);
247 return cairo_pattern_create_linear(x0, y0, x1, y1);
251 * Creates a new radial gradient cairo_pattern_t between the two
252 * circles defined by (x0, y0, c0) and (x1, y1, c0). Before using the
253 * gradient pattern, a number of color stops should be defined using
254 * cairo_pattern_add_color_stop_rgb() or
255 * cairo_pattern_add_color_stop_rgba().
256 * Note: The coordinates here are in pattern space. For a new pattern,
257 * pattern space is identical to user space, but the relationship
258 * between the spaces can be changed with cairo_pattern_set_matrix().
259 * cx0:
260 * x coordinate for the center of the start circle
261 * cy0:
262 * y coordinate for the center of the start circle
263 * radius0:
264 * radius of the start cirle
265 * cx1:
266 * x coordinate for the center of the end circle
267 * cy1:
268 * y coordinate for the center of the end circle
269 * radius1:
270 * radius of the end cirle
271 * Returns:
272 * the newly created cairo_pattern_t if succesful, or
273 * an error pattern in case of no memory. The caller owns the
274 * returned object and should call cairo_pattern_destroy() when
275 * finished with it.
276 * This function will always return a valid pointer, but if an error
277 * occurred the pattern status will be set to an error. To inspect
278 * the status of a pattern use cairo_pattern_status().
280 public static cairo_pattern_t* createRadial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
282 // cairo_pattern_t* cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
283 return cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
287 * Decreases the reference count on pattern by one. If the result is
288 * zero, then pattern and all associated resources are freed. See
289 * cairo_pattern_reference().
290 * pattern:
291 * a cairo_pattern_t
293 public void destroy()
295 // void cairo_pattern_destroy (cairo_pattern_t *pattern);
296 cairo_pattern_destroy(cairo_pattern);
300 * Increases the reference count on pattern by one. This prevents
301 * pattern from being destroyed until a matching call to
302 * cairo_pattern_destroy() is made.
303 * pattern:
304 * a cairo_pattern_t
305 * Returns:
306 * the referenced cairo_pattern_t.
308 public cairo_pattern_t* reference()
310 // cairo_pattern_t* cairo_pattern_reference (cairo_pattern_t *pattern);
311 return cairo_pattern_reference(cairo_pattern);
315 * Checks whether an error has previously occurred for this
316 * pattern.
317 * pattern:
318 * a cairo_pattern_t
319 * Returns:
320 * CAIRO_STATUS_SUCCESS, CAIRO_STATUS_NO_MEMORY, or
321 * CAIRO_STATUS_PATTERN_TYPE_MISMATCH.
323 public cairo_status_t status()
325 // cairo_status_t cairo_pattern_status (cairo_pattern_t *pattern);
326 return cairo_pattern_status(cairo_pattern);
331 * Sets the mode to be used for drawing outside the area of a pattern.
332 * See cairo_extend_t for details on the semantics of each extend
333 * strategy.
334 * pattern:
335 * a cairo_pattern_t
336 * extend:
337 * a cairo_extend_t describing how the area outside of the
338 * pattern will be drawn
340 public void setExtend(cairo_extend_t extend)
342 // void cairo_pattern_set_extend (cairo_pattern_t *pattern, cairo_extend_t extend);
343 cairo_pattern_set_extend(cairo_pattern, extend);
347 * Gets the current extend mode for a pattern. See cairo_extend_t
348 * for details on the semantics of each extend strategy.
349 * pattern:
350 * a cairo_pattern_t
351 * Returns:
352 * the current extend strategy used for drawing the
353 * pattern.
355 public cairo_extend_t getExtend()
357 // cairo_extend_t cairo_pattern_get_extend (cairo_pattern_t *pattern);
358 return cairo_pattern_get_extend(cairo_pattern);
363 * pattern:
364 * filter:
366 public void setFilter(cairo_filter_t filter)
368 // void cairo_pattern_set_filter (cairo_pattern_t *pattern, cairo_filter_t filter);
369 cairo_pattern_set_filter(cairo_pattern, filter);
373 * pattern:
374 * Returns:
376 public cairo_filter_t getFilter()
378 // cairo_filter_t cairo_pattern_get_filter (cairo_pattern_t *pattern);
379 return cairo_pattern_get_filter(cairo_pattern);
383 * Sets the pattern's transformation matrix to matrix. This matrix is
384 * a transformation from user space to pattern space.
385 * When a pattern is first created it always has the identity matrix
386 * for its transformation matrix, which means that pattern space is
387 * initially identical to user space.
388 * Important: Please note that the direction of this transformation
389 * matrix is from user space to pattern space. This means that if you
390 * imagine the flow from a pattern to user space (and on to device
391 * space), then coordinates in that flow will be transformed by the
392 * inverse of the pattern matrix.
393 * For example, if you want to make a pattern appear twice as large as
394 * it does by default the correct code to use is:
395 * cairo_matrix_init_scale (matrix, 0.5, 0.5);
396 * cairo_pattern_set_matrix (pattern, matrix);
397 * Meanwhile, using values of 2.0 rather than 0.5 in the code above
398 * would cause the pattern to appear at half of its default size.
399 * Also, please note the discussion of the user-space locking
400 * semantics of cairo_set_source().
401 * pattern:
402 * a cairo_pattern_t
403 * matrix:
404 * a cairo_matrix_t
406 public void setMatrix(cairo_matrix_t* matrix)
408 // void cairo_pattern_set_matrix (cairo_pattern_t *pattern, const cairo_matrix_t *matrix);
409 cairo_pattern_set_matrix(cairo_pattern, matrix);
413 * Stores the pattern's transformation matrix into matrix.
414 * pattern:
415 * a cairo_pattern_t
416 * matrix:
417 * return value for the matrix
419 public void getMatrix(cairo_matrix_t* matrix)
421 // void cairo_pattern_get_matrix (cairo_pattern_t *pattern, cairo_matrix_t *matrix);
422 cairo_pattern_get_matrix(cairo_pattern, matrix);
427 * This function returns the type a pattern.
428 * See cairo_pattern_type_t for available types.
429 * pattern:
430 * a cairo_pattern_t
431 * Returns:
432 * The type of pattern.
433 * Since 1.2
435 public cairo_pattern_type_t getType()
437 // cairo_pattern_type_t cairo_pattern_get_type (cairo_pattern_t *pattern);
438 return cairo_pattern_get_type(cairo_pattern);