Class: Archimate::Svg::Segment
- Inherits:
-
Struct
- Object
- Struct
- Archimate::Svg::Segment
- Defined in:
- lib/archimate/svg/segment.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
Instance Method Summary collapse
- #from_end(dist) ⇒ Object
- #from_start(dist) ⇒ Object
- #length ⇒ Object
- #point_at_percent(pct) ⇒ Object
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a
5 6 7 |
# File 'lib/archimate/svg/segment.rb', line 5 def a @a end |
#b ⇒ Object
Returns the value of attribute b
5 6 7 |
# File 'lib/archimate/svg/segment.rb', line 5 def b @b end |
Instance Method Details
#from_end(dist) ⇒ Object
10 11 12 13 |
# File 'lib/archimate/svg/segment.rb', line 10 def from_end(dist) length = b - a from_start(length - dist) end |
#from_start(dist) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/archimate/svg/segment.rb', line 15 def from_start(dist) length = b - a return a if dist.negative? return b if length < dist point_at_percent(dist / length) end |
#length ⇒ Object
6 7 8 |
# File 'lib/archimate/svg/segment.rb', line 6 def length b - a end |
#point_at_percent(pct) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/archimate/svg/segment.rb', line 22 def point_at_percent(pct) Point.new( a.x + ((b.x - a.x) * pct), a.y + ((b.y - a.y) * pct) ) end |