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
#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.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/sfml/graphics/circle_shape.rb', line 15
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.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
65
66
67
|
# File 'lib/sfml/graphics/circle_shape.rb', line 65
def handle
@handle
end
|
Instance Method Details
#draw_on(target, states_ptr = nil) ⇒ Object
61
62
63
|
# File 'lib/sfml/graphics/circle_shape.rb', line 61
def draw_on(target, states_ptr = nil) target._draw_native(:CircleShape, @handle, states_ptr)
end
|
#fill_color ⇒ Object
43
|
# File 'lib/sfml/graphics/circle_shape.rb', line 43
def fill_color = Color.from_native(C::Graphics.sfCircleShape_getFillColor(@handle))
|
#fill_color=(c) ⇒ Object
45
46
47
|
# File 'lib/sfml/graphics/circle_shape.rb', line 45
def fill_color=(c)
C::Graphics.sfCircleShape_setFillColor(@handle, c.to_native)
end
|
#outline_color ⇒ Object
49
|
# File 'lib/sfml/graphics/circle_shape.rb', line 49
def outline_color = Color.from_native(C::Graphics.sfCircleShape_getOutlineColor(@handle))
|
#outline_color=(c) ⇒ Object
51
52
53
|
# File 'lib/sfml/graphics/circle_shape.rb', line 51
def outline_color=(c)
C::Graphics.sfCircleShape_setOutlineColor(@handle, c.to_native)
end
|
#outline_thickness ⇒ Object
55
|
# File 'lib/sfml/graphics/circle_shape.rb', line 55
def outline_thickness = C::Graphics.sfCircleShape_getOutlineThickness(@handle)
|
#outline_thickness=(t) ⇒ Object
57
58
59
|
# File 'lib/sfml/graphics/circle_shape.rb', line 57
def outline_thickness=(t)
C::Graphics.sfCircleShape_setOutlineThickness(@handle, t.to_f)
end
|
#point_count ⇒ Object
37
|
# File 'lib/sfml/graphics/circle_shape.rb', line 37
def point_count = C::Graphics.sfCircleShape_getPointCount(@handle)
|
#point_count=(n) ⇒ Object
39
40
41
|
# File 'lib/sfml/graphics/circle_shape.rb', line 39
def point_count=(n)
C::Graphics.sfCircleShape_setPointCount(@handle, Integer(n))
end
|
#radius ⇒ Object
31
|
# File 'lib/sfml/graphics/circle_shape.rb', line 31
def radius = C::Graphics.sfCircleShape_getRadius(@handle)
|
#radius=(value) ⇒ Object
33
34
35
|
# File 'lib/sfml/graphics/circle_shape.rb', line 33
def radius=(value)
C::Graphics.sfCircleShape_setRadius(@handle, value.to_f)
end
|