Class: Geometry::CenteredObround
- Defined in:
- lib/geometry/obround.rb
Instance Attribute Summary collapse
-
#center ⇒ Point
The Obround‘s center.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
- #size ⇒ Size
Accessors collapse
- #height ⇒ Object
-
#points ⇒ Array<Point>
The Obround‘s four points (clockwise).
- #width ⇒ Object
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(*args) ⇒ CenteredObround
constructor
A new instance of CenteredObround.
Methods inherited from Obround
Methods included from ClusterFactory
Constructor Details
#new(width, height) ⇒ CenteredObround #new(size) ⇒ CenteredObround #new(center, size) ⇒ CenteredObround
Returns a new instance of CenteredObround.
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/geometry/obround.rb', line 139 def initialize(*args) if args[0].is_a?(Size) @center = Point[0,0] @size = args[0] elsif args[0].is_a?(Geometry::Point) and args[1].is_a?(Geometry::Size) @center, @size = args[0,1] elsif (2 == args.size) and args.all? {|a| a.is_a?(Numeric)} @center = Point[0,0] @size = Geometry::Size[*args] end end |
Instance Attribute Details
#center ⇒ Point
Returns The Obround‘s center.
121 122 123 |
# File 'lib/geometry/obround.rb', line 121 def center @center end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
122 123 124 |
# File 'lib/geometry/obround.rb', line 122 def origin @origin end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
151 152 153 |
# File 'lib/geometry/obround.rb', line 151 def eql?(other) (self.center == other.center) && (self.size == other.size) end |
#height ⇒ Object
166 167 168 |
# File 'lib/geometry/obround.rb', line 166 def height @size.height end |
#points ⇒ Array<Point>
Returns The Obround‘s four points (clockwise).
158 159 160 161 162 163 164 |
# File 'lib/geometry/obround.rb', line 158 def points point0 = @center - @size/2.0 point2 = @center + @size/2.0 point1 = Point[point0.x,point2.y] point3 = Point[point2.x, point0.y] [point0, point1, point2, point3] end |
#width ⇒ Object
170 171 172 |
# File 'lib/geometry/obround.rb', line 170 def width @size.width end |