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
Attributes inherited from Obround
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.
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/geometry/obround.rb', line 145 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.
127 128 129 |
# File 'lib/geometry/obround.rb', line 127 def center @center end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
128 129 130 |
# File 'lib/geometry/obround.rb', line 128 def origin @origin end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
157 158 159 |
# File 'lib/geometry/obround.rb', line 157 def eql?(other) (self.center == other.center) && (self.size == other.size) end |
#height ⇒ Object
172 173 174 |
# File 'lib/geometry/obround.rb', line 172 def height @size.height end |
#points ⇒ Array<Point>
Returns The Obround‘s four points (clockwise).
164 165 166 167 168 169 170 |
# File 'lib/geometry/obround.rb', line 164 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
176 177 178 |
# File 'lib/geometry/obround.rb', line 176 def width @size.width end |