class Cairo::Matrix

Public Class Methods

identity() click to toggle source
static VALUE
cr_matrix_init_identity (VALUE self)
{
  cairo_matrix_t matrix;
  cairo_matrix_init_identity (&matrix);
  return CRMATRIX2RVAL (&matrix);
}
new(p1, p2, p3, p4, p5, p6) click to toggle source
static VALUE
cr_matrix_initialize (VALUE self,
                      VALUE xx, VALUE yx,
                      VALUE xy, VALUE yy,
                      VALUE x0, VALUE y0)
{
  cairo_matrix_t *matrix = ALLOC (cairo_matrix_t);

  cairo_matrix_init (matrix,
                     NUM2DBL (xx), NUM2DBL (yx),
                     NUM2DBL (xy), NUM2DBL (yy),
                     NUM2DBL (x0), NUM2DBL (y0));
  DATA_PTR (self) = matrix;
  return Qnil;
}
rotate(p1) click to toggle source
static VALUE
cr_matrix_init_rotate (VALUE self, VALUE radius)
{
  cairo_matrix_t matrix;
  cairo_matrix_init_rotate (&matrix, NUM2DBL (radius));
  return CRMATRIX2RVAL (&matrix);
}
scale(p1, p2) click to toggle source
static VALUE
cr_matrix_init_scale (VALUE self, VALUE sx, VALUE sy)
{
  cairo_matrix_t matrix;
  cairo_matrix_init_scale (&matrix, NUM2DBL (sx), NUM2DBL (sy));
  return CRMATRIX2RVAL (&matrix);
}
translate(p1, p2) click to toggle source
static VALUE
cr_matrix_init_translate (VALUE self, VALUE tx, VALUE ty)
{
  cairo_matrix_t matrix;
  cairo_matrix_init_translate (&matrix, NUM2DBL (tx), NUM2DBL (ty));
  return CRMATRIX2RVAL (&matrix);
}

Public Instance Methods

*(other)
Alias for: multiply
==(p1) click to toggle source
static VALUE
cr_matrix_equal (VALUE self, VALUE other)
{
  if (!rb_cairo__is_kind_of (other, rb_cCairo_Matrix))
    return Qfalse;

  return rb_funcall (cr_matrix_to_a (self),
                     cr_id_equal, 1,
                     cr_matrix_to_a (other));
}
clone() click to toggle source
# File lib/cairo.rb, line 128
def clone
  copy = dup
  copy.freeze if self.frozen?
  copy
end
dup() click to toggle source
# File lib/cairo.rb, line 124
def dup
  Matrix.new(*to_a)
end
identity!() click to toggle source
static VALUE
cr_matrix_identity (VALUE self)
{
  cairo_matrix_init_identity (_SELF);
  return self;
}
invert() click to toggle source
# File lib/cairo.rb, line 137
def invert; dup.invert!; end
invert!() click to toggle source
static VALUE
cr_matrix_invert (VALUE self)
{
  rb_cairo_check_status (cairo_matrix_invert (_SELF));
  return self;
}
multiply(other) click to toggle source
# File lib/cairo.rb, line 138
def multiply(other); dup.multiply!(other); end
Also aliased as: *
multiply!(p1) click to toggle source
static VALUE
cr_matrix_multiply (VALUE self, VALUE other)
{
  cairo_matrix_multiply (_SELF, _SELF, RVAL2CRMATRIX (other));
  return self;
}
rotate(radians) click to toggle source
# File lib/cairo.rb, line 136
def rotate(radians); dup.rotate!(radians); end
rotate!(p1) click to toggle source
static VALUE
cr_matrix_rotate (VALUE self, VALUE radians)
{
  cairo_matrix_rotate (_SELF, NUM2DBL (radians));
  return self;
}
scale(sx, sy) click to toggle source
# File lib/cairo.rb, line 135
def scale(sx, sy); dup.scale!(sx, sy); end
scale!(p1, p2) click to toggle source
static VALUE
cr_matrix_scale (VALUE self, VALUE sx, VALUE sy)
{
  cairo_matrix_scale (_SELF, NUM2DBL (sx), NUM2DBL (sy));
  return self;
}
set(p1, p2, p3, p4, p5, p6) click to toggle source

Utilities

static VALUE
cr_matrix_set (VALUE self,
               VALUE xx, VALUE yx,
               VALUE xy, VALUE yy,
               VALUE x0, VALUE y0)
{
  cairo_matrix_init (_SELF,
                     NUM2DBL (xx), NUM2DBL (yx),
                     NUM2DBL (xy), NUM2DBL (yy),
                     NUM2DBL (x0), NUM2DBL (y0));
  return self;
}
set_x0(p1) click to toggle source
static VALUE
cr_matrix_set_x0 (VALUE self, VALUE x0)
{
  _SELF->x0 = NUM2DBL (x0);
  return Qnil;
}
set_xx(p1) click to toggle source
static VALUE
cr_matrix_set_xx (VALUE self, VALUE xx)
{
  _SELF->xx = NUM2DBL (xx);
  return Qnil;
}
set_xy(p1) click to toggle source
static VALUE
cr_matrix_set_xy (VALUE self, VALUE xy)
{
  _SELF->xy = NUM2DBL (xy);
  return Qnil;
}
set_y0(p1) click to toggle source
static VALUE
cr_matrix_set_y0 (VALUE self, VALUE y0)
{
  _SELF->y0 = NUM2DBL (y0);
  return Qnil;
}
set_yx(p1) click to toggle source
static VALUE
cr_matrix_set_yx (VALUE self, VALUE yx)
{
  _SELF->yx = NUM2DBL (yx);
  return Qnil;
}
set_yy(p1) click to toggle source
static VALUE
cr_matrix_set_yy (VALUE self, VALUE yy)
{
  _SELF->yy = NUM2DBL (yy);
  return Qnil;
}
to_a() click to toggle source
static VALUE
cr_matrix_to_a (VALUE self)
{
  cairo_matrix_t *matrix = _SELF;
  double affine[6];
  affine[0] = matrix->xx;
  affine[1] = matrix->yx;
  affine[2] = matrix->xy;
  affine[3] = matrix->yy;
  affine[4] = matrix->x0;
  affine[5] = matrix->y0;
  return rb_cairo__float_array (affine, 6);
}
to_s() click to toggle source
static VALUE
cr_matrix_to_s(VALUE self)
{
  VALUE ret;

  ret = rb_str_new2 ("#<");
  rb_str_cat2 (ret, rb_class2name (CLASS_OF (self)));
  rb_str_cat2 (ret, ":");
  rb_str_concat (ret, rb_inspect (cr_matrix_to_a (self)));
  rb_str_cat2 (ret, ">");
  
  return ret;
}
transform_distance(p1, p2) click to toggle source
static VALUE
cr_matrix_transform_distance (VALUE self, VALUE dx, VALUE dy)
{
  double pair[2];
  pair[0] = NUM2DBL (dx);
  pair[1] = NUM2DBL (dy);
  cairo_matrix_transform_distance (_SELF, pair, pair + 1);
  return rb_cairo__float_array (pair, 2);
}
transform_point(p1, p2) click to toggle source
static VALUE
cr_matrix_transform_point (VALUE self, VALUE x, VALUE y)
{
  double pair[2];
  pair[0] = NUM2DBL (x);
  pair[1] = NUM2DBL (y);
  cairo_matrix_transform_point (_SELF, pair, pair + 1);
  return rb_cairo__float_array (pair, 2);
}
translate(tx, ty) click to toggle source
# File lib/cairo.rb, line 134
def translate(tx, ty); dup.translate!(tx, ty); end
translate!(p1, p2) click to toggle source
static VALUE
cr_matrix_translate (VALUE self, VALUE tx, VALUE ty)
{
  cairo_matrix_translate (_SELF, NUM2DBL (tx), NUM2DBL (ty));
  return self;
}
x0() click to toggle source
static VALUE
cr_matrix_get_x0 (VALUE self)
{
  return rb_float_new (_SELF->x0);
}
xx() click to toggle source

Accessors

static VALUE
cr_matrix_get_xx (VALUE self)
{
  return rb_float_new (_SELF->xx);
}
xy() click to toggle source
static VALUE
cr_matrix_get_xy (VALUE self)
{
  return rb_float_new (_SELF->xy);
}
y0() click to toggle source
static VALUE
cr_matrix_get_y0 (VALUE self)
{
  return rb_float_new (_SELF->y0);
}
yx() click to toggle source
static VALUE
cr_matrix_get_yx (VALUE self)
{
  return rb_float_new (_SELF->yx);
}
yy() click to toggle source
static VALUE
cr_matrix_get_yy (VALUE self)
{
  return rb_float_new (_SELF->yy);
}