Method: Geometry::Obround.new

Defined in:
lib/geometry/obround.rb

.new(width, height) ⇒ CenteredObround .new(size) ⇒ CenteredObround .new(point0, point1) ⇒ Object .new(origin, size) ⇒ SizedObround .new(left, bottom, right, top) ⇒ Obround

Overloads:

  • .new(width, height) ⇒ CenteredObround

    Creates a Geometry::Obround of the given width and height, centered on the origin

    Parameters:

    • height (Number)

      Height

    • width (Number)

      Width

    Returns:

  • .new(size) ⇒ CenteredObround

    Creates a Geometry::Obround of the given Size centered on the origin

    Parameters:

    • size (Size)

      Width and height

    Returns:

  • .new(point0, point1) ⇒ Object

    Creates a Geometry::Obround using the given Points

    Parameters:

    • point0 (Point)

      A corner

    • point1 (Point)

      The other corner

  • .new(origin, size) ⇒ SizedObround

    Creates a Geometry::Obround from the given origin and size

    Parameters:

    • origin (Point)

      Lower-left corner

    • size (Size)

      Width and height

    Returns:

  • .new(left, bottom, right, top) ⇒ Obround

    Creates a Geometry::Obround from the locations of each side

    Parameters:

    • left (Number)

      X-coordinate of the left side

    • bottom (Number)

      Y-coordinate of the bottom edge

    • right (Number)

      X-coordinate of the right side

    • top (Number)

      Y-coordinate of the top edge

    Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/geometry/obround.rb', line 40

def self.new(*args)
    case args.size
	when 1
	    CenteredObround.new(args[0])
	when 2
	    if args.all? {|a| a.is_a?(Numeric) }
		CenteredObround.new(Size[*args])
	    elsif args.all? {|a| a.is_a?(Array) || a.is_a?(Point) }
		original_new(*args)
	    elsif (args[0].is_a?(Point) or args[0].is_a?(Array))and args[1].is_a?(Size)
		SizedObround.new(*args)
	    else
		raise ArgumentError, "Invalid arguments #{args}"
	    end
	when 4
	    raise ArgumentError unless args.all? {|a| a.is_a?(Numeric)}
	    left, bottom, right, top = *args
	    original_new(Point[left, bottom], Point[right, top])
    end
end