Class: SDL2::Point

Inherits:
Object
  • Object
show all
Defined in:
ext/sdl2_ext/video.c,
ext/sdl2_ext/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



3148
3149
3150
3151
3152
3153
3154
3155
3156
# File 'ext/sdl2_ext/video.c', line 3148

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 coordinate of the point.

Returns:

  • (Integer)

#yInteger

Y coordinate of the point.

Returns:

  • (Integer)

Instance Method Details

#inspectString

Return inspection string.

Returns:

  • (String)


3162
3163
3164
3165
3166
# File 'ext/sdl2_ext/video.c', line 3162

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);
}