Class: SFML::CircleShape
Overview
A filled circle (or regular polygon if you set point_count). Cheapest drawable that requires no asset file — perfect for placeholders.
ball = SFML::CircleShape.new(
radius: 20,
position: [400, 300],
fill_color: SFML::Color.red,
)
window.draw(ball)
Constant Summary
collapse
- CSFML_PREFIX =
:sfCircleShape
Instance Attribute Summary collapse
Instance Method Summary
collapse
#dup, #geometric_center, #global_bounds, #inverse_transform, #local_bounds, #point, #set_texture, #texture, #texture=, #texture_rect, #texture_rect=, #transform
#move, #origin, #origin=, #position, #position=, #rotate, #rotation, #rotation=, #scale, #scale=, #scale_by
Constructor Details
#initialize(radius: 10.0, **opts) ⇒ CircleShape
Returns a new instance of CircleShape.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/sfml/graphics/circle_shape.rb', line 16
def initialize(radius: 10.0, **opts)
ptr = C::Graphics.sfCircleShape_create
raise Error, "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
68
69
70
|
# File 'lib/sfml/graphics/circle_shape.rb', line 68
def handle
@handle
end
|
Instance Method Details
#draw_on(target, states_ptr = nil) ⇒ Object
64
65
66
|
# File 'lib/sfml/graphics/circle_shape.rb', line 64
def draw_on(target, states_ptr = nil) target._draw_native(:CircleShape, @handle, states_ptr)
end
|
#fill_color ⇒ Object
46
|
# File 'lib/sfml/graphics/circle_shape.rb', line 46
def fill_color = Color.from_native(C::Graphics.sfCircleShape_getFillColor(@handle))
|
#fill_color=(c) ⇒ Object
48
49
50
|
# File 'lib/sfml/graphics/circle_shape.rb', line 48
def fill_color=(c)
C::Graphics.sfCircleShape_setFillColor(@handle, c.to_native)
end
|
#outline_color ⇒ Object
52
|
# File 'lib/sfml/graphics/circle_shape.rb', line 52
def outline_color = Color.from_native(C::Graphics.sfCircleShape_getOutlineColor(@handle))
|
#outline_color=(c) ⇒ Object
54
55
56
|
# File 'lib/sfml/graphics/circle_shape.rb', line 54
def outline_color=(c)
C::Graphics.sfCircleShape_setOutlineColor(@handle, c.to_native)
end
|
#outline_thickness ⇒ Object
58
|
# File 'lib/sfml/graphics/circle_shape.rb', line 58
def outline_thickness = C::Graphics.sfCircleShape_getOutlineThickness(@handle)
|
#outline_thickness=(t) ⇒ Object
60
61
62
|
# File 'lib/sfml/graphics/circle_shape.rb', line 60
def outline_thickness=(t)
C::Graphics.sfCircleShape_setOutlineThickness(@handle, t.to_f)
end
|
#point_count ⇒ Object
40
|
# File 'lib/sfml/graphics/circle_shape.rb', line 40
def point_count = C::Graphics.sfCircleShape_getPointCount(@handle)
|
#point_count=(n) ⇒ Object
42
43
44
|
# File 'lib/sfml/graphics/circle_shape.rb', line 42
def point_count=(n)
C::Graphics.sfCircleShape_setPointCount(@handle, Integer(n))
end
|
#radius ⇒ Object
34
|
# File 'lib/sfml/graphics/circle_shape.rb', line 34
def radius = C::Graphics.sfCircleShape_getRadius(@handle)
|
#radius=(value) ⇒ Object
36
37
38
|
# File 'lib/sfml/graphics/circle_shape.rb', line 36
def radius=(value)
C::Graphics.sfCircleShape_setRadius(@handle, value.to_f)
end
|