Class: SFML::Circle
- Inherits:
-
Object
- Object
- SFML::Circle
- Defined in:
- ext/graphics/circle.c,
ext/graphics/circle.c
Overview
A circle shape, drawable, transformable and stylable like the other SFML shapes. Includes Drawable.
Instance Attribute Summary collapse
-
#fill_color ⇒ Color
Returns the shape's fill color.
-
#origin ⇒ Vector2
Returns the object's origin.
-
#outline_color ⇒ Color
Returns the shape's outline color.
-
#outline_thickness ⇒ Float
Returns the shape's outline thickness.
-
#point_count ⇒ Integer
Returns the number of points composing the shape.
-
#position ⇒ Vector2
Returns the object's position.
-
#radius ⇒ Float
Returns the circle's radius.
-
#rotation ⇒ Float
Returns the object's rotation, in degrees.
-
#scale ⇒ Vector2
Returns the object's scale factors.
-
#texture ⇒ Texture?
Returns the object's texture, or
nilif it has none. -
#texture_rect ⇒ Rect
Returns the sub-rectangle of the texture displayed on the object.
Instance Method Summary collapse
-
#copy ⇒ Circle
Returns a deep copy of the circle, including its texture reference.
-
#draw(target, state) ⇒ nil
Draws the circle onto
targetusing the given renderstate. -
#geometric_center ⇒ Vector2
Returns the local position of the shape's geometric center.
-
#global_bounds ⇒ Rect
Returns the bounding box after the transform is applied.
-
#new(radius = 0) ⇒ Circle
constructor
Creates a circle shape with the given
radius(0 by default). -
#inverse_transform ⇒ Array
Returns the 3x3 row-major inverse of the circle's transform matrix.
-
#local_bounds ⇒ Rect
Returns the bounding box in local (untransformed) coordinates.
-
#transform ⇒ Array
Also available as #matrix.
-
#move(offset) ⇒ self
Moves the circle by
offset. -
#point(index) ⇒ Vector2
Returns the local position of the point at
index. -
#rotate(angle) ⇒ self
Rotates the circle by
angledegrees. -
#scale!(factors) ⇒ self
Scales the circle by
factorsrelative to its current scale. -
#transform ⇒ Array
Also available as #matrix.
Constructor Details
#new(radius = 0) ⇒ Circle
Creates a circle shape with the given radius (0 by default).
92 93 94 95 96 97 98 99 100 101 102 |
# File 'ext/graphics/circle.c', line 92
static VALUE Circle_initialize(int argc, VALUE* argv, VALUE self) {
VALUE rb_radius;
rb_scan_args(argc, argv, "01", &rb_radius);
if (!NIL_P(rb_radius)) {
sfCircleShape_setRadius(Get_Circle_Shape(self), NUM2DBL(rb_radius));
}
return self;
}
|
Instance Attribute Details
#fill_color ⇒ Color
Returns the shape's fill color.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_fill_color(VALUE self) { return color_to_rb(sfCircleShape_getFillColor(Get_Circle_Shape(self))); } |
#origin ⇒ Vector2
Returns the object's origin.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_origin(VALUE self) { return vec2f_to_rb(sfCircleShape_getOrigin(Get_Circle_Shape(self))); } |
#outline_color ⇒ Color
Returns the shape's outline color.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_outline_color(VALUE self) { return color_to_rb(sfCircleShape_getOutlineColor(Get_Circle_Shape(self))); } |
#outline_thickness ⇒ Float
Returns the shape's outline thickness.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_outline_thickness(VALUE self) { return DBL2NUM(sfCircleShape_getOutlineThickness(Get_Circle_Shape(self))); } |
#point_count ⇒ Integer
Returns the number of points composing the shape.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_point_count(VALUE self) { return SIZET2NUM(sfCircleShape_getPointCount(Get_Circle_Shape(self))); } |
#position ⇒ Vector2
Returns the object's position.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_position(VALUE self) { return vec2f_to_rb(sfCircleShape_getPosition(Get_Circle_Shape(self))); } |
#radius ⇒ Float
Returns the circle's radius.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_radius(VALUE self) { return DBL2NUM(sfCircleShape_getRadius(Get_Circle_Shape(self))); } |
#rotation ⇒ Float
Returns the object's rotation, in degrees.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_rotation(VALUE self) { return DBL2NUM(sfCircleShape_getRotation(Get_Circle_Shape(self))); } |
#scale ⇒ Vector2
Returns the object's scale factors.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_scale(VALUE self) { return vec2f_to_rb(sfCircleShape_getScale(Get_Circle_Shape(self))); } |
#texture ⇒ Texture?
Returns the object's texture, or nil if it has none.
498 499 500 |
# File 'ext/graphics/circle.c', line 498
static VALUE Circle_get_texture(VALUE self) {
return Get_Circle(self)->rb_texture;
}
|
#texture_rect ⇒ Rect
Returns the sub-rectangle of the texture displayed on the object.
498 499 500 |
# File 'ext/graphics/circle.c', line 498 static VALUE Circle_get_texture_rect(VALUE self) { return int_rect_to_rb(sfCircleShape_getTextureRect(Get_Circle_Shape(self))); } |
Instance Method Details
#copy ⇒ Circle
Returns a deep copy of the circle, including its texture reference.
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'ext/graphics/circle.c', line 110
static VALUE Circle_copy(VALUE self) {
Circle* ptr = Get_Circle(self);
VALUE copy = Circle_wrap(Get_Klass_Circle(), sfCircleShape_copy(ptr->shape));
if (!NIL_P(ptr->rb_texture)) {
Circle* copy_ptr = Get_Circle(copy);
copy_ptr->rb_texture = ptr->rb_texture;
sfCircleShape_setTexture(copy_ptr->shape, Get_Texture_Struct(ptr->rb_texture), false);
}
return copy;
}
|
#draw(target, state) ⇒ nil
Draws the circle onto target using the given render state.
485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'ext/graphics/circle.c', line 485
static VALUE Circle_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
TargetView view = Get_RenderTarget_View(rb_target);
if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
raise_invalid_argument_class(Get_Klass_RenderState());
}
TARGET_DRAW(view, sfRenderWindow_drawCircleShape, sfRenderTexture_drawCircleShape,
Get_Circle_Shape(self), Get_RenderState_Struct(rb_state));
return Qnil;
}
|
#geometric_center ⇒ Vector2
Returns the local position of the shape's geometric center.
454 455 456 |
# File 'ext/graphics/circle.c', line 454 static VALUE Circle_get_geometric_center(VALUE self) { return vec2f_to_rb(sfCircleShape_getGeometricCenter(Get_Circle_Shape(self))); } |
#global_bounds ⇒ Rect
Returns the bounding box after the transform is applied.
474 475 476 |
# File 'ext/graphics/circle.c', line 474 static VALUE Circle_get_global_bounds(VALUE self) { return rect_to_rb(sfCircleShape_getGlobalBounds(Get_Circle_Shape(self))); } |
#inverse_transform ⇒ Array
Returns the 3x3 row-major inverse of the circle's transform matrix.
350 351 352 353 |
# File 'ext/graphics/circle.c', line 350 static VALUE Circle_get_inverse_transform(VALUE self) { return Transform_MatrixToArray( sfCircleShape_getInverseTransform(Get_Circle_Shape(self)).matrix); } |
#local_bounds ⇒ Rect
Returns the bounding box in local (untransformed) coordinates.
464 465 466 |
# File 'ext/graphics/circle.c', line 464 static VALUE Circle_get_local_bounds(VALUE self) { return rect_to_rb(sfCircleShape_getLocalBounds(Get_Circle_Shape(self))); } |
#transform ⇒ Array
Also available as #matrix.
340 341 342 |
# File 'ext/graphics/circle.c', line 340 static VALUE Circle_get_transform(VALUE self) { return Transform_MatrixToArray(sfCircleShape_getTransform(Get_Circle_Shape(self)).matrix); } |
#move(offset) ⇒ self
Moves the circle by offset.
306 307 308 309 |
# File 'ext/graphics/circle.c', line 306
static VALUE Circle_move(VALUE self, VALUE rb_move) {
sfCircleShape_move(Get_Circle_Shape(self), vec2f_from_rb(rb_move));
return self;
}
|
#point(index) ⇒ Vector2
Returns the local position of the point at index.
444 445 446 |
# File 'ext/graphics/circle.c', line 444
static VALUE Circle_get_point(VALUE self, VALUE rb_index) {
return vec2f_to_rb(sfCircleShape_getPoint(Get_Circle_Shape(self), (size_t)NUM2SIZET(rb_index)));
}
|
#rotate(angle) ⇒ self
Rotates the circle by angle degrees.
317 318 319 320 |
# File 'ext/graphics/circle.c', line 317
static VALUE Circle_rotate(VALUE self, VALUE rb_angle) {
sfCircleShape_rotate(Get_Circle_Shape(self), NUM2DBL(rb_angle));
return self;
}
|
#scale!(factors) ⇒ self
Scales the circle by factors relative to its current scale.
329 330 331 332 |
# File 'ext/graphics/circle.c', line 329
static VALUE Circle_scale(VALUE self, VALUE rb_scale) {
sfCircleShape_scale(Get_Circle_Shape(self), vec2f_from_rb(rb_scale));
return self;
}
|
#transform ⇒ Array
Also available as #matrix.
340 341 342 |
# File 'ext/graphics/circle.c', line 340 static VALUE Circle_get_transform(VALUE self) { return Transform_MatrixToArray(sfCircleShape_getTransform(Get_Circle_Shape(self)).matrix); } |