Class: Geometry::SizedObround
- Defined in:
- lib/geometry/obround.rb
Accessors collapse
- #center ⇒ Object readonly
Instance Attribute Summary collapse
-
#origin ⇒ Point
The Obround‘s 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) ⇒ SizedObround
constructor
A new instance of SizedObround.
Methods inherited from Obround
Methods included from ClusterFactory
Constructor Details
#new(width, height) ⇒ Object #new(size) ⇒ Object #new(origin, size) ⇒ Object
Returns a new instance of SizedObround.
198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/geometry/obround.rb', line 198 def initialize(*args) if args[0].is_a?(Size) @origin = Point[0,0] @size = args[0] elsif (args[0].is_a?(Point) or args[0].is_a?(Array)) and args[1].is_a?(Geometry::Size) @origin, @size = Point[args[0]], args[1] elsif (2 == args.size) and args.all? {|a| a.is_a?(Numeric)} @origin = Point[0,0] @size = Geometry::Size[*args] end end |
Instance Attribute Details
#center ⇒ Object (readonly)
178 179 180 |
# File 'lib/geometry/obround.rb', line 178 def center @center end |
#origin ⇒ Point
Returns The Obround‘s origin.
180 181 182 |
# File 'lib/geometry/obround.rb', line 180 def origin @origin end |
#size ⇒ Size
Returns The Geometry::Size of the Obround.
182 183 184 |
# File 'lib/geometry/obround.rb', line 182 def size @size end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
210 211 212 |
# File 'lib/geometry/obround.rb', line 210 def eql?(other) (self.origin == other.origin) && (self.size == other.size) end |
#height ⇒ Object
229 230 231 |
# File 'lib/geometry/obround.rb', line 229 def height @size.height end |
#points ⇒ Array<Point>
Returns The Obround‘s four points (clockwise).
221 222 223 224 225 226 227 |
# File 'lib/geometry/obround.rb', line 221 def points point0 = @origin point2 = @origin + @size point1 = Point[point0.x,point2.y] point3 = Point[point2.x, point0.y] [point0, point1, point2, point3] end |
#width ⇒ Object
233 234 235 |
# File 'lib/geometry/obround.rb', line 233 def width @size.width end |