Class: SFML::Transformable
- Inherits:
-
Object
- Object
- SFML::Transformable
- Defined in:
- ext/graphics/transformable.c,
ext/graphics/transformable.c
Overview
A standalone position/rotation/scale/origin, decoupled from any drawable object -- the same transform state that Sprite, Text and Shape each carry internally, usable on its own (e.g. as a scene-graph node).
Instance Attribute Summary collapse
-
#origin ⇒ Vector2
Returns the object's origin.
-
#position ⇒ Vector2
Returns the object's position.
-
#rotation ⇒ Float
Returns the object's rotation, in degrees.
-
#scale ⇒ Vector2
Returns the object's scale factors.
Instance Method Summary collapse
-
#copy ⇒ Transformable
Returns a deep copy of the object.
-
#new ⇒ Transformable
constructor
Creates a transformable object with a default position, rotation and scale.
-
#inverse_transform ⇒ Array<Float>
Returns the 3x3 row-major inverse of the object's transform matrix.
-
#transform ⇒ Array<Float>
Returns the object's 3x3 row-major transform matrix.
-
#move(offset) ⇒ self
Adds
offsetto the current position. -
#rotate(angle) ⇒ self
Adds
angledegrees to the current rotation. -
#scale!(factors) ⇒ self
Multiplies the current scale componentwise by
factors. -
#transform ⇒ Array<Float>
Returns the object's 3x3 row-major transform matrix.
Constructor Details
#new ⇒ Transformable
Creates a transformable object with a default position, rotation and scale.
44 45 46 |
# File 'ext/graphics/transformable.c', line 44 static VALUE Transformable_init(VALUE self) { return self; } |
Instance Attribute Details
#origin ⇒ Vector2
Returns the object's origin.
231 232 233 234 235 |
# File 'ext/graphics/transformable.c', line 231 static VALUE Transformable_get_origin(VALUE self) { sfVector2f origin = sfTransformable_getOrigin(Get_Transformable_Struct(self)); return VEC2_C2RB(origin); } |
#position ⇒ Vector2
Returns the object's position.
231 232 233 234 235 |
# File 'ext/graphics/transformable.c', line 231 static VALUE Transformable_get_position(VALUE self) { sfVector2f position = sfTransformable_getPosition(Get_Transformable_Struct(self)); return VEC2_C2RB(position); } |
#rotation ⇒ Float
Returns the object's rotation, in degrees.
231 232 233 |
# File 'ext/graphics/transformable.c', line 231 static VALUE Transformable_get_rotation(VALUE self) { return DBL2NUM(sfTransformable_getRotation(Get_Transformable_Struct(self))); } |
#scale ⇒ Vector2
Returns the object's scale factors.
231 232 233 234 235 |
# File 'ext/graphics/transformable.c', line 231 static VALUE Transformable_get_scale(VALUE self) { sfVector2f scale = sfTransformable_getScale(Get_Transformable_Struct(self)); return VEC2_C2RB(scale); } |
Instance Method Details
#copy ⇒ Transformable
Returns a deep copy of the object.
222 223 224 225 226 227 228 229 |
# File 'ext/graphics/transformable.c', line 222
static VALUE Transformable_copy(VALUE self) {
sfTransformable* copy = sfTransformable_copy(Get_Transformable_Struct(self));
VALUE other = TypedData_Wrap_Struct(rb_cTransformable, &Transformable_data_type, copy);
rb_obj_call_init(other, 0, NULL);
return other;
}
|
#inverse_transform ⇒ Array<Float>
Returns the 3x3 row-major inverse of the object's transform matrix.
210 211 212 213 214 |
# File 'ext/graphics/transformable.c', line 210 static VALUE Transformable_get_inverse_matrix(VALUE self) { sfTransform transform = sfTransformable_getInverseTransform(Get_Transformable_Struct(self)); return Transform_MatrixToArray(transform.matrix); } |
#transform ⇒ Array<Float>
Returns the object's 3x3 row-major transform matrix.
197 198 199 200 201 202 |
# File 'ext/graphics/transformable.c', line 197 static VALUE Transformable_get_matrix(VALUE self) { sfTransformable* transformable = Get_Transformable_Struct(self); sfTransform transform = sfTransformable_getTransform(transformable); return Transform_MatrixToArray(transform.matrix); } |
#move(offset) ⇒ self
Adds offset to the current position.
156 157 158 159 160 161 |
# File 'ext/graphics/transformable.c', line 156
static VALUE Transformable_move(VALUE self, VALUE rb_move) {
sfVector2f move = VEC2_RB2C(rb_move);
sfTransformable_move(Get_Transformable_Struct(self), move);
return self;
}
|
#rotate(angle) ⇒ self
Adds angle degrees to the current rotation.
170 171 172 173 174 |
# File 'ext/graphics/transformable.c', line 170
static VALUE Transformable_rotate(VALUE self, VALUE rb_angle) {
sfTransformable_rotate(Get_Transformable_Struct(self), NUM2DBL(rb_angle));
return self;
}
|
#scale!(factors) ⇒ self
Multiplies the current scale componentwise by factors.
183 184 185 186 187 188 |
# File 'ext/graphics/transformable.c', line 183
static VALUE Transformable_scale(VALUE self, VALUE rb_scale) {
sfVector2f scale = VEC2_RB2C(rb_scale);
sfTransformable_scale(Get_Transformable_Struct(self), scale);
return self;
}
|
#transform ⇒ Array<Float>
Returns the object's 3x3 row-major transform matrix.
197 198 199 200 201 202 |
# File 'ext/graphics/transformable.c', line 197 static VALUE Transformable_get_matrix(VALUE self) { sfTransformable* transformable = Get_Transformable_Struct(self); sfTransform transform = sfTransformable_getTransform(transformable); return Transform_MatrixToArray(transform.matrix); } |