Class: DYI::Shape::Line
- Inherits:
-
Base
- Object
- Element
- GraphicalElement
- Base
- DYI::Shape::Line
- Includes:
- Markable
- Defined in:
- lib/dyi/shape/base.rb
Overview
Constant Summary
Constants inherited from GraphicalElement
GraphicalElement::CLASS_REGEXP
Constants inherited from Element
Instance Attribute Summary
Attributes inherited from Base
#anchor_href, #anchor_target, #attributes, #clipping, #parent
Attributes inherited from GraphicalElement
Attributes inherited from Element
Class Method Summary collapse
- .create_on_direction(start_point, direction_x, direction_y, options = {}) ⇒ Object
- .create_on_start_end(start_point, end_point, options = {}) ⇒ Object
Instance Method Summary collapse
- #bottom ⇒ Object
-
#initialize(start_point, end_point, options = {}) ⇒ Line
constructor
A new instance of Line.
- #left ⇒ Object
- #right ⇒ Object
- #top ⇒ Object
- #write_as(formatter, io = $>) ⇒ Object
Methods included from Markable
#has_marker?, #marker, #set_marker
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(start_point, end_point, options = {}) ⇒ Line
Returns a new instance of Line.
628 629 630 631 632 633 |
# File 'lib/dyi/shape/base.rb', line 628 def initialize(start_point, end_point, ={}) @start_point = Coordinate.new(start_point) @end_point = Coordinate.new(end_point) @attributes = init_attributes() @marker = {} end |
Class Method Details
.create_on_direction(start_point, direction_x, direction_y, options = {}) ⇒ Object
663 664 665 666 667 |
# File 'lib/dyi/shape/base.rb', line 663 def create_on_direction(start_point, direction_x, direction_y, ={}) start_point = Coordinate.new(start_point) end_point = start_point + Coordinate.new(direction_x, direction_y) new(start_point, end_point, ) end |
.create_on_start_end(start_point, end_point, options = {}) ⇒ Object
659 660 661 |
# File 'lib/dyi/shape/base.rb', line 659 def create_on_start_end(start_point, end_point, ={}) new(start_point, end_point, ) end |
Instance Method Details
#bottom ⇒ Object
647 648 649 |
# File 'lib/dyi/shape/base.rb', line 647 def bottom [@start_point.y, @end_point.y].max end |
#left ⇒ Object
635 636 637 |
# File 'lib/dyi/shape/base.rb', line 635 def left [@start_point.x, @end_point.x].min end |
#right ⇒ Object
639 640 641 |
# File 'lib/dyi/shape/base.rb', line 639 def right [@start_point.x, @end_point.x].max end |
#top ⇒ Object
643 644 645 |
# File 'lib/dyi/shape/base.rb', line 643 def top [@start_point.y, @end_point.y].min end |
#write_as(formatter, io = $>) ⇒ Object
651 652 653 |
# File 'lib/dyi/shape/base.rb', line 651 def write_as(formatter, io=$>) formatter.write_line(self, io, &(block_given? ? Proc.new : nil)) end |