Class: Cairo::GradientPattern
- Defined in:
- ext/cairo/rb_cairo_pattern.c
Direct Known Subclasses
Instance Method Summary collapse
-
#add_color_stop ⇒ Object
(also: #add_color_stop_rgb, #add_color_stop_rgba)
Cairo::GradientPattern.
- #color_stop_count ⇒ Object
- #get_color_stop_color ⇒ Object
- #get_color_stop_rgba ⇒ Object
Methods inherited from Pattern
#extend, #filter, #initialize, #matrix, #set_extend, #set_filter, #set_matrix
Constructor Details
This class inherits a constructor from Cairo::Pattern
Instance Method Details
#add_color_stop ⇒ Object Also known as: add_color_stop_rgb, add_color_stop_rgba
Cairo::GradientPattern
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'ext/cairo/rb_cairo_pattern.c', line 230
static VALUE
cr_gradient_pattern_add_color_stop_generic (int argc, VALUE *argv, VALUE self)
{
VALUE offset, red, green, blue, alpha;
int n;
n = rb_scan_args (argc, argv, "23", &offset, &red, &green, &blue, &alpha);
if (n == 2)
{
VALUE color = red;
color = cr_color_parse (color);
if (rb_cairo__is_kind_of (color, rb_cCairo_Color_Base))
red = rb_funcall (rb_funcall (color, id_to_rgb, 0), id_to_a, 0);
}
if (n == 2 && rb_cairo__is_kind_of (red, rb_cArray))
{
VALUE ary = red;
n = RARRAY_LEN (ary) + 1;
red = rb_ary_entry (ary, 0);
green = rb_ary_entry (ary, 1);
blue = rb_ary_entry (ary, 2);
alpha = rb_ary_entry (ary, 3);
}
if (n == 4 || (n == 5 && NIL_P (alpha)))
{
cairo_pattern_add_color_stop_rgb (_SELF (self), NUM2DBL (offset),
NUM2DBL (red), NUM2DBL (green),
NUM2DBL (blue));
}
else if (n == 5)
{
cairo_pattern_add_color_stop_rgba (_SELF (self), NUM2DBL (offset),
NUM2DBL (red), NUM2DBL (green),
NUM2DBL (blue), NUM2DBL (alpha));
}
else
{
VALUE inspected;
inspected = rb_funcall (rb_ary_new4 (argc, argv), id_inspect, 0);
rb_raise (rb_eArgError,
"invalid argument: %s (expect "
"(offset, color_name), "
"(offset, color_hex_triplet), "
"(offset, Cairo::Color::RGB), "
"(offset, Cairo::Color::CMYK), "
"(offset, Cairo::Color::HSV), "
"(offset, red, green, blue), "
"(offset, [red, green, blue]), "
"(offset, red, green, blue, alpha) or "
"(offset, [red, green, blue, alpha])"
")",
RVAL2CSTR (inspected));
}
cr_pattern_check_status (_SELF (self));
return self;
}
|
#color_stop_count ⇒ Object
395 396 397 398 399 400 401 402 403 404 |
# File 'ext/cairo/rb_cairo_pattern.c', line 395
static VALUE
cr_gradient_pattern_get_color_stop_count (VALUE self)
{
cairo_status_t status;
int count;
status = cairo_pattern_get_color_stop_count (_SELF (self), &count);
rb_cairo_check_status (status);
return INT2NUM (count);
}
|
#get_color_stop_color ⇒ Object
383 384 385 386 387 388 389 390 391 392 393 |
# File 'ext/cairo/rb_cairo_pattern.c', line 383
static VALUE
cr_gradient_pattern_get_color_stop_color (VALUE self, VALUE index)
{
VALUE result, offset, rgba;
result = cr_gradient_pattern_get_color_stop_rgba (self, index);
offset = rb_ary_shift (result);
rgba = result;
return rb_ary_new3 (2, offset, cr_color_parse (rgba));
}
|
#get_color_stop_rgba ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'ext/cairo/rb_cairo_pattern.c', line 368
static VALUE
cr_gradient_pattern_get_color_stop_rgba (VALUE self, VALUE index)
{
cairo_status_t status;
double offset, red, green, blue, alpha;
status = cairo_pattern_get_color_stop_rgba (_SELF (self), NUM2INT (index),
&offset, &red, &green, &blue,
&alpha);
rb_cairo_check_status (status);
return rb_ary_new3 (5, rb_float_new (offset),
rb_float_new (red), rb_float_new (green),
rb_float_new (blue), rb_float_new (alpha));
}
|