Class: DYI::Shape::Polyline
Overview
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
Instance Method Summary
collapse
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
#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, options = {}) ⇒ Polyline
Returns a new instance of Polyline.
678
679
680
681
682
|
# File 'lib/dyi/shape/base.rb', line 678
def initialize(start_point, options={})
@points = [Coordinate.new(start_point)]
@attributes = init_attributes(options)
@marker = {}
end
|
Instance Method Details
#bottom ⇒ Object
722
723
724
|
# File 'lib/dyi/shape/base.rb', line 722
def bottom
@points.max {|a, b| a.y <=> b.y}.y
end
|
#current_point ⇒ Object
694
695
696
|
# File 'lib/dyi/shape/base.rb', line 694
def current_point
@points.last
end
|
#left ⇒ Object
710
711
712
|
# File 'lib/dyi/shape/base.rb', line 710
def left
@points.min {|a, b| a.x <=> b.x}.x
end
|
#line_to(*points) ⇒ Object
684
685
686
|
# File 'lib/dyi/shape/base.rb', line 684
def line_to(*points)
@points.push(*points.map{|pt| Coordinate.new(pt)})
end
|
#points ⇒ Object
702
703
704
|
# File 'lib/dyi/shape/base.rb', line 702
def points
@points.clone
end
|
#right ⇒ Object
714
715
716
|
# File 'lib/dyi/shape/base.rb', line 714
def right
@points.max {|a, b| a.x <=> b.x}.x
end
|
#rline_to(*points) ⇒ Object
689
690
691
692
|
# File 'lib/dyi/shape/base.rb', line 689
def rline_to(*points)
current = current_point
@points.push(*points.inject([]){|result, pt| result << (current += pt)})
end
|
#start_point ⇒ Object
698
699
700
|
# File 'lib/dyi/shape/base.rb', line 698
def start_point
@points.first
end
|
#top ⇒ Object
718
719
720
|
# File 'lib/dyi/shape/base.rb', line 718
def top
@points.min {|a, b| a.y <=> b.y}.y
end
|
#undo ⇒ Object
706
707
708
|
# File 'lib/dyi/shape/base.rb', line 706
def undo
@points.pop if @points.size > 1
end
|
#write_as(formatter, io = $>) ⇒ Object
726
727
728
|
# File 'lib/dyi/shape/base.rb', line 726
def write_as(formatter, io=$>)
formatter.write_polyline(self, io, &(block_given? ? Proc.new : nil))
end
|