Box

Box

Class Box represents bounding box of the shape. It may also represent axis-aligned rectangle

Constructor

new Box(xmin, ymin, xmax, ymax)

Source:
Parameters:
Name Type Description
xmin number minimal x coordinate
ymin number minimal y coordinate
xmax number maximal x coordinate
ymax number maximal y coordinate

Classes

Box

Members

box

Return property box like all other shapes
Source:

center

Return center of the box
Source:

height

Return the height of the box
Source:

high

Property high need for interval tree interface
Source:

low

Property low need for interval tree interface
Source:

max

Property max returns the box itself !
Source:

width

Return the width of the box
Source:

xmax :number

Maximal x coordinate
Source:
Type:
  • number

xmin :number

Minimal x coordinate
Source:
Type:
  • number

ymax :number

Maximal y coordinate
Source:
Type:
  • number

ymin :number

Minimal y coordinate
Source:
Type:
  • number

Methods

clone() → {Box}

Return new cloned instance of box
Source:
Returns:
Type:
Box

contains(shape) → {boolean}

Return true if box contains shape: no point of shape lies outside the box
Source:
Parameters:
Name Type Description
shape AnyShape test shape
Returns:
Type:
boolean

equal_to(other_box) → {boolean}

Returns true if this box is equal to other box, false otherwise
Source:
Parameters:
Name Type Description
other_box Box query box
Returns:
Type:
boolean

intersect(other_box) → {boolean}

Returns true if intersected with other box
Source:
Parameters:
Name Type Description
other_box Box Query box
Returns:
Type:
boolean

less_than(other_box) → {boolean}

Defines predicate "less than" between two boxes. Need for interval index
Source:
Parameters:
Name Type Description
other_box Box other box
Returns:
Type:
boolean
- true if this box less than other box, false otherwise

merge(other_box) → {Box}

Returns new box merged with other box
Source:
Parameters:
Name Type Description
other_box Box Other box to merge with
Returns:
Type:
Box

not_intersect(other_box) → {boolean}

Returns true if not intersected with other box
Source:
Parameters:
Name Type Description
other_box Box other box to test
Returns:
Type:
boolean

rotate(angle, centeropt)

Box rotation is not supported Attempt to rotate box throws error
Source:
Parameters:
Name Type Attributes Default Description
angle number angle in radians
center Point <optional>
(0,0) center

set(xmin, ymin, xmax, ymax)

Set new values to the box object
Source:
Parameters:
Name Type Description
xmin number mininal x coordinate
ymin number minimal y coordinate
xmax number maximal x coordinate
ymax number maximal y coordinate

svg(attrs) → {string}

Return string to draw box in svg
Source:
Parameters:
Name Type Description
attrs Object an object with attributes of svg rectangle element
Returns:
Type:
string

toPoints() → {Array.<Point>}

Transform box into array of points from low left corner in counterclockwise
Source:
Returns:
Type:
Array.<Point>

toSegments() → {Array.<Segment>}

Transform box into array of segments from low left corner in counterclockwise
Source:
Returns:
Type:
Array.<Segment>

transform(m) → {Box}

Return new box transformed using affine transformation matrix New box is a bounding box of transformed corner points
Source:
Parameters:
Name Type Description
m Matrix affine transformation matrix
Returns:
Type:
Box