Class: DYI::Shape::ReusedShape
- Inherits:
-
Base
- Object
- Element
- GraphicalElement
- Base
- DYI::Shape::ReusedShape
- Defined in:
- lib/dyi/shape/reused_shape.rb
Overview
Marker object represents a symbol at One or more vertices of the lines.
Marker provides some pre-defined shapes and a custom marker defined freely.
Constant Summary
Constants inherited from GraphicalElement
GraphicalElement::CLASS_REGEXP
Constants inherited from Element
Instance Attribute Summary collapse
- #source_element ⇒ Object readonly
Attributes inherited from Base
#anchor_href, #anchor_target, #attributes, #clipping, #parent
Attributes inherited from GraphicalElement
Attributes inherited from Element
Instance Method Summary collapse
-
#bottom ⇒ Length
Returns a y-axis coordinate of the bottom of the re-used shape.
-
#center ⇒ Coordinate
Returns a coordinate of the center of the re-used shape.
- #child_elements ⇒ Object
-
#has_uri_reference? ⇒ Boolean
Whether the element has a URI reference.
-
#initialize(source_element, left_top, options = {}) ⇒ ReusedShape
constructor
A new instance of ReusedShape.
-
#left ⇒ Length
Returns a x-axis coordinate of the left side of the re-used shape.
-
#right ⇒ Length
Returns a x-axis coordinate of the right side of the re-used shape.
-
#top ⇒ Length
Returns a y-axis coordinate of the top of the re-used shape.
-
#write_as(formatter, io = $>) ⇒ Object
Writes image on io object.
Methods inherited from Base
#add_animation, #add_painting_animation, #add_transform_animation, #animate?, #animations, #clear_clipping, #draw_on, #has_marker?, #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, #id, #id=, #include_external_file?, #inner_id
Constructor Details
#initialize(source_element, left_top, options = {}) ⇒ ReusedShape
Returns a new instance of ReusedShape.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dyi/shape/reused_shape.rb', line 39 def initialize(source_element, left_top, ={}) @source_element = source_element.to_reused_source width = Length.new_or_nil(.delete(:width)) height = Length.new_or_nil(.delete(:height)) @lt_pt = Coordinate.new(left_top) @lt_pt += Coordinate.new(width, 0) if width && width < Length::ZERO @lt_pt += Coordinate.new(0, height) if height && height < Length::ZERO @width = width && width.abs @height = height && height.abs @attributes = init_attributes() source_element.publish_id end |
Instance Attribute Details
#source_element ⇒ Object (readonly)
31 32 33 |
# File 'lib/dyi/shape/reused_shape.rb', line 31 def source_element @source_element end |
Instance Method Details
#bottom ⇒ Length
Returns a y-axis coordinate of the bottom of the re-used shape.
72 73 74 |
# File 'lib/dyi/shape/reused_shape.rb', line 72 def bottom height && (@lt_pt.y + height) end |
#center ⇒ Coordinate
Returns a coordinate of the center of the re-used shape.
78 79 80 |
# File 'lib/dyi/shape/reused_shape.rb', line 78 def center width && height && (@lt_pt + Coordinate.new(width.quo(2), height.quo(2))) end |
#child_elements ⇒ Object
82 83 84 |
# File 'lib/dyi/shape/reused_shape.rb', line 82 def child_elements source_element.child_elements end |
#has_uri_reference? ⇒ Boolean
Returns whether the element has a URI reference.
87 88 89 |
# File 'lib/dyi/shape/reused_shape.rb', line 87 def has_uri_reference? true end |
#left ⇒ Length
Returns a x-axis coordinate of the left side of the re-used shape.
54 55 56 |
# File 'lib/dyi/shape/reused_shape.rb', line 54 def left @lt_pt.x end |
#right ⇒ Length
Returns a x-axis coordinate of the right side of the re-used shape.
60 61 62 |
# File 'lib/dyi/shape/reused_shape.rb', line 60 def right width && (@lt_pt.x + width) end |
#top ⇒ Length
Returns a y-axis coordinate of the top of the re-used shape.
66 67 68 |
# File 'lib/dyi/shape/reused_shape.rb', line 66 def top @lt_pt.y end |
#write_as(formatter, io = $>) ⇒ Object
Writes image on io object.
94 95 96 |
# File 'lib/dyi/shape/reused_shape.rb', line 94 def write_as(formatter, io=$>) formatter.write_reused_shape(self, io) end |