class Cairo::ScriptSurface - cairo-1.12.9 Documentation

# class Cairo::ScriptSurface

script surface

### Public Class Methods

new(*args) click to toggle source

script surface functions

    static VALUE
    cr_script_surface_initialize (int argc, VALUE *argv, VALUE self)
    {
      cairo_surface_t *surface = NULL, *target = NULL;
      cairo_device_t *device;
      double width = 0.0, height = 0.0;
      cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
      VALUE arg1, arg2, arg3, arg4;

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

      device = RVAL2CRDEVICE (arg1);
      if (argc == 2)
        {
          target = RVAL2CRSURFACE (arg2);
        }
      else
        {
          width = NUM2DBL (arg2);
          height = NUM2DBL (arg3);
          switch (TYPE (arg4))
            {
            case T_NIL:
              break;
            case T_STRING:
            case T_SYMBOL:
            case T_FIXNUM:
              content = RVAL2CRCONTENT (arg4);
              break;
            default:
              rb_raise (rb_eArgError,
                        "invalid argument (expect "
                        "(device, width, height), "
                        "(device, width, height, content) or "
                        "(device, surface)): %s",
                        rb_cairo__inspect (rb_ary_new4 (argc, argv)));
              break;
            }
        }

      if (target)
        surface = cairo_script_surface_create_for_target (device, target);
      else
        surface = cairo_script_surface_create (device, content, width, height);

      cr_surface_check_status (surface);
      DATA_PTR (self) = surface;
      if (rb_block_given_p ())
        yield_and_finish (self);
      return Qnil;
    }