Class: Cairo::RasterSourcePattern

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



892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
# File 'ext/cairo/rb_cairo_pattern.c', line 892

static VALUE
cr_raster_source_pattern_initialize (int argc, VALUE *argv, VALUE self)
{
  cairo_pattern_t *pattern;
  cairo_content_t content;
  int width, height;
  VALUE arg1, arg2, arg3;

  rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);

  if (argc == 2)
    {
      content = CAIRO_CONTENT_COLOR_ALPHA;
      width = NUM2INT (arg1);
      height = NUM2INT (arg2);
    }
  else
    {
      content = RVAL2CRCONTENT (arg1);
      width = NUM2INT (arg2);
      height = NUM2INT (arg3);
    }

  pattern = cairo_pattern_create_raster_source (RVAL2POINTER (self),
                                                content, width, height);
  cr_pattern_check_status (pattern);

  DATA_PTR (self) = pattern;
  rb_iv_set (self, "@acquire", Qnil);
  rb_iv_set (self, "@release", Qnil);
  rb_iv_set (self, "@snapshot", Qnil);
  rb_iv_set (self, "@copy", Qnil);
  rb_iv_set (self, "@finish", Qnil);

  cairo_raster_source_pattern_set_acquire (pattern,
                                           cr_raster_source_acquire_callback,
                                           cr_raster_source_release_callback);
  cairo_raster_source_pattern_set_snapshot (pattern,
                                            cr_raster_source_snapshot_callback);
  cairo_raster_source_pattern_set_copy (pattern,
                                        cr_raster_source_copy_callback);
  cairo_raster_source_pattern_set_finish (pattern,
                                          cr_raster_source_finish_callback);

  return Qnil;
}

Instance Method Details

#acquireObject



939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'ext/cairo/rb_cairo_pattern.c', line 939

static VALUE
cr_raster_source_pattern_acquire (VALUE self)
{
  if (!rb_block_given_p ())
    {
      VALUE inspected;

      inspected = rb_funcall (self, id_inspect, 0);
      rb_raise (rb_eArgError, "acquire block is missing: %s",
                RVAL2CSTR (inspected));
    }

  rb_iv_set (self, "@acquire", rb_block_proc ());

  return self;
}

#copyObject



990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
# File 'ext/cairo/rb_cairo_pattern.c', line 990

static VALUE
cr_raster_source_pattern_copy (VALUE self)
{
  if (!rb_block_given_p ())
    {
      VALUE inspected;

      inspected = rb_funcall (self, id_inspect, 0);
      rb_raise (rb_eArgError, "copy block is missing: %s",
                RVAL2CSTR (inspected));
    }

  rb_iv_set (self, "@copy", rb_block_proc ());

  return self;
}

#finishObject



1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
# File 'ext/cairo/rb_cairo_pattern.c', line 1007

static VALUE
cr_raster_source_pattern_finish (VALUE self)
{
  if (!rb_block_given_p ())
    {
      VALUE inspected;

      inspected = rb_funcall (self, id_inspect, 0);
      rb_raise (rb_eArgError, "finish block is missing: %s",
                RVAL2CSTR (inspected));
    }

  rb_iv_set (self, "@finish", rb_block_proc ());

  return self;
}

#releaseObject



956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
# File 'ext/cairo/rb_cairo_pattern.c', line 956

static VALUE
cr_raster_source_pattern_release (VALUE self)
{
  if (!rb_block_given_p ())
    {
      VALUE inspected;

      inspected = rb_funcall (self, id_inspect, 0);
      rb_raise (rb_eArgError, "release block is missing: %s",
                RVAL2CSTR (inspected));
    }

  rb_iv_set (self, "@release", rb_block_proc ());

  return self;
}

#snapshotObject



973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
# File 'ext/cairo/rb_cairo_pattern.c', line 973

static VALUE
cr_raster_source_pattern_snapshot (VALUE self)
{
  if (!rb_block_given_p ())
    {
      VALUE inspected;

      inspected = rb_funcall (self, id_inspect, 0);
      rb_raise (rb_eArgError, "snapshot block is missing: %s",
                RVAL2CSTR (inspected));
    }

  rb_iv_set (self, "@snapshot", rb_block_proc ());

  return self;
}