class Cairo::Matrix
Public Class Methods
Source
static VALUE
cr_matrix_init_identity (VALUE self)
{
cairo_matrix_t matrix;
cairo_matrix_init_identity (&matrix);
return CRMATRIX2RVAL (&matrix);
}
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));
RTYPEDDATA_DATA (self) = matrix;
return Qnil;
}
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);
}
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);
}
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
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));
}
Source
# File lib/cairo.rb, line 97 def clone copy = dup copy.freeze if self.frozen? copy end
Source
static VALUE
cr_matrix_identity (VALUE self)
{
cairo_matrix_init_identity (_SELF);
return self;
}
Source
static VALUE
cr_matrix_invert (VALUE self)
{
rb_cairo_check_status (cairo_matrix_invert (_SELF));
return self;
}
Source
# File lib/cairo.rb, line 107 def multiply(other); dup.multiply!(other); end
Also aliased as: *
Source
static VALUE
cr_matrix_multiply (VALUE self, VALUE other)
{
cairo_matrix_multiply (_SELF, _SELF, RVAL2CRMATRIX (other));
return self;
}
Source
# File lib/cairo.rb, line 105 def rotate(radians); dup.rotate!(radians); end
Source
static VALUE
cr_matrix_rotate (VALUE self, VALUE radians)
{
cairo_matrix_rotate (_SELF, NUM2DBL (radians));
return self;
}
Source
static VALUE
cr_matrix_scale (VALUE self, VALUE sx, VALUE sy)
{
cairo_matrix_scale (_SELF, NUM2DBL (sx), NUM2DBL (sy));
return self;
}
Source
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;
}
Utilities
Source
static VALUE
cr_matrix_set_x0 (VALUE self, VALUE x0)
{
_SELF->x0 = NUM2DBL (x0);
return Qnil;
}
Source
static VALUE
cr_matrix_set_xx (VALUE self, VALUE xx)
{
_SELF->xx = NUM2DBL (xx);
return Qnil;
}
Source
static VALUE
cr_matrix_set_xy (VALUE self, VALUE xy)
{
_SELF->xy = NUM2DBL (xy);
return Qnil;
}
Source
static VALUE
cr_matrix_set_y0 (VALUE self, VALUE y0)
{
_SELF->y0 = NUM2DBL (y0);
return Qnil;
}
Source
static VALUE
cr_matrix_set_yx (VALUE self, VALUE yx)
{
_SELF->yx = NUM2DBL (yx);
return Qnil;
}
Source
static VALUE
cr_matrix_set_yy (VALUE self, VALUE yy)
{
_SELF->yy = NUM2DBL (yy);
return Qnil;
}
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);
}
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;
}
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);
}
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);
}
Source
# File lib/cairo.rb, line 103 def translate(tx, ty); dup.translate!(tx, ty); end
Source
static VALUE
cr_matrix_translate (VALUE self, VALUE tx, VALUE ty)
{
cairo_matrix_translate (_SELF, NUM2DBL (tx), NUM2DBL (ty));
return self;
}
Source
static VALUE
cr_matrix_get_xx (VALUE self)
{
return rb_float_new (_SELF->xx);
}
Accessors