2 * Copyright (C) 2004-2007 Tilman Sauerbeck (tilman at code-monkey de)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "rb_evas_main.h"
25 #include "rb_evas_object.h"
29 * Evas::Gradient.new(evas) => gradient
31 * Creates an Evas::Gradient object.
33 static VALUE c_init (VALUE self, VALUE evas)
35 CHECK_CLASS (evas, cEvas);
36 GET_OBJ (evas, RbEvas, e);
37 GET_OBJ (self, RbEvasObject, grad);
39 grad->real = evas_object_gradient_add (e->real);
41 rb_call_super (1, &evas);
48 * gradient.add_color(r, g, b, a, distance) => nil
50 * Adds a color to <i>gradient</i>.
52 static VALUE c_add_color (VALUE self, VALUE r, VALUE g, VALUE b,
53 VALUE a, VALUE distance)
55 GET_OBJ (self, RbEvasObject, e);
57 Check_Type (r, T_FIXNUM);
58 Check_Type (g, T_FIXNUM);
59 Check_Type (b, T_FIXNUM);
60 Check_Type (a, T_FIXNUM);
61 Check_Type (distance, T_FIXNUM);
63 evas_object_gradient_color_stop_add (e->real, FIX2INT (r),
64 FIX2INT (g), FIX2INT (b),
65 FIX2INT (a), FIX2INT (distance));
70 static VALUE c_add_alpha (VALUE self, VALUE a, VALUE distance)
72 GET_OBJ (self, RbEvasObject, e);
74 Check_Type (a, T_FIXNUM);
75 Check_Type (distance, T_FIXNUM);
77 evas_object_gradient_alpha_stop_add (e->real, FIX2INT (a),
85 * gradient.clear => nil
87 * Clears <i>gradient</i>.
89 static VALUE c_clear (VALUE self)
91 GET_OBJ (self, RbEvasObject, e);
93 evas_object_gradient_clear (e->real);
100 * gradient.angle => fixnum
102 * Returns the angle of <i>gradient</i>.
104 static VALUE c_angle_get (VALUE self)
106 GET_OBJ (self, RbEvasObject, e);
108 return INT2FIX (evas_object_gradient_angle_get (e->real));
113 * gradient.angle(fixnum)
115 * Sets the angle of <i>gradient</i>.
117 static VALUE c_angle_set (VALUE self, VALUE val)
119 GET_OBJ (self, RbEvasObject, e);
121 Check_Type (val, T_FIXNUM);
123 evas_object_gradient_angle_set (e->real, FIX2INT (val));
129 c_direction_get (VALUE self)
131 GET_OBJ (self, RbEvasObject, e);
133 return INT2FIX (evas_object_gradient_direction_get (e->real));
137 c_direction_set (VALUE self, VALUE val)
139 GET_OBJ (self, RbEvasObject, e);
141 Check_Type (val, T_FIXNUM);
143 evas_object_gradient_direction_set (e->real, FIX2INT (val));
149 c_offset_get (VALUE self)
151 GET_OBJ (self, RbEvasObject, e);
153 return rb_float_new (evas_object_gradient_offset_get (e->real));
157 c_offset_set (VALUE self, VALUE val)
159 GET_OBJ (self, RbEvasObject, e);
161 Check_Type (val, T_FLOAT);
163 evas_object_gradient_offset_set (e->real, NUM2DBL (val));
168 void Init_Gradient (void)
170 VALUE c = rb_define_class_under (mEvas, "Gradient", cEvasObject);
172 rb_define_method (c, "initialize", c_init, 1);
173 rb_define_method (c, "add_color", c_add_color, 5);
174 rb_define_method (c, "add_alpha", c_add_alpha, 2);
175 rb_define_method (c, "clear", c_clear, 0);
176 rb_define_method (c, "angle", c_angle_get, 0);
177 rb_define_method (c, "angle=", c_angle_set, 1);
178 rb_define_method (c, "direction", c_direction_get, 0);
179 rb_define_method (c, "direction=", c_direction_set, 1);
180 rb_define_method (c, "offset", c_offset_get, 0);
181 rb_define_method (c, "offset=", c_offset_set, 1);