Class: SDL2::Point

Inherits:
Object
  • Object
show all
Defined in:
video.c,
video.c

Overview

This class represents a point in SDL library. Some method requires this method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ SDL2::Point #initializeSDL2::Point

Create a new point object.

Overloads:

  • #initialize(x, y) ⇒ SDL2::Point

    Parameters:

    • x

      the x coordinate of the point

    • y

      the y coordinate of the point

  • #initializeSDL2::Point

    x and y of the created point object are initialized by 0



2605
2606
2607
2608
2609
2610
2611
2612
2613
# File 'video.c', line 2605

static VALUE Point_initialize(int argc, VALUE* argv, VALUE self)
{
    VALUE x, y;
    SDL_Point* point = Get_SDL_Point(self);
    rb_scan_args(argc, argv, "02", &x, &y);
    point->x = (x == Qnil) ? 0 : NUM2INT(x);
    point->y = (y == Qnil) ? 0 : NUM2INT(y);
    return Qnil;
}

Instance Attribute Details

#xInteger

X coordiante of the point.

Returns:

  • (Integer)

#yInteger

Y coordiante of the point.

Returns:

  • (Integer)

Instance Method Details

#inspectString

Return inspection string.

Returns:

  • (String)


2619
2620
2621
2622
2623
# File 'video.c', line 2619

static VALUE Point_inspect(VALUE self)
{
    SDL_Point* point = Get_SDL_Point(self);
    return rb_sprintf("<SDL2::Point x=%d y=%d>", point->x, point->y);
}