Class: Rixmap::Deformer::AffineMatrix

Inherits:
Object
  • Object
show all
Defined in:
src/rixmapdeformation.cxx,
src/rixmapdeformation.cxx

Overview

アフィン変換用パラメータクラス.

Instance Method Summary collapse

Constructor Details

#initialize(*args) (private)

アフィン変換パラメータを初期化します.

Parameters:

  • params (Hash)

    初期化パラメータ



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'src/rixmapdeformation.cxx', line 305

static VALUE AffineMatrix_initialize(int argc, VALUE* argv, VALUE self) {
    // 引数解析
    VALUE argParams = Qnil;
    rb_scan_args(argc, argv, "01", &argParams);

    VALUE objParams = Qnil;
    if (!NIL_P(argParams)) {
#if HAVE_RB_HASH
        objParams = rb_Hash(argParams);
#else
        objParams = rb_hash_new();
#endif
    } else {
        objParams = rb_hash_new();
    }

    VALUE keys = rb_funcall(objParams, rb_intern("keys"), 0);
    long nkey = RARRAY_LEN(keys);
    for (long i = 0; i < nkey; i++) {
        VALUE key = rb_ary_entry(keys, i);
        VALUE val = rb_hash_lookup(objParams, key);

        // インスタンスメソッドを呼び出し
        rb_funcall(self, rb_intern_str(rb_String(key)), 1, val);
    }

    return self;
}

Instance Method Details

#angleFloat

回転角度をラジアンで取得します.

Returns:

  • (Float)

    回転角度



433
434
435
436
# File 'src/rixmapdeformation.cxx', line 433

static VALUE AffineMatrix_getAngle(VALUE self) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    return DBL2NUM(_this->getAngle());
}

#angle=(argAngle)

This method returns an undefined value.

回転角度を設定します.

Parameters:

  • angle (Float)

    回転角度 (ラジアン)



444
445
446
447
448
# File 'src/rixmapdeformation.cxx', line 444

static VALUE AffineMatrix_setAngle(VALUE self, VALUE argAngle) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    _this->setAngle(NUM2DBL(rb_Float(argAngle)));
    return argAngle;
}

#centerArray<Float>

変換中心点を取得します.

Returns:

  • (Array<Float>)

    中心点



354
355
356
357
358
359
360
# File 'src/rixmapdeformation.cxx', line 354

static VALUE AffineMatrix_getCenter(VALUE self) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    VALUE items = rb_ary_new();
    rb_ary_store(items, 0, DBL2NUM(_this->getCenter().x));
    rb_ary_store(items, 1, DBL2NUM(_this->getCenter().y));
    return items;
}

#center=(argPoint)

This method returns an undefined value.

変換中心点を設定します.

Parameters:

  • point (Array<Float>)

    中心点



368
369
370
371
372
373
374
375
# File 'src/rixmapdeformation.cxx', line 368

static VALUE AffineMatrix_setCenter(VALUE self, VALUE argPoint) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    VALUE items = rb_Array(argPoint);
    double x = NUM2DBL(rb_Float(rb_ary_entry(items, 0)));
    double y = NUM2DBL(rb_Float(rb_ary_entry(items, 1)));
    _this->setCenter(x, y);
    return argPoint;
}

#initialize_copy(argObject) (private)

This method returns an undefined value.

アフィン変換パラメータの複製を初期化します.

Parameters:

  • object (Object)

    複製元オブジェクト



340
341
342
343
344
345
346
347
# File 'src/rixmapdeformation.cxx', line 340

static VALUE AffineMatrix_initializeCopy(VALUE self, VALUE argObject) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    Rixmap::AffineMatrixData* _that = rixmap_unwrap<Rixmap::AffineMatrixData>(argObject);

    *_this = *_that;

    return self;
}

#inspectString

オブジェクトとしての文字列表現を返します.

Returns:

  • (String)

    文字列表現



510
511
512
513
514
515
516
517
518
519
520
521
# File 'src/rixmapdeformation.cxx', line 510

static VALUE AffineMatrix_inspect(VALUE self) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    return rb_enc_sprintf(
            rb_usascii_encoding(),
            "#<%s:%p scale=[%f, %f], trans=[%f, %f], center=[%f, %f], angle=%f, skew=%d>",
            rb_obj_classname(self), reinterpret_cast<void*>(self),
            _this->getScale().x, _this->getScale().y,
            _this->getTranslation().x, _this->getTranslation().y,
            _this->getCenter().x, _this->getCenter().y,
            _this->getAngle(),
            static_cast<int>(_this->getSkew()));
}

#scaleArray<Float>

拡大率を取得します.

Returns:

  • (Array<Float>)

    拡大率



382
383
384
385
386
387
388
# File 'src/rixmapdeformation.cxx', line 382

static VALUE AffineMatrix_getScale(VALUE self) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    VALUE items = rb_ary_new();
    rb_ary_store(items, 0, DBL2NUM(_this->getScale().x));
    rb_ary_store(items, 1, DBL2NUM(_this->getScale().y));
    return items;
}

#scale=(argScale) ⇒ Object

拡大率を設定します.

Parameters:

  • scale (Array<Float>)

    拡大率



395
396
397
398
399
400
# File 'src/rixmapdeformation.cxx', line 395

static VALUE AffineMatrix_setScale(VALUE self, VALUE argScale) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    VALUE items = rb_Array(argScale);
    _this->setScale(NUM2DBL(rb_Float(rb_ary_entry(items, 0))), NUM2DBL(rb_Float(rb_ary_entry(items, 1))));
    return argScale;
}

#skewInteger

剪断変形方向を取得します.

Returns:

  • (Integer)

    剪断変形方向定数値



455
456
457
458
459
460
461
462
463
464
465
466
# File 'src/rixmapdeformation.cxx', line 455

static VALUE AffineMatrix_getSkew(VALUE self) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    switch (_this->getSkew()) {
    case Rixmap::SkewDeformation::HORIZONTAL:
    case Rixmap::SkewDeformation::VERTICAL:
    case Rixmap::SkewDeformation::BOTH:
        return INT2FIX(static_cast<int>(_this->getSkew()));

    default:
        return Qnil;
    }
}

#skew=(argSkew)

This method returns an undefined value.

剪断変形方向を設定します.

Parameters:

  • skew (Symbol, String, Integer, nil)

    剪断変形方向



474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'src/rixmapdeformation.cxx', line 474

static VALUE AffineMatrix_setSkew(VALUE self, VALUE argSkew) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    if (NIL_P(argSkew)) {
        _this->setSkew(Rixmap::SkewDeformation::NONE);
    } else if (RB_TYPE_P(argSkew, T_FIXNUM)) {
        Rixmap::SkewDeformation skew = static_cast<Rixmap::SkewDeformation>(FIX2INT(argSkew));
        switch (skew) {
        case Rixmap::SkewDeformation::HORIZONTAL:
        case Rixmap::SkewDeformation::VERTICAL:
        case Rixmap::SkewDeformation::BOTH:
            _this->setSkew(skew);
            break;

        default:
            _this->setSkew(Rixmap::SkewDeformation::NONE);
            break;
        }
    } else {
        VALUE strSkew = rb_sprintf("SKEW_");
        strSkew = rb_str_concat(strSkew, rb_funcall(rb_String(argSkew), rb_intern("upcase"), 0, NULL));
        if (rb_const_defined(mRixmapDeformer, rb_intern_str(strSkew))) {
            VALUE objSkew = rb_const_get(mRixmapDeformer, rb_intern_str(strSkew));
            _this->setSkew(static_cast<Rixmap::SkewDeformation>(NUM2INT(rb_Integer(objSkew))));
        } else {
            _this->setSkew(Rixmap::SkewDeformation::NONE);
        }
    }

    return argSkew;
}

#translationArray<Float>

平行移動量を取得します.

Returns:

  • (Array<Float>)

    平行移動量



407
408
409
410
411
412
413
# File 'src/rixmapdeformation.cxx', line 407

static VALUE AffineMatrix_getTranslation(VALUE self) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    VALUE items = rb_ary_new();
    rb_ary_store(items, 0, DBL2NUM(_this->getTranslation().x));
    rb_ary_store(items, 1, DBL2NUM(_this->getTranslation().y));
    return items;
}

#translation=(argTrans)

This method returns an undefined value.

平行移動量を設定します.

Parameters:

  • trans (Array<Float>)

    平行移動量



421
422
423
424
425
426
# File 'src/rixmapdeformation.cxx', line 421

static VALUE AffineMatrix_setTranslation(VALUE self, VALUE argTrans) {
    Rixmap::AffineMatrixData* _this = rixmap_unwrap<Rixmap::AffineMatrixData>(self);
    VALUE items = rb_Array(argTrans);
    _this->setTranslation(NUM2DBL(rb_Float(rb_ary_entry(items, 0))), NUM2DBL(rb_Float(rb_ary_entry(items, 1))));
    return argTrans;
}