CPRect

org.cosplay.CPRect
See theCPRect companion object
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.

Attributes

See also

CPArray2D 2D content holder.

Companion
object
Source
CPRect.scala
Graph
Supertypes
trait Product
trait Equals
class CPInt4
trait Ordered[CPInt4]
trait Comparable[CPInt4]
trait Serializable
class Object
trait Matchable
class Any
Show all

Members list

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

Source
CPRect.scala
override def equals(obj: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

Source
CPRect.scala
def randX(): Int

Gets random X-coordinate within this rectangle.

Gets random X-coordinate within this rectangle.

Attributes

Source
CPRect.scala
def randXY(): CPInt2

Gets random XY-coordinate within this rectangle.

Gets random XY-coordinate within this rectangle.

Attributes

Source
CPRect.scala
def randY(): Int

Gets random Y-coordinate within this rectangle.

Gets random Y-coordinate within this rectangle.

Attributes

Source
CPRect.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

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.

Attributes

Source
CPRect.scala

Inherited methods

inline def *(x: Int): T

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.

Attributes

Returns

New tuple as a result of multiplication.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def *(x: CPIntTuple[CPInt4]): T

Multiple two tuples by multiplying their corresponding values.

Multiple two tuples by multiplying their corresponding values.

Value parameters

x

Other tuple to multiply with.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def +(x: Int): T

Adds given value to each member of this tuple.

Adds given value to each member of this tuple.

Value parameters

x

Value to add.

Attributes

Returns

New tuple as a result of addition.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def +(x: CPIntTuple[_]): T

Adds two tuples by adding their corresponding values.

Adds two tuples by adding their corresponding values.

Value parameters

x

Tuple to add.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def -(x: Int): T

Subtracts given value from each member of this tuple.

Subtracts given value from each member of this tuple.

Value parameters

x

Value to subtract.

Attributes

Returns

New tuple as a result of subtraction.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def -(x: CPIntTuple[CPInt4]): T

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.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def /(x: Int): T

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.

Attributes

Returns

New tuple as a result of division.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline def /(x: CPIntTuple[CPInt4]): T

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.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
def <(that: CPInt4): Boolean

Attributes

Inherited from:
Ordered
inline def <(x: Int): Boolean

Less-then '<' operator for int.

Less-then '<' operator for int.

Value parameters

x

Other tuple to compare.

Attributes

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

Less-then '<' operator for tuples.

Less-then '<' operator for tuples.

Value parameters

x

Other tuple to compare.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
def <=(that: CPInt4): Boolean

Attributes

Inherited from:
Ordered
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.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
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.

Attributes

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
def >(that: CPInt4): Boolean

Attributes

Inherited from:
Ordered
inline def >(x: CPIntTuple[_]): Boolean

Greater-then '>' operator for tuples.

Greater-then '>' operator for tuples.

Value parameters

x

Other tuple to compare.

Attributes

Note

Tuples must have the same arity.

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

Greater-then '>' operator for int.

Greater-then '>' operator for int.

Value parameters

x

Other tuple to compare.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
def >=(that: CPInt4): Boolean

Attributes

Inherited from:
Ordered
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.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
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.

Attributes

Note

Tuples must have the same arity.

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
inline override def compare(that: CPInt4): Int

Attributes

Definition Classes
CPInt4 -> Ordered
Inherited from:
CPInt4
Source
CPInt4.scala
def compareTo(that: CPInt4): Int

Attributes

Inherited from:
Ordered
inline def copy: T

Creates a copy of this tuple.

Creates a copy of this tuple.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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.

Attributes

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

Maps this tuple using given function.

Maps this tuple using given function.

Value parameters

f

Mapping function.

Attributes

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

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields

val area: Int

Area of this rectangle as width * height.

Area of this rectangle as width * height.

Attributes

Source
CPRect.scala
val centerX: Int

X-coordinate of the center point.

X-coordinate of the center point.

Attributes

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.

Attributes

Source
CPRect.scala
val centerY: Int

Y-coordinate of the center point.

Y-coordinate of the center point.

Attributes

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.

Attributes

Source
CPRect.scala
val dim: CPDim

Dimension of this rectangle.

Dimension of this rectangle.

Attributes

Source
CPRect.scala
val h: Int

Height of the rectangular (shortcut API).

Height of the rectangular (shortcut API).

Attributes

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.

Attributes

Source
CPRect.scala
val isEmpty: Boolean

Whether width or height equals to zero.

Whether width or height equals to zero.

Attributes

Source
CPRect.scala
val nonEmpty: Boolean

Whether width and height are greater than zero.

Whether width and height are greater than zero.

Attributes

Source
CPRect.scala
val w: Int

Width of the rectangular (shortcut API).

Width of the rectangular (shortcut API).

Attributes

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.

Attributes

Source
CPRect.scala
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.

Attributes

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.

Attributes

Source
CPRect.scala
val xMin: Int

Minimal X-coordinate. It is equal to x.

Minimal X-coordinate. It is equal to x.

Attributes

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.

Attributes

Source
CPRect.scala
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.

Attributes

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.

Attributes

Source
CPRect.scala
val yMin: Int

Minimal Y-coordinate. It is equal to y.

Minimal Y-coordinate. It is equal to y.

Attributes

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.

Attributes

Source
CPRect.scala

Inherited fields

val arity: Int

Arity of this tuple.

Arity of this tuple.

Attributes

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala
val i1: Int

Attributes

Inherited from:
CPInt4
Source
CPInt4.scala
val i2: Int

Attributes

Inherited from:
CPInt4
Source
CPInt4.scala
val i3: Int

Attributes

Inherited from:
CPInt4
Source
CPInt4.scala
val i4: Int

Attributes

Inherited from:
CPInt4
Source
CPInt4.scala
val ints: Int*

Attributes

Inherited from:
CPIntTuple (hidden)
Source
CPIntTuple.scala