Method: Magick::Image#composite_mathematics

Defined in:
ext/RMagick/rmimage.c

#composite_mathematics(*args) ⇒ Object

Composite using MathematicsCompositeOp.

Ruby usage:

- @verbatim img.composite_mathematics(comp_img, A, B, C, D, gravity) @endverbatim
- @verbatim img.composite_mathematics(comp_img, A, B, C, D, x_off, y_off) @endverbatim
- @verbatim img.composite_mathematics(comp_img, A, B, C, D, gravity, x_off, y_off) @endverbatim

Notes:

- Default x_off is 0
- Default y_off is 0
- New in ImageMagick 6.5.4-3.

Parameters:

  • argc

    number of input arguments

  • argv

    array of input arguments

  • self

    this object

Returns:

  • a new image

[View source]

3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
# File 'ext/RMagick/rmimage.c', line 3549

VALUE
Image_composite_mathematics(int argc, VALUE *argv, VALUE self)
{
#if defined(HAVE_ENUM_MATHEMATICSCOMPOSITEOP)
    Image *composite_image;
    VALUE args[5];
    signed long x_off = 0L;
    signed long y_off = 0L;
    GravityType gravity = NorthWestGravity;
    char compose_args[200];

    rm_check_destroyed(self);
    if (argc > 0)
    {
        composite_image = rm_check_destroyed(rm_cur_image(argv[0]));
    }

    switch (argc)
    {
        case 8:
            VALUE_TO_ENUM(argv[5], gravity, GravityType);
            x_off = NUM2LONG(argv[6]);
            y_off = NUM2LONG(argv[7]);
            break;
        case 7:
            x_off = NUM2LONG(argv[5]);
            y_off = NUM2LONG(argv[6]);
            break;
        case 6:
            VALUE_TO_ENUM(argv[5], gravity, GravityType);
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (got %d, expected 6 to 8)", argc);
            break;
    }


    (void) sprintf(compose_args, "%-.16g,%-.16g,%-.16g,%-.16g", NUM2DBL(argv[1]), NUM2DBL(argv[2]), NUM2DBL(argv[3]), NUM2DBL(argv[4]));
    SetImageArtifact(composite_image,"compose:args", compose_args);

    // Call composite(False, gravity, x_off, y_off, MathematicsCompositeOp, DefaultChannels)
    args[0] = argv[0];
    args[1] = GravityType_new(gravity);
    args[2] = LONG2FIX(x_off);
    args[3] = LONG2FIX(y_off);
    args[4] = CompositeOperator_new(MathematicsCompositeOp);

    return composite(False, 5, args, self, DefaultChannels);

#else
    rm_not_implemented();
    argc = argc;
    argv = argv;
    self = self;
    return (VALUE)0;
#endif
}