Class: SFML::CircleShape
- Inherits:
-
Object
- Object
- SFML::CircleShape
- Defined in:
- lib/sfml/graphics/circle_shape.rb
Overview
Constant Summary collapse
- CSFML_PREFIX =
:sfCircleShape
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#draw_on(target, states_ptr = nil) ⇒ Object
Returns the draw on.
-
#fill_color ⇒ Object
Interior fill color.
-
#fill_color=(c) ⇒ Object
Set the fill color.
-
#initialize(radius: 10.0, **opts) ⇒ CircleShape
constructor
Build a CircleShape.
-
#outline_color ⇒ Object
Outline color (only visible when
#outline_thickness > 0). -
#outline_color=(c) ⇒ Object
Set the outline color.
-
#outline_thickness ⇒ Object
Outline thickness in pixels.
-
#outline_thickness=(t) ⇒ Object
Set the outline thickness.
-
#point_count ⇒ Object
Number of points used to approximate the circle.
-
#point_count=(n) ⇒ Object
Set the point count — see
#point_count. -
#radius ⇒ Object
Radius in pixels.
-
#radius=(value) ⇒ Object
Set the radius.
Methods included from Graphics::ShapeInspectable
#dup, #geometric_center, #global_bounds, #inverse_transform, #local_bounds, #point, #set_texture, #texture, #texture=, #texture_rect, #texture_rect=, #transform
Methods included from Graphics::Transformable
#move, #origin, #origin=, #position, #position=, #rotate, #rotation, #rotation=, #scale, #scale=, #scale_by
Constructor Details
#initialize(radius: 10.0, **opts) ⇒ CircleShape
Build a CircleShape. radius defaults to 10 px. Any of the
standard styling / transform kwargs can be passed (fill_color,
outline_color, outline_thickness, texture, texture_rect,
position, origin, rotation, scale, point_count).
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sfml/graphics/circle_shape.rb', line 20 def initialize(radius: 10.0, **opts) ptr = C::Graphics.sfCircleShape_create raise GraphicsError, "sfCircleShape_create returned NULL" if ptr.null? @handle = FFI::AutoPointer.new(ptr, C::Graphics.method(:sfCircleShape_destroy)) self.radius = radius self.point_count = opts[:point_count] if opts[:point_count] self.fill_color = opts[:fill_color] if opts.key?(:fill_color) self.outline_color = opts[:outline_color] if opts.key?(:outline_color) self.outline_thickness = opts[:outline_thickness] if opts.key?(:outline_thickness) self.texture = opts[:texture] if opts.key?(:texture) self.texture_rect = opts[:texture_rect] if opts.key?(:texture_rect) self.position = opts[:position] if opts.key?(:position) self.origin = opts[:origin] if opts.key?(:origin) self.rotation = opts[:rotation] if opts.key?(:rotation) self.scale = opts[:scale] if opts.key?(:scale) end |
Instance Attribute Details
#handle ⇒ Object (readonly)
:nodoc:
85 86 87 |
# File 'lib/sfml/graphics/circle_shape.rb', line 85 def handle @handle end |
Instance Method Details
#draw_on(target, states_ptr = nil) ⇒ Object
Returns the draw on.
81 82 83 |
# File 'lib/sfml/graphics/circle_shape.rb', line 81 def draw_on(target, states_ptr = nil) # :nodoc: target._draw_native(:CircleShape, @handle, states_ptr) end |
#fill_color ⇒ Object
Interior fill color.
56 |
# File 'lib/sfml/graphics/circle_shape.rb', line 56 def fill_color = Color.from_native(C::Graphics.sfCircleShape_getFillColor(@handle)) |
#fill_color=(c) ⇒ Object
Set the fill color.
59 60 61 |
# File 'lib/sfml/graphics/circle_shape.rb', line 59 def fill_color=(c) C::Graphics.sfCircleShape_setFillColor(@handle, c.to_native) end |
#outline_color ⇒ Object
Outline color (only visible when #outline_thickness > 0).
64 |
# File 'lib/sfml/graphics/circle_shape.rb', line 64 def outline_color = Color.from_native(C::Graphics.sfCircleShape_getOutlineColor(@handle)) |
#outline_color=(c) ⇒ Object
Set the outline color.
67 68 69 |
# File 'lib/sfml/graphics/circle_shape.rb', line 67 def outline_color=(c) C::Graphics.sfCircleShape_setOutlineColor(@handle, c.to_native) end |
#outline_thickness ⇒ Object
Outline thickness in pixels. Outline is drawn outward by default — set negative for inward.
73 |
# File 'lib/sfml/graphics/circle_shape.rb', line 73 def outline_thickness = C::Graphics.sfCircleShape_getOutlineThickness(@handle) |
#outline_thickness=(t) ⇒ Object
Set the outline thickness.
76 77 78 |
# File 'lib/sfml/graphics/circle_shape.rb', line 76 def outline_thickness=(t) C::Graphics.sfCircleShape_setOutlineThickness(@handle, t.to_f) end |
#point_count ⇒ Object
Number of points used to approximate the circle. Default 30 (smooth); set to 3-8 for a regular polygon (triangle, square, ...).
48 |
# File 'lib/sfml/graphics/circle_shape.rb', line 48 def point_count = C::Graphics.sfCircleShape_getPointCount(@handle) |
#point_count=(n) ⇒ Object
Set the point count — see #point_count.
51 52 53 |
# File 'lib/sfml/graphics/circle_shape.rb', line 51 def point_count=(n) C::Graphics.sfCircleShape_setPointCount(@handle, Integer(n)) end |