In Files

Parent

Imlib2::Filter

Public Class Methods

new(p1) click to toggle source

Return a new Imlib2::Filter

Example:

filter = Imlib2::Filter.new
VALUE filter_new(VALUE initsize, VALUE klass) {
  Imlib_Filter *f = malloc(sizeof(Imlib_Filter));
  VALUE f_o, vals[1];

  *f = imlib_create_filter(NUM2INT(initsize));
  f_o = Data_Wrap_Struct(klass, 0, filter_free, f);

  vals[0] = initsize;
  rb_obj_call_init(f_o, 1, vals);

  return f_o;
}

Public Instance Methods

alpha(*args) click to toggle source

Set the alpha filter color value and x, y

Example:

filter.set_alpha x, y, Imlib2::Color::RgbaColor.new 0, 0, 0, 128
VALUE filter_set_alpha(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_alpha(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
blue(*args) click to toggle source

Set the blue filter color value and x, y

Example:

filter.set_blue x, y, Imlib2::Color::RgbaColor.new 0, 0, 64, 128
VALUE filter_set_blue(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_blue(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
constants(p1) click to toggle source

Set filter constants.

Example:

filter.set_constants RgbaColor.new 32, 32, 32, 32
VALUE filter_constants(VALUE self, VALUE color) {
  Imlib_Filter *f;
  Imlib_Color *c;

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_constants(c->alpha, c->red, c->green, c->blue);

  return self;
}
divisors(p1) click to toggle source

Set filter divisors.

Example:

filter.set_divisors RgbaColor.new 0, 32, 0, 32
VALUE filter_divisors(VALUE self, VALUE color) {
  Imlib_Filter *f;
  Imlib_Color *c;

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_divisors(c->alpha, c->red, c->green, c->blue);

  return self;
}
green(*args) click to toggle source

Set the green filter color value and x, y

Example:

filter.set_green x, y, Imlib2::Color::RgbaColor.new 0, 128, 0, 128
VALUE filter_set_green(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_green(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
red(*args) click to toggle source
VALUE filter_set_red(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_red(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
set(*args) click to toggle source

Set the filter color value and x, y

Example:

filter.set x, y, Imlib2::Color::RED
VALUE filter_set(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
set_alpha(*args) click to toggle source

Set the alpha filter color value and x, y

Example:

filter.set_alpha x, y, Imlib2::Color::RgbaColor.new 0, 0, 0, 128
VALUE filter_set_alpha(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_alpha(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
set_blue(*args) click to toggle source

Set the blue filter color value and x, y

Example:

filter.set_blue x, y, Imlib2::Color::RgbaColor.new 0, 0, 64, 128
VALUE filter_set_blue(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_blue(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
set_green(*args) click to toggle source

Set the green filter color value and x, y

Example:

filter.set_green x, y, Imlib2::Color::RgbaColor.new 0, 128, 0, 128
VALUE filter_set_green(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_green(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}
set_red(*args) click to toggle source
VALUE filter_set_red(int argc, VALUE *argv, VALUE self) {
  Imlib_Filter *f;
  Imlib_Color *c;
  int x, y;
  VALUE color;

  switch (argc) {
    case 2:
      /* 2 args is an array or hash of x, y, and an RGBAColor */

      color = argv[1];
      switch (TYPE(argv[0])) {
        case T_HASH:
          x = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("x")));
          y = NUM2INT(rb_hash_aref(argv[0], rb_str_new2("y")));
          break;
        case T_ARRAY:
          x = NUM2INT(rb_ary_entry(argv[0], 0));
          y = NUM2INT(rb_ary_entry(argv[0], 1));
          break;
        default:
          rb_raise(rb_eTypeError, "Invalid argument type (not array or hash)");
      }
      break;
    case 3:
      /* three args is x, y, and color */

      x = NUM2INT(argv[0]);
      y = NUM2INT(argv[1]);
      color = argv[2];
      break;
    default:
      rb_raise(rb_eTypeError, "Invalid argument count (not 2 or 3)");
  }

  Data_Get_Struct(self, Imlib_Filter, f);
  Data_Get_Struct(color, Imlib_Color, c);
  imlib_context_set_filter(*f);
  imlib_filter_set_red(x, y, c->alpha, c->red, c->green, c->blue);

  return self;
}

[Validate]

Generated with the Darkfish Rdoc Generator 2.