CPRect

final case class CPRect(x: Int, y: Int, width: Int, height: Int) extends CPInt4

Rectangular shape.

This class is used to define any arbitrary rectangular shape. Note that this class only describes the rectangular shape but does not hold any content.

Value parameters:
height

Height of the rectangular.

width

Width of the rectangular.

x

X-coordinate of the left top corner.

y

Y-coordinate of the left top corner.

See also:

CPArray2D 2D content holder.

Companion:
object
Source:
CPRect.scala
trait Product
trait Equals
class CPInt4
trait Ordered[CPInt4]
trait Comparable[CPInt4]
trait Serializable
class Object
trait Matchable
class Any

Value members

Constructors

def this(p1: CPInt2, p2: CPInt2)

Creates rectangle from two tuples.

Creates rectangle from two tuples.

Value parameters:
p1

XY-coordinate of the top left corner.

p2

XY-coordinate of the bottom right corner.

Source:
CPRect.scala
def this(p1: (Int, Int), p2: (Int, Int))

Creates rectangle from two tuples.

Creates rectangle from two tuples.

Value parameters:
p1

XY-coordinate of the top left corner.

p2

XY-coordinate of the bottom right corner.

Source:
CPRect.scala
def this(x: Int, y: Int, dim: CPDim)

Creates rectangle.

Creates rectangle.

Value parameters:
dim

Dimension of the rectangle.

x

X-coordinate of the top left corner.

y

Y-coordinate of the top left corner.

Source:
CPRect.scala
def this(dim: CPDim)

Creates rectangle with (0,0) left top corner and given dimension.

Creates rectangle with (0,0) left top corner and given dimension.

Value parameters:
dim

Rectangle dimension.

Source:
CPRect.scala

Concrete methods

inline def contains(a: Int, b: Int): Boolean

Whether or not given point is contained within this rectangle. This includes a point on the edge of the rectangle.

Whether or not given point is contained within this rectangle. This includes a point on the edge of the rectangle.

Value parameters:
a

X coordinate.

b

Y coordinate.

Source:
CPRect.scala
inline def contains(rect: CPRect): Boolean

Tests whether this rectangle contains given rectangle.

Tests whether this rectangle contains given rectangle.

Value parameters:
rect

Rectangle to test.

Source:
CPRect.scala
inline def containsHor(rect: CPRect): Boolean

Tests whether this rectangle contains given rectangle horizontally.

Tests whether this rectangle contains given rectangle horizontally.

Value parameters:
rect

Rectangle to test.

Source:
CPRect.scala
inline def containsVer(rect: CPRect): Boolean

Tests whether this rectangle contains given rectangle vertically.

Tests whether this rectangle contains given rectangle vertically.

Value parameters:
rect

Rectangle to test.

Source:
CPRect.scala
override def equals(obj: Any): Boolean
Definition Classes
Equals -> CPIntTuple -> Any
Source:
CPRect.scala
def exists(f: (Int, Int) => Boolean): Boolean

Tests whether this rectangle has at least one points satisfying given predicate.

Tests whether this rectangle has at least one points satisfying given predicate.

Value parameters:
f

Predicate to test.

Source:
CPRect.scala
inline def growTo(x2: Int, y2: Int): CPRect

Creates new rectangle grown in size enough to contain a given point. This method always creates new rectangle and its dimension will always be equal or larger than the dimension of this rectangle.

Creates new rectangle grown in size enough to contain a given point. This method always creates new rectangle and its dimension will always be equal or larger than the dimension of this rectangle.

Value parameters:
x2

X-coordinate of the point.

y2

Y-coordinate of the point.

Source:
CPRect.scala
inline def intersectWith(rect: CPRect): CPRect

Creates intersection rectangle between this rectangle and a given one. If rectangles don't intersect, CPRect.ZERO is returned.

Creates intersection rectangle between this rectangle and a given one. If rectangles don't intersect, CPRect.ZERO is returned.

Value parameters:
rect

Rectangle to intersect with.

Source:
CPRect.scala
inline def isAboveOf(r: CPRect): Boolean

Tests whether this rectangle is position above of the given rectangle.

Tests whether this rectangle is position above of the given rectangle.

Value parameters:
r

Rectangle to test.

Source:
CPRect.scala
inline def isBelowOf(r: CPRect): Boolean

Tests whether this rectangle is position below of the given rectangle.

Tests whether this rectangle is position below of the given rectangle.

Value parameters:
r

Rectangle to test.

Source:
CPRect.scala
inline def isLeftOf(r: CPRect): Boolean

Tests whether this rectangle is position to the left of the given rectangle.

Tests whether this rectangle is position to the left of the given rectangle.

Value parameters:
r

Rectangle to test.

Source:
CPRect.scala
inline def isRightOf(r: CPRect): Boolean

Tests whether this rectangle is position to the right of the given rectangle.

Tests whether this rectangle is position to the right of the given rectangle.

Value parameters:
r

Rectangle to test.

Source:
CPRect.scala
def loop(f: (Int, Int) => Unit): Unit

Calls given XY-coordinate function on each point in this rectangle. Iteration over the points in this rectangle will be horizontal first. In other words, given the rectangle with the following coordinates:

Calls given XY-coordinate function on each point in this rectangle. Iteration over the points in this rectangle will be horizontal first. In other words, given the rectangle with the following coordinates:

   +-----------------+
   |(0,0) (1,0) (2,0)|
   |(0,1) (1,1) (2,1)|
   |(0,2) (1,2) (2,2)|
   +-----------------+

this method will iterate in the following order:

   (0,0) (1,0) (2,0) (0,1) (1,1) (2,1) (0,2) (1,2) (2,2)
Value parameters:
f

XY-coordinate function to call.

See also:
Source:
CPRect.scala
def loopHor(f: (Int, Int) => Unit): Unit

Calls given XY-coordinate function on each point in this rectangle. Iteration over the points in this rectangle will be horizontal first. In other words, given the rectangle with the following coordinates:

Calls given XY-coordinate function on each point in this rectangle. Iteration over the points in this rectangle will be horizontal first. In other words, given the rectangle with the following coordinates:

   +-----------------+
   |(0,0) (1,0) (2,0)|
   |(0,1) (1,1) (2,1)|
   |(0,2) (1,2) (2,2)|
   +-----------------+

this method will iterate in the following order:

   (0,0) (1,0) (2,0) (0,1) (1,1) (2,1) (0,2) (1,2) (2,2)
Value parameters:
f

XY-coordinate function to call.

See also:
Source:
CPRect.scala
def loopVert(f: (Int, Int) => Unit): Unit

Calls given XY-coordinate function on each point in this rectangle. Iteration over the points in this rectangle will be vertical first. In other words, given the rectangle with the following coordinates:

Calls given XY-coordinate function on each point in this rectangle. Iteration over the points in this rectangle will be vertical first. In other words, given the rectangle with the following coordinates:

   +-----------------+
   |(0,0) (1,0) (2,0)|
   |(0,1) (1,1) (2,1)|
   |(0,2) (1,2) (2,2)|
   +-----------------+

this method will iterate in the following order:

   (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
Value parameters:
f

XY-coordinate function to call.

See also:
Source:
CPRect.scala
inline def overlaps(rect: CPRect): Boolean

Tests whether or not this rectangle overlaps with the given one. Note that "touching" rectangles do not intersect as far as this method is concerned.

Tests whether or not this rectangle overlaps with the given one. Note that "touching" rectangles do not intersect as far as this method is concerned.

Value parameters:
rect

Rectangle to test.

Source:
CPRect.scala
def randX(): Int

Gets random X-coordinate within this rectangle.

Gets random X-coordinate within this rectangle.

Source:
CPRect.scala
def randXY(): CPInt2

Gets random XY-coordinate within this rectangle.

Gets random XY-coordinate within this rectangle.

Source:
CPRect.scala
def randY(): Int

Gets random Y-coordinate within this rectangle.

Gets random Y-coordinate within this rectangle.

Source:
CPRect.scala
override def toString: String
Definition Classes
CPIntTuple -> Any
Source:
CPRect.scala
inline def union(rect: CPRect): CPRect

Creates new rectangle with a minimal size to contain both this and given rectangle.

Creates new rectangle with a minimal size to contain both this and given rectangle.

Value parameters:
rect

Rectangle to combine with this rectangle.

Source:
CPRect.scala

Inherited methods

@targetName("multiInt")
inline def *(x: Int): CPInt4

Multiplies given value with each member of this tuple.

Multiplies given value with each member of this tuple.

Value parameters:
x

Value to multiple by.

Returns:

New tuple as a result of multiplication.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("multiIntTuple")
inline def *(x: CPIntTuple[CPInt4]): CPInt4

Multiple two tuples by multiplying their corresponding values.

Multiple two tuples by multiplying their corresponding values.

Value parameters:
x

Other tuple to multiply with.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("plusInt")
inline def +(x: Int): CPInt4

Adds given value to each member of this tuple.

Adds given value to each member of this tuple.

Value parameters:
x

Value to add.

Returns:

New tuple as a result of addition.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("plusIntTuple")
inline def +(x: CPIntTuple[_]): CPInt4

Adds two tuples by adding their corresponding values.

Adds two tuples by adding their corresponding values.

Value parameters:
x

Tuple to add.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("minusInt")
inline def -(x: Int): CPInt4

Subtracts given value from each member of this tuple.

Subtracts given value from each member of this tuple.

Value parameters:
x

Value to subtract.

Returns:

New tuple as a result of subtraction.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("minusIntTuple")
inline def -(x: CPIntTuple[CPInt4]): CPInt4

Subtracts given tuple from this one by subtracting their corresponding values.

Subtracts given tuple from this one by subtracting their corresponding values.

Value parameters:
x

Tuple to subtract.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("divideInt")
inline def /(x: Int): CPInt4

Divides each member of this tuple by the given value.

Divides each member of this tuple by the given value.

Value parameters:
x

Value to divide by.

Returns:

New tuple as a result of division.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("divideIntTuple")
inline def /(x: CPIntTuple[CPInt4]): CPInt4

Device this tuple by the given tuple by dividing their corresponding values.

Device this tuple by the given tuple by dividing their corresponding values.

Value parameters:
x

Other tuple to divide by.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
def <(that: CPInt4): Boolean
Inherited from:
Ordered
@targetName("lessInt")
inline def <(x: Int): Boolean

Less-then '<' operator for int.

Less-then '<' operator for int.

Value parameters:
x

Other tuple to compare.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("lessTuple")
inline def <(x: CPIntTuple[_]): Boolean

Less-then '<' operator for tuples.

Less-then '<' operator for tuples.

Value parameters:
x

Other tuple to compare.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
def <=(that: CPInt4): Boolean
Inherited from:
Ordered
@targetName("lessThenOrEqualTuple")
inline def <=(x: CPIntTuple[_]): Boolean

Less-then-or-equal '<=' operator for tuples.

Less-then-or-equal '<=' operator for tuples.

Value parameters:
x

Other tuple to compare.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("lessThenOrEqualInt")
inline def <=(x: Int): Boolean

Less-then-or-equal '<=' operator for int.

Less-then-or-equal '<=' operator for int.

Value parameters:
x

Other tuple to compare.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
def >(that: CPInt4): Boolean
Inherited from:
Ordered
@targetName("greaterTuple")
inline def >(x: CPIntTuple[_]): Boolean

Greater-then '>' operator for tuples.

Greater-then '>' operator for tuples.

Value parameters:
x

Other tuple to compare.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("greaterInt")
inline def >(x: Int): Boolean

Greater-then '>' operator for int.

Greater-then '>' operator for int.

Value parameters:
x

Other tuple to compare.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
def >=(that: CPInt4): Boolean
Inherited from:
Ordered
@targetName("greaterThenOrEqualTuple")
inline def >=(x: CPIntTuple[_]): Boolean

Greater-then-or-equal '>=' operator for tuples.

Greater-then-or-equal '>=' operator for tuples.

Value parameters:
x

Other tuple to compare.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
@targetName("greaterThenOrEqualInt")
inline def >=(x: Int): Boolean

Greater-then-or-equal '>=' operator for int.

Greater-then-or-equal '>=' operator for int.

Value parameters:
x

Other tuple to compare.

Note:

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
inline override def compare(that: CPInt4): Int
Definition Classes
CPInt4 -> Ordered
Inherited from:
CPInt4
Source:
CPInt4.scala
def compareTo(that: CPInt4): Int
Inherited from:
Ordered
inline def copy: CPInt4

Creates a copy of this tuple.

Creates a copy of this tuple.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
inline def isOne: Boolean

Tests whether all values in this tuple are one.

Tests whether all values in this tuple are one.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
inline def isPositive: Boolean

Checks if this tuple contains only positive (> 0) numbers.

Checks if this tuple contains only positive (> 0) numbers.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
inline def isWhole: Boolean

Checks if this tuple contains only whole (>= 0) numbers.

Checks if this tuple contains only whole (>= 0) numbers.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
inline def isZero: Boolean

Tests whether all values in this tuple are zero.

Tests whether all values in this tuple are zero.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
inline def mapInt(f: Int => Int): CPInt4

Maps this tuple using given function.

Maps this tuple using given function.

Value parameters:
f

Mapping function.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product

Concrete fields

final val area: Int

Area of this rectangle as width * height.

Area of this rectangle as width * height.

Source:
CPRect.scala
final val centerX: Int

X-coordinate of the center point.

X-coordinate of the center point.

Source:
CPRect.scala
final lazy val centerXF: Float

X-coordinate of the center point as a float.

X-coordinate of the center point as a float.

Source:
CPRect.scala
final val centerY: Int

Y-coordinate of the center point.

Y-coordinate of the center point.

Source:
CPRect.scala
final lazy val centerYF: Float

Y-coordinate of the center point as a float.

Y-coordinate of the center point as a float.

Source:
CPRect.scala
final val dim: CPDim

Dimension of this rectangle.

Dimension of this rectangle.

Source:
CPRect.scala
final val h: Int

Height of the rectangular (shortcut API).

Height of the rectangular (shortcut API).

Source:
CPRect.scala
final lazy val hF: Float

Height of the rectangular (shortcut API) as a float.

Height of the rectangular (shortcut API) as a float.

Source:
CPRect.scala
final val isEmpty: Boolean

Whether width or height equals to zero.

Whether width or height equals to zero.

Source:
CPRect.scala
final val nonEmpty: Boolean

Whether width and height are greater than zero.

Whether width and height are greater than zero.

Source:
CPRect.scala
final val w: Int

Width of the rectangular (shortcut API).

Width of the rectangular (shortcut API).

Source:
CPRect.scala
final lazy val wF: Float

Width of the rectangular (shortcut API) as a float.

Width of the rectangular (shortcut API) as a float.

Source:
CPRect.scala
final val xMax: Int

Maximum X-coordinate. If width is zero this will equal to x - 1.

Maximum X-coordinate. If width is zero this will equal to x - 1.

Source:
CPRect.scala
final lazy val xMaxF: Float

Maximum X-coordinate as a float. If width is zero this will equal to x - 1.

Maximum X-coordinate as a float. If width is zero this will equal to x - 1.

Source:
CPRect.scala
final val xMin: Int

Minimal X-coordinate. It is equal to x.

Minimal X-coordinate. It is equal to x.

Source:
CPRect.scala
final lazy val xMinF: Float

Minimal X-coordinate as a float. It is equal to x.

Minimal X-coordinate as a float. It is equal to x.

Source:
CPRect.scala
final val yMax: Int

Maximum Y-coordinate. If height is zero this will equal to y - 1.

Maximum Y-coordinate. If height is zero this will equal to y - 1.

Source:
CPRect.scala
final lazy val yMaxF: Float

Maximum Y-coordinate as a float. If height is zero this will equal to y - 1.

Maximum Y-coordinate as a float. If height is zero this will equal to y - 1.

Source:
CPRect.scala
final val yMin: Int

Minimal Y-coordinate. It is equal to y.

Minimal Y-coordinate. It is equal to y.

Source:
CPRect.scala
final lazy val yMinF: Float

Minimal Y-coordinate as a float. It is equal to y.

Minimal Y-coordinate as a float. It is equal to y.

Source:
CPRect.scala

Inherited fields

val arity: Int

Arity of this tuple.

Arity of this tuple.

Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala
val i1: Int
Inherited from:
CPInt4
Source:
CPInt4.scala
val i2: Int
Inherited from:
CPInt4
Source:
CPInt4.scala
val i3: Int
Inherited from:
CPInt4
Source:
CPInt4.scala
val i4: Int
Inherited from:
CPInt4
Source:
CPInt4.scala
val ints: Int*
Inherited from:
CPIntTuple (hidden)
Source:
CPIntTuple.scala