Class: DYI::Shape::Ellipse

Inherits:
Base show all
Defined in:
lib/dyi/shape/base.rb

Overview

Since:

  • 0.0.0

Constant Summary

Constants inherited from GraphicalElement

GraphicalElement::CLASS_REGEXP

Constants inherited from Element

Element::ID_REGEXP

Instance Attribute Summary

Attributes inherited from Base

#anchor_href, #anchor_target, #attributes, #clipping, #parent

Attributes inherited from GraphicalElement

#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

Methods inherited from GraphicalElement

#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_x, radius_y, options = {}) ⇒ Ellipse

Returns a new instance of Ellipse.

Parameters:

  • center (Coordinate)

    a center coordinate of the ellipse

  • radius_x (Length)

    an x-axis radius of the ellipse

  • radius_y (Length)

    a y-axis radius of the ellipse

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :painting (Painting)

    painting status of this shape

  • :description (String)

    the description of this shape

  • :title (String)

    the title of this shape

Since:

  • 0.0.0



574
575
576
577
578
579
# File 'lib/dyi/shape/base.rb', line 574

def initialize(center, radius_x, radius_y, options={})
  @center = Coordinate.new(center)
  @radius_x = Length.new(radius_x).abs
  @radius_y = Length.new(radius_y).abs
  @attributes = init_attributes(options)
end

Class Method Details

.create_on_center_radius(center, radius_x, radius_y, options = {}) ⇒ Object

Since:

  • 0.0.0



613
614
615
# File 'lib/dyi/shape/base.rb', line 613

def create_on_center_radius(center, radius_x, radius_y, options={})
  new(center, radius_x, radius_y, options)
end

Instance Method Details

#bottomObject

Since:

  • 0.0.0



593
594
595
# File 'lib/dyi/shape/base.rb', line 593

def bottom
  @center.y + @radius_y
end

#heightObject

Since:

  • 0.0.0



601
602
603
# File 'lib/dyi/shape/base.rb', line 601

def height
  @radius_y * 2
end

#leftObject

Since:

  • 0.0.0



581
582
583
# File 'lib/dyi/shape/base.rb', line 581

def left
  @center.x - @radius_x
end

#rightObject

Since:

  • 0.0.0



585
586
587
# File 'lib/dyi/shape/base.rb', line 585

def right
  @center.x + @radius_x
end

#topObject

Since:

  • 0.0.0



589
590
591
# File 'lib/dyi/shape/base.rb', line 589

def top
  @center.y - @radius_y
end

#widthObject

Since:

  • 0.0.0



597
598
599
# File 'lib/dyi/shape/base.rb', line 597

def width
  @radius_x * 2
end

#write_as(formatter, io = $>) ⇒ Object

Since:

  • 0.0.0



605
606
607
# File 'lib/dyi/shape/base.rb', line 605

def write_as(formatter, io=$>)
  formatter.write_ellipse(self, io, &(block_given? ? Proc.new : nil))
end