# cocos.rect module

class `Rect`(x, y, width, height)

  Bases: `object`

  Define a rectangular area.

  Many convenience handles and other properties are also defined - all of which may be assigned to which will result in altering the position and sometimes dimensions of the Rect:

  > - top – y pixel extent
  > - bottom – y pixel extent
  > - left – x pixel extent
  > - right – x pixel extent
  > - position – (x, y) of bottom-left corner pixel
  > - origin – (x, y) of bottom-left corner pixel
  > - center – (x, y) of center pixel
  > - topleft – (x, y) of top-left corner pixel
  > - topright – (x, y) of top-right corner pixel
  > - bottomleft – (x, y) of bottom-left corner pixel
  > - bottomright – (x, y) of bottom-right corner pixel
  > - midtop – (x, y) of middle of top side pixel
  > - midbottom – (x, y) of middle of bottom side pixel
  > - midleft – (x, y) of middle of left side pixel
  > - midright – (x, y) of middle of right side pixel
  > - size – (width, height) of rect

  The Rect area includes the bottom and left borders but not the top and right borders.

  `clippedBy`(other)

    bool. True iif intersection with other is smaller than self.

    Equivalent: True if self doesn’t fit entirely into other

        >>> r1 = Rect(0, 0, 10, 10)
        >>> r2 = Rect(1, 1, 9, 9)
        >>> r2.clippedBy(r1)    # r2 fits inside r1
        False
        >>> r1.clippedBy(r2)    # r1 is clipped by r2
        True
        >>> r2 = Rect(1, 1, 11, 11)
        >>> r1.intersect(r2)
        Rect(xy=1,1; wh=9,9)
        >>> r1.clippedBy(r2)
        True
        >>> r2.intersect(r1)
        Rect(xy=1,1; wh=9,9)
        >>> r2.clippedBy(r1)
        True
        >>> r2 = Rect(11, 11, 1, 1)
        >>> r1.clippedBy(r2)
        True

  `contains`(x, y)

    Return boolean whether the point defined by x, y is inside the rect area.

  `copy`()
  `get_bottom`()
  `get_bottomleft`()
  `get_bottomright`()
  `get_center`()
  `get_left`()
  `get_midbottom`()
  `get_midleft`()
  `get_midright`()
  `get_midtop`()
  `get_origin`()
  `get_right`()
  `get_top`()
  `get_topleft`()
  `get_topright`()
  `intersect`(other)

    Find the intersection of two Rect s.

        >>> r1 = Rect(0, 51, 200, 17)
        >>> r2 = Rect(0, 64, 200, 55)
        >>> r1.intersect(r2)
        Rect(xy=0,64; wh=200,4)

        >>> r1 = Rect(0, 64, 200, 55)
        >>> r2 = Rect(0, 0, 200, 17)
        >>> print r1.intersect(r2)
        None

        >>> r1 = Rect(10, 10, 10, 10)
        >>> r2 = Rect(20, 20, 10, 10)
        >>> print r1.intersect(r2)
        None

        >>> bool(Rect(0, 0, 1, 1))
        True
        >>> bool(Rect(0, 0, 1, 0))
        False
        >>> bool(Rect(0, 0, 0, 1))
        False
        >>> bool(Rect(0, 0, 0, 0))
        False

  `intersects`(other)

    Return boolean whether the interior of “other” rect (an object with .x, .y, .width and .height attributes) overlaps the interior of this Rect in any way.

  `set_bottom`(y)
  `set_bottomleft`(position)
  `set_bottomright`(position)
  `set_center`(center)
  `set_height`(value)
  `set_left`(x)
  `set_midbottom`(midbottom)
  `set_midleft`(midleft)
  `set_midright`(midright)
  `set_midtop`(midtop)
  `set_origin`(origin)
  `set_position`(value)
  `set_right`(x)
  `set_size`(value)
  `set_top`(y)
  `set_topleft`(position)
  `set_topright`(position)
  `set_width`(value)
  `set_x`(value)
  `set_y`(value)
  `bottom`
  `bottomleft`
  `bottomright`
  `center`
  `height`
  `left`
  `midbottom`
  `midleft`
  `midright`
  `midtop`
  `origin`
  `position`
  `right`
  `size`
  `top`
  `topleft`
  `topright`
  `width`
  `x`
  `y`