sfml3.rb

Class: SFML::View

Inherits:
Object
  • Object
show all
Defined in:
ext/graphics/view.c,
ext/graphics/view.c

Overview

A 2D camera: the region of the scene visible on a render target, and where on that target it is shown.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#new ⇒ View

Creates a default view covering the (0, 0) - (1000, 1000) region.



76
77
78
# File 'ext/graphics/view.c', line 76

static VALUE View_init(VALUE self) {
    return self;
}

Instance Attribute Details

#center ⇒ Vector2

Returns the view's center.

Returns:

Returns:



243
244
245
# File 'ext/graphics/view.c', line 243

static VALUE View_get_center(VALUE self) {
    return vec2f_to_rb(sfView_getCenter(Get_View_Struct(self)));
}

#rotation ⇒ Float

Returns the object's rotation, in degrees.

Returns:

  • (Float)

Returns:

  • (Float) —

    degrees



243
244
245
# File 'ext/graphics/view.c', line 243

static VALUE View_get_rotation(VALUE self) {
    return DBL2NUM(sfView_getRotation(Get_View_Struct(self)));
}

#scissor ⇒ Rect

Returns the target's scissor rectangle, or nil if none is set.

Returns:

Returns:



243
244
245
# File 'ext/graphics/view.c', line 243

static VALUE View_get_scissor(VALUE self) {
    return RECT_C2RB(sfView_getScissor(Get_View_Struct(self)));
}

#size ⇒ Vector2

Returns the object's size.

Returns:

Returns:



243
244
245
# File 'ext/graphics/view.c', line 243

static VALUE View_get_size(VALUE self) {
    return vec2f_to_rb(sfView_getSize(Get_View_Struct(self)));
}

#viewport ⇒ Rect

Returns the target's viewport rectangle, or nil if none is set.

Returns:

Returns:



243
244
245
# File 'ext/graphics/view.c', line 243

static VALUE View_get_viewport(VALUE self) {
    return RECT_C2RB(sfView_getViewport(Get_View_Struct(self)));
}

Class Method Details

.from_rect(rect) ⇒ View

Creates a view covering the given rectangle.

Returns:

Returns:

  • (View) —

    a view whose visible area is rect (position is the top-left corner)



65
66
67
# File 'ext/graphics/view.c', line 65

static VALUE View_s_from_rect(VALUE klass, VALUE rb_rect) {
    return View_new_from(klass, sfView_createFromRect(rect_from_rb(rb_rect)));
}

Instance Method Details

#copy ⇒ View

Returns a deep copy of the object.

Returns:

Returns:

  • (View) —

    an independent copy



239
240
241
# File 'ext/graphics/view.c', line 239

static VALUE View_copy(VALUE self) {
    return Get_Casting_View(sfView_copy(Get_View_Struct(self)));
}

#move(offset) ⇒ self

Moves the object by offset.

Returns:

  • (self)

Returns:

  • (self)


202
203
204
205
# File 'ext/graphics/view.c', line 202

static VALUE View_move(VALUE self, VALUE rb_move) {
    sfView_move(Get_View_Struct(self), vec2f_from_rb(rb_move));
    return self;
}

#rotate(angle) ⇒ self

Rotates the object by angle degrees.

Returns:

  • (self)

Returns:

  • (self)


214
215
216
217
218
# File 'ext/graphics/view.c', line 214

static VALUE View_rotate(VALUE self, VALUE rb_angle) {
    sfView_rotate(Get_View_Struct(self), NUM2DBL(rb_angle));

    return self;
}

#zoom(factor) ⇒ self

Multiplies the view's size by factor.

Returns:

  • (self)

Returns:

  • (self)


227
228
229
230
231
# File 'ext/graphics/view.c', line 227

static VALUE View_zoom(VALUE self, VALUE rb_zoom) {
    sfView_zoom(Get_View_Struct(self), NUM2DBL(rb_zoom));

    return self;
}