Class: Cairo::MeshPattern

Inherits:
Pattern
  • Object
show all
Defined in:
ext/cairo/rb_cairo_pattern.c

Instance Method Summary collapse

Methods inherited from Pattern

#extend, #filter, gradient_supported?, linear_supported?, #matrix, mesh_supported?, radial_supported?, raster_source_supported?, #set_extend, #set_filter, #set_matrix, solid_supported?, supported?, surface_supported?

Constructor Details

#initializeObject

Cairo::MeshPattern



514
515
516
517
518
519
520
521
522
523
# File 'ext/cairo/rb_cairo_pattern.c', line 514

static VALUE
cr_mesh_pattern_initialize (VALUE self)
{
  cairo_pattern_t *pattern;

  pattern = cairo_pattern_create_mesh ();
  cr_pattern_check_status (pattern);
  DATA_PTR (self) = pattern;
  return Qnil;
}

Instance Method Details

#begin_patchObject



536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'ext/cairo/rb_cairo_pattern.c', line 536

static VALUE
cr_mesh_pattern_begin_patch (VALUE self)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_begin_patch (pattern);
  cr_pattern_check_status (pattern);
  if (rb_block_given_p ())
    return rb_ensure (rb_yield, self, cr_mesh_pattern_end_patch, self);
  else
    return self;
}

#curve_toObject



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# File 'ext/cairo/rb_cairo_pattern.c', line 550

static VALUE
cr_mesh_pattern_curve_to (VALUE self,
                          VALUE x1, VALUE y1,
                          VALUE x2, VALUE y2,
                          VALUE x3, VALUE y3)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_curve_to (pattern,
                               NUM2DBL (x1), NUM2DBL (y1),
                               NUM2DBL (x2), NUM2DBL (y2),
                               NUM2DBL (x3), NUM2DBL (y3));
  cr_pattern_check_status (pattern);
  return self;
}

#end_patchObject



525
526
527
528
529
530
531
532
533
534
# File 'ext/cairo/rb_cairo_pattern.c', line 525

static VALUE
cr_mesh_pattern_end_patch (VALUE self)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_end_patch (pattern);
  cr_pattern_check_status (pattern);
  return self;
}

#get_control_pointObject



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# File 'ext/cairo/rb_cairo_pattern.c', line 715

static VALUE
cr_mesh_pattern_get_control_point (VALUE self,
                                   VALUE rb_nth_patch, VALUE rb_nth_point)
{
  cairo_pattern_t *pattern;
  unsigned int nth_patch, nth_point;
  double x, y;
  cairo_status_t status;

  nth_patch = NUM2UINT (rb_nth_patch);
  nth_point = NUM2UINT (rb_nth_point);
  if (nth_point > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new3 (2, rb_nth_patch, rb_nth_point),
                              id_inspect, 0);
      rb_raise (rb_eArgError, "nth_point must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_point, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  status = cairo_mesh_pattern_get_control_point (pattern,
                                                 nth_patch, nth_point,
                                                 &x, &y);
  rb_cairo_check_status (status);
  return rb_ary_new3 (2, rb_float_new (x), rb_float_new (y));
}

#get_corner_colorObject



681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'ext/cairo/rb_cairo_pattern.c', line 681

static VALUE
cr_mesh_pattern_get_corner_color (VALUE self,
                                  VALUE rb_nth_patch, VALUE rb_nth_corner)
{
  cairo_pattern_t *pattern;
  unsigned int nth_patch, nth_corner;
  double red, green, blue, alpha;
  cairo_status_t status;

  nth_patch = NUM2UINT (rb_nth_patch);
  nth_corner = NUM2UINT (rb_nth_corner);
  if (nth_corner > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new3 (2, rb_nth_patch, rb_nth_corner),
                              id_inspect, 0);
      rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_corner, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  status = cairo_mesh_pattern_get_corner_color_rgba (pattern,
                                                     nth_patch, nth_corner,
                                                     &red,
                                                     &green,
                                                     &blue,
                                                     &alpha);
  rb_cairo_check_status (status);
  return rb_ary_new3 (4,
                      rb_float_new (red), rb_float_new (green),
                      rb_float_new (blue), rb_float_new (alpha));
}

#get_pathObject



669
670
671
672
673
674
675
676
677
678
679
# File 'ext/cairo/rb_cairo_pattern.c', line 669

static VALUE
cr_mesh_pattern_get_path (VALUE self, VALUE nth_patch)
{
  cairo_pattern_t *pattern;
  cairo_path_t *path;

  pattern = _SELF (self);
  path = cairo_mesh_pattern_get_path (pattern, NUM2UINT (nth_patch));
  rb_cairo_check_status (path->status);
  return CRPATH2RVAL (path);
}

#line_toObject



567
568
569
570
571
572
573
574
575
576
# File 'ext/cairo/rb_cairo_pattern.c', line 567

static VALUE
cr_mesh_pattern_line_to (VALUE self, VALUE x, VALUE y)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_line_to (pattern, NUM2DBL (x), NUM2DBL (y));
  cr_pattern_check_status (pattern);
  return self;
}

#move_toObject



578
579
580
581
582
583
584
585
586
587
# File 'ext/cairo/rb_cairo_pattern.c', line 578

static VALUE
cr_mesh_pattern_move_to (VALUE self, VALUE x, VALUE y)
{
  cairo_pattern_t *pattern;

  pattern = _SELF (self);
  cairo_mesh_pattern_move_to (pattern, NUM2DBL (x), NUM2DBL (y));
  cr_pattern_check_status (pattern);
  return self;
}

#patch_countObject



656
657
658
659
660
661
662
663
664
665
666
667
# File 'ext/cairo/rb_cairo_pattern.c', line 656

static VALUE
cr_mesh_pattern_get_patch_count (VALUE self)
{
  cairo_pattern_t *pattern;
  unsigned int count;
  cairo_status_t status;

  pattern = _SELF (self);
  status = cairo_mesh_pattern_get_patch_count (pattern, &count);
  rb_cairo_check_status (status);
  return UINT2NUM (count);
}

#set_control_pointObject



589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'ext/cairo/rb_cairo_pattern.c', line 589

static VALUE
cr_mesh_pattern_set_control_point (VALUE self, VALUE rb_nth_point,
                                   VALUE rb_x, VALUE rb_y)
{
  cairo_pattern_t *pattern;
  unsigned int nth_point;

  pattern = _SELF (self);
  nth_point = NUM2UINT (rb_nth_point);
  if (nth_point <= 3)
    {
      cairo_mesh_pattern_set_control_point (pattern, nth_point,
                                            NUM2DBL (rb_x), NUM2DBL (rb_y));
    }
  else
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new3 (3, rb_nth_point, rb_x, rb_y),
                              id_inspect, 0);
      rb_raise (rb_eArgError, "nth_point must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_point, RVAL2CSTR (inspected));
    }
  cr_pattern_check_status (pattern);
  return self;
}

#set_corner_colorObject Also known as: set_corner_color_rgb, set_corner_color_rgba



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'ext/cairo/rb_cairo_pattern.c', line 616

static VALUE
cr_mesh_pattern_set_corner_color_generic (int argc, VALUE *argv, VALUE self)
{
  cairo_pattern_t *pattern;
  VALUE rb_nth_corner, rb_red, rb_green, rb_blue, rb_alpha;
  unsigned int nth_corner;
  double red, green, blue, alpha;

  rb_scan_args (argc, argv, "41",
                &rb_nth_corner, &rb_red, &rb_green, &rb_blue, &rb_alpha);

  nth_corner = NUM2UINT (rb_nth_corner);
  if (nth_corner > 3)
    {
      VALUE inspected;

      inspected = rb_funcall (rb_ary_new4 (argc, argv), id_inspect, 0);
      rb_raise (rb_eArgError, "nth_corner must be 0, 1, 2 or 3: <%u>: <%s>",
                nth_corner, RVAL2CSTR (inspected));
    }

  pattern = _SELF (self);
  red = NUM2DBL (rb_red);
  green = NUM2DBL (rb_green);
  blue = NUM2DBL (rb_blue);
  if (NIL_P (rb_alpha))
    {
      cairo_mesh_pattern_set_corner_color_rgb (pattern, nth_corner,
                                               red, green, blue);
    }
  else
    {
      alpha = NUM2DBL (rb_alpha);
      cairo_mesh_pattern_set_corner_color_rgba (pattern, nth_corner,
                                                red, green, blue, alpha);
    }
  cr_pattern_check_status (pattern);
  return self;
}