Class: Gosling::Circle
Overview
Represents an Actor with a circular shape, defined by a mutable radius. The circle is rendered relative to the Circle’s center (see Transformable#center).
Constant Summary collapse
- RENDER_VERTEX_COUNT =
How many vertices to use when rendering circles. More vertices means more accurate rendering at the cost of performance.
16
Instance Attribute Summary collapse
-
#radius ⇒ Object
Returns the value of attribute radius.
Attributes inherited from Actor
#are_children_tangible, #are_children_visible, #children, #color, #is_mask, #is_tangible, #is_visible, #parent, #window
Attributes included from Transformable
Instance Method Summary collapse
-
#get_point_at_angle(radians, out = nil) ⇒ Object
Returns the angle’s corresponding unit vector times this circle’s radius.
-
#initialize(window) ⇒ Circle
constructor
Creates a new Circle with initial radius of zero.
-
#is_point_in_bounds(point) ⇒ Object
Returns true if the point is inside the Circle, false otherwise.
Methods inherited from Actor
#add_child, #alpha, #alpha=, #blue, #blue=, #draw, #get_actor_at, #get_actors_at, #get_global_position, #get_global_transform, #green, #green=, #has_child?, #inspect, #red, #red=, #remove_child
Methods included from Transformable
#center, #center=, #center_x, #center_x=, #center_y, #center_y=, #reset, #scale, #scale=, #scale_x, #scale_x=, #scale_y, #scale_y=, #to_matrix, transform_point, #transform_point, #translation, #translation=, untransform_point, #untransform_point, #x, #x=, #y, #y=
Constructor Details
#initialize(window) ⇒ Circle
Creates a new Circle with initial radius of zero.
21 22 23 24 |
# File 'lib/gosling/circle.rb', line 21 def initialize(window) super(window) @radius = 0 end |
Instance Attribute Details
#radius ⇒ Object
Returns the value of attribute radius.
16 17 18 |
# File 'lib/gosling/circle.rb', line 16 def radius @radius end |
Instance Method Details
#get_point_at_angle(radians, out = nil) ⇒ Object
Returns the angle’s corresponding unit vector times this circle’s radius.
37 38 39 40 41 |
# File 'lib/gosling/circle.rb', line 37 def get_point_at_angle(radians, out = nil) raise ArgumentError.new("Expected Numeric, but received #{radians.inspect}!") unless radians.is_a?(Numeric) out ||= Snow::Vec3.new out.set(Math.cos(radians) * @radius, Math.sin(radians) * @radius, 0) end |
#is_point_in_bounds(point) ⇒ Object
Returns true if the point is inside the Circle, false otherwise.
46 47 48 |
# File 'lib/gosling/circle.rb', line 46 def is_point_in_bounds(point) Collision.is_point_in_shape?(point, self) end |