Class: Geom::Bounds2d

Inherits:
Object
• Object
show all

Overview

The bounds2d class represents an axis aligned bounding box represented by two Point2d objects, upper left and lower right positions. The units utilized in the creation and modification Bounds2d are inches.

Version:

• LayOut 2018

Constructor Details

↑#initialize(other_bounds) ⇒ Geom::Bounds2d #initialize(upper_left, lower_right) ⇒ Geom::Bounds2d #initialize(x, y, width, height) ⇒ Geom::Bounds2d #initialize(point_array) ⇒ Geom::Bounds2d #initialize(float_array) ⇒ Geom::Bounds2d

The #initialize method creates a new Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new(0.0, 0.0, 1.0, 1.0)

• #initialize(other_bounds) ⇒ Geom::Bounds2d

Parameters:

• other_bounds
• #initialize(upper_left, lower_right) ⇒ Geom::Bounds2d

Parameters:

• upper_left
• lower_right
• #initialize(x, y, width, height) ⇒ Geom::Bounds2d

Parameters:

• x (Float)
• y (Float)
• width (Float)
• height (Float)
• #initialize(point_array) ⇒ Geom::Bounds2d

Parameters:

• point_array

An array of two Point2ds

• #initialize(float_array) ⇒ Geom::Bounds2d

Parameters:

• float_array (Array(Float, Float, Float, Float))

An array of four floats (x, y, width, height)

Version:

• LayOut 2018

Instance Method Details

↑ #==(other) ⇒ Boolean

The #== method checks to see if the two Geom::Bounds2ds are equal. This checks whether the point values are the same

Examples:

entity.bounds == entity.untransformed_bounds

Parameters:

• other

Returns:

• (Boolean)

Version:

• LayOut 2018

↑ #height ⇒ Geom::Point2d

The #height method returns the height of the Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new({0.0, 0.0, 1.0, 1.0})
height = bounds.height

Returns:

Version:

• LayOut 2018

↑ #lower_right ⇒ Geom::Point2d

The #lower_right method returns the Point2d of the lower right corner of the Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new({0.0, 0.0, 1.0, 1.0})
l_r = bounds.lower_right

Returns:

Version:

• LayOut 2018

↑#set!(other_bounds) ⇒ Geom::Bounds2d #set!(upper_left, lower_right) ⇒ Geom::Bounds2d #set!(x, y, width, height) ⇒ Geom::Bounds2d #set!(point_array) ⇒ Geom::Bounds2d #set!(float_array) ⇒ Geom::Bounds2d

The #set! method sets the Geom::Bounds2d to match another one. The argument is anything that can be converted into a Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new(3.0, 3.0, 5.0, 5.0)
bounds.set!(Geom::Point2d.new(0.0, 0.0), Geom::Point2d.new(2.0, 2.0))

• #set!(other_bounds) ⇒ Geom::Bounds2d

Parameters:

• other_bounds

Returns:

• #set!(upper_left, lower_right) ⇒ Geom::Bounds2d

Parameters:

• upper_left
• lower_right

Returns:

• #set!(x, y, width, height) ⇒ Geom::Bounds2d

Parameters:

• x (Float)
• y (Float)
• width (Float)
• height (Float)

Returns:

• #set!(point_array) ⇒ Geom::Bounds2d

Parameters:

• point_array

An array of two Point2ds

Returns:

• #set!(float_array) ⇒ Geom::Bounds2d

Parameters:

• float_array (Array(Float, Float, Float, Float))

An array of four floats (x, y, width, height)

Returns:

Version:

• LayOut 2018

↑ #to_a ⇒ Array(Geom::Point2d, Geom::Point2d)

The #to_a method returns an array which contains the Point2d that define the Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new
bounds.to_a.each { |point| p point.to_s }

Returns:

Version:

• LayOut 2018

↑ #upper_left ⇒ Geom::Point2d

The #upper_left method returns the Point2d of the upper left corner of the Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new({0.0, 0.0, 1.0, 1.0})
u_l = bounds.upper_left

Returns:

Version:

• LayOut 2018

↑ #width ⇒ Geom::Point2d

The #width method returns the width of the Geom::Bounds2d.

Examples:

bounds = Geom::Bounds2d.new({0.0, 0.0, 1.0, 1.0})
width = bounds.width

Returns:

Version:

• LayOut 2018