Class: DYI::Shape::Circle
Overview
The circle in the vector image
Constant Summary
GraphicalElement::CLASS_REGEXP
Constants inherited
from Element
Element::ID_REGEXP
Instance Attribute Summary
Attributes inherited from Base
#anchor_href, #anchor_target, #attributes, #clipping, #parent
#css_class
Attributes inherited from Element
#description, #title
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#add_animation, #add_painting_animation, #add_transform_animation, #animate?, #animations, #clear_clipping, #draw_on, #has_marker?, #has_uri_reference?, #root_element?, #root_node?, #rotate, #scale, #set_clipping, #set_clipping_shapes, #set_event, #skew_x, #skew_y, #transform, #translate
#add_css_class, #add_event_listener, #css_classes, #event_listeners, #event_target?, #remove_css_class, #remove_event_listener, #set_event, #to_reused_source
Methods inherited from Element
#canvas, #child_elements, #has_uri_reference?, #id, #id=, #include_external_file?, #inner_id
Constructor Details
#initialize(center, radius, options = {}) ⇒ Circle
Returns a new instance of Circle.
520
521
522
523
524
|
# File 'lib/dyi/shape/base.rb', line 520
def initialize(center, radius, options={})
@center = Coordinate.new(center)
@radius = Length.new(radius).abs
@attributes = init_attributes(options)
end
|
Class Method Details
.create_on_center_radius(center, radius, options = {}) ⇒ Object
558
559
560
|
# File 'lib/dyi/shape/base.rb', line 558
def create_on_center_radius(center, radius, options={})
new(center, radius, options)
end
|
Instance Method Details
#bottom ⇒ Object
538
539
540
|
# File 'lib/dyi/shape/base.rb', line 538
def bottom
@center.y + @radius
end
|
#height ⇒ Object
546
547
548
|
# File 'lib/dyi/shape/base.rb', line 546
def height
@radius * 2
end
|
#left ⇒ Object
526
527
528
|
# File 'lib/dyi/shape/base.rb', line 526
def left
@center.x - @radius
end
|
#right ⇒ Object
530
531
532
|
# File 'lib/dyi/shape/base.rb', line 530
def right
@center.x + @radius
end
|
#top ⇒ Object
534
535
536
|
# File 'lib/dyi/shape/base.rb', line 534
def top
@center.y - @radius
end
|
#width ⇒ Object
542
543
544
|
# File 'lib/dyi/shape/base.rb', line 542
def width
@radius * 2
end
|
#write_as(formatter, io = $>) ⇒ Object
550
551
552
|
# File 'lib/dyi/shape/base.rb', line 550
def write_as(formatter, io=$>)
formatter.write_circle(self, io, &(block_given? ? Proc.new : nil))
end
|