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



522
523
524
525
526
527
528
529
530
531
# File 'ext/cairo/rb_cairo_pattern.c', line 522

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

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

Instance Method Details

#begin_patchObject



544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'ext/cairo/rb_cairo_pattern.c', line 544

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



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'ext/cairo/rb_cairo_pattern.c', line 558

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



533
534
535
536
537
538
539
540
541
542
# File 'ext/cairo/rb_cairo_pattern.c', line 533

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



723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# File 'ext/cairo/rb_cairo_pattern.c', line 723

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



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
714
715
716
717
718
719
720
721
# File 'ext/cairo/rb_cairo_pattern.c', line 689

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



677
678
679
680
681
682
683
684
685
686
687
# File 'ext/cairo/rb_cairo_pattern.c', line 677

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



575
576
577
578
579
580
581
582
583
584
# File 'ext/cairo/rb_cairo_pattern.c', line 575

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



586
587
588
589
590
591
592
593
594
595
# File 'ext/cairo/rb_cairo_pattern.c', line 586

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



664
665
666
667
668
669
670
671
672
673
674
675
# File 'ext/cairo/rb_cairo_pattern.c', line 664

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



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'ext/cairo/rb_cairo_pattern.c', line 597

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



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
655
656
657
658
659
660
661
662
# File 'ext/cairo/rb_cairo_pattern.c', line 624

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;
}