Class: Cairo::Matrix
- Inherits:
-
Object
- Object
- Cairo::Matrix
- Defined in:
- lib/cairo.rb,
ext/cairo/rb_cairo_matrix.c
Class Method Summary collapse
Instance Method Summary collapse
- #== ⇒ Object
- #clone ⇒ Object
- #dup ⇒ Object
- #identity! ⇒ Object
- #initialize ⇒ Object constructor
- #invert ⇒ Object
- #invert! ⇒ Object
- #multiply(other) ⇒ Object (also: #*)
- #multiply! ⇒ Object
- #rotate(radians) ⇒ Object
- #rotate! ⇒ Object
- #scale(sx, sy) ⇒ Object
- #scale! ⇒ Object
-
#set ⇒ Object
Utilities.
- #set_x0 ⇒ Object
- #set_xx ⇒ Object
- #set_xy ⇒ Object
- #set_y0 ⇒ Object
- #set_yx ⇒ Object
- #set_yy ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
- #transform_distance ⇒ Object
- #transform_point ⇒ Object
- #translate(tx, ty) ⇒ Object
- #translate! ⇒ Object
- #x0 ⇒ Object
-
#xx ⇒ Object
Accessors.
- #xy ⇒ Object
- #y0 ⇒ Object
- #yx ⇒ Object
- #yy ⇒ Object
Constructor Details
#initialize ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'ext/cairo/rb_cairo_matrix.c', line 69
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;
}
|
Class Method Details
.identity ⇒ Object
85 86 87 88 89 90 91 |
# File 'ext/cairo/rb_cairo_matrix.c', line 85
static VALUE
cr_matrix_init_identity (VALUE self)
{
cairo_matrix_t matrix;
cairo_matrix_init_identity (&matrix);
return CRMATRIX2RVAL (&matrix);
}
|
.rotate ⇒ Object
109 110 111 112 113 114 115 |
# File 'ext/cairo/rb_cairo_matrix.c', line 109
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 ⇒ Object
101 102 103 104 105 106 107 |
# File 'ext/cairo/rb_cairo_matrix.c', line 101
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 ⇒ Object
93 94 95 96 97 98 99 |
# File 'ext/cairo/rb_cairo_matrix.c', line 93
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);
}
|
Instance Method Details
#== ⇒ Object
301 302 303 304 305 306 307 308 309 310 |
# File 'ext/cairo/rb_cairo_matrix.c', line 301
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 ⇒ Object
122 123 124 125 126 |
# File 'lib/cairo.rb', line 122 def clone copy = dup copy.freeze if self.frozen? copy end |
#identity! ⇒ Object
117 118 119 120 121 122 |
# File 'ext/cairo/rb_cairo_matrix.c', line 117
static VALUE
cr_matrix_identity (VALUE self)
{
cairo_matrix_init_identity (_SELF);
return self;
}
|
#invert ⇒ Object
131 |
# File 'lib/cairo.rb', line 131 def invert; dup.invert!; end |
#invert! ⇒ Object
145 146 147 148 149 150 |
# File 'ext/cairo/rb_cairo_matrix.c', line 145
static VALUE
cr_matrix_invert (VALUE self)
{
rb_cairo_check_status (cairo_matrix_invert (_SELF));
return self;
}
|
#multiply(other) ⇒ Object Also known as: *
132 |
# File 'lib/cairo.rb', line 132 def multiply(other); dup.multiply!(other); end |
#multiply! ⇒ Object
152 153 154 155 156 157 |
# File 'ext/cairo/rb_cairo_matrix.c', line 152
static VALUE
cr_matrix_multiply (VALUE self, VALUE other)
{
cairo_matrix_multiply (_SELF, _SELF, RVAL2CRMATRIX (other));
return self;
}
|
#rotate(radians) ⇒ Object
130 |
# File 'lib/cairo.rb', line 130 def rotate(radians); dup.rotate!(radians); end |
#rotate! ⇒ Object
138 139 140 141 142 143 |
# File 'ext/cairo/rb_cairo_matrix.c', line 138
static VALUE
cr_matrix_rotate (VALUE self, VALUE radians)
{
cairo_matrix_rotate (_SELF, NUM2DBL (radians));
return self;
}
|
#scale(sx, sy) ⇒ Object
129 |
# File 'lib/cairo.rb', line 129 def scale(sx, sy); dup.scale!(sx, sy); end |
#scale! ⇒ Object
131 132 133 134 135 136 |
# File 'ext/cairo/rb_cairo_matrix.c', line 131
static VALUE
cr_matrix_scale (VALUE self, VALUE sx, VALUE sy)
{
cairo_matrix_scale (_SELF, NUM2DBL (sx), NUM2DBL (sy));
return self;
}
|
#set ⇒ Object
Utilities
260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'ext/cairo/rb_cairo_matrix.c', line 260
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 ⇒ Object
239 240 241 242 243 244 |
# File 'ext/cairo/rb_cairo_matrix.c', line 239
static VALUE
cr_matrix_set_x0 (VALUE self, VALUE x0)
{
_SELF->x0 = NUM2DBL (x0);
return Qnil;
}
|
#set_xx ⇒ Object
187 188 189 190 191 192 |
# File 'ext/cairo/rb_cairo_matrix.c', line 187
static VALUE
cr_matrix_set_xx (VALUE self, VALUE xx)
{
_SELF->xx = NUM2DBL (xx);
return Qnil;
}
|
#set_xy ⇒ Object
213 214 215 216 217 218 |
# File 'ext/cairo/rb_cairo_matrix.c', line 213
static VALUE
cr_matrix_set_xy (VALUE self, VALUE xy)
{
_SELF->xy = NUM2DBL (xy);
return Qnil;
}
|
#set_y0 ⇒ Object
252 253 254 255 256 257 |
# File 'ext/cairo/rb_cairo_matrix.c', line 252
static VALUE
cr_matrix_set_y0 (VALUE self, VALUE y0)
{
_SELF->y0 = NUM2DBL (y0);
return Qnil;
}
|
#set_yx ⇒ Object
200 201 202 203 204 205 |
# File 'ext/cairo/rb_cairo_matrix.c', line 200
static VALUE
cr_matrix_set_yx (VALUE self, VALUE yx)
{
_SELF->yx = NUM2DBL (yx);
return Qnil;
}
|
#set_yy ⇒ Object
226 227 228 229 230 231 |
# File 'ext/cairo/rb_cairo_matrix.c', line 226
static VALUE
cr_matrix_set_yy (VALUE self, VALUE yy)
{
_SELF->yy = NUM2DBL (yy);
return Qnil;
}
|
#to_a ⇒ Object
273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'ext/cairo/rb_cairo_matrix.c', line 273
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 ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'ext/cairo/rb_cairo_matrix.c', line 287
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 ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'ext/cairo/rb_cairo_matrix.c', line 159
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 ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'ext/cairo/rb_cairo_matrix.c', line 169
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) ⇒ Object
128 |
# File 'lib/cairo.rb', line 128 def translate(tx, ty); dup.translate!(tx, ty); end |
#translate! ⇒ Object
124 125 126 127 128 129 |
# File 'ext/cairo/rb_cairo_matrix.c', line 124
static VALUE
cr_matrix_translate (VALUE self, VALUE tx, VALUE ty)
{
cairo_matrix_translate (_SELF, NUM2DBL (tx), NUM2DBL (ty));
return self;
}
|
#x0 ⇒ Object
233 234 235 236 237 |
# File 'ext/cairo/rb_cairo_matrix.c', line 233
static VALUE
cr_matrix_get_x0 (VALUE self)
{
return rb_float_new (_SELF->x0);
}
|
#xx ⇒ Object
Accessors
181 182 183 184 185 |
# File 'ext/cairo/rb_cairo_matrix.c', line 181
static VALUE
cr_matrix_get_xx (VALUE self)
{
return rb_float_new (_SELF->xx);
}
|
#xy ⇒ Object
207 208 209 210 211 |
# File 'ext/cairo/rb_cairo_matrix.c', line 207
static VALUE
cr_matrix_get_xy (VALUE self)
{
return rb_float_new (_SELF->xy);
}
|
#y0 ⇒ Object
246 247 248 249 250 |
# File 'ext/cairo/rb_cairo_matrix.c', line 246
static VALUE
cr_matrix_get_y0 (VALUE self)
{
return rb_float_new (_SELF->y0);
}
|
#yx ⇒ Object
194 195 196 197 198 |
# File 'ext/cairo/rb_cairo_matrix.c', line 194
static VALUE
cr_matrix_get_yx (VALUE self)
{
return rb_float_new (_SELF->yx);
}
|
#yy ⇒ Object
220 221 222 223 224 |
# File 'ext/cairo/rb_cairo_matrix.c', line 220
static VALUE
cr_matrix_get_yy (VALUE self)
{
return rb_float_new (_SELF->yy);
}
|