Contents

Description

A module for handling pixel rectangles: Rectangle.

Synopsis

# Usage

import XMonad.Util.Rectangle as R
R.empty (Rectangle 0 0 1024 768)

Rectangle as two points. What those points mean depends on the conversion function.

Constructors

 PointRectangle Fieldspoint_x1 :: aPoint nearest to the origin.point_y1 :: a point_x2 :: aPoint furthest from the origin.point_y2 :: a

#### Instances

Instances details
 Read a => Read (PointRectangle a) Source # Instance detailsDefined in XMonad.Util.Rectangle MethodsreadPrec :: ReadPrec (PointRectangle a)readListPrec :: ReadPrec [PointRectangle a] Show a => Show (PointRectangle a) Source # Instance detailsDefined in XMonad.Util.Rectangle MethodsshowsPrec :: Int -> PointRectangle a -> ShowS #showList :: [PointRectangle a] -> ShowS # Eq a => Eq (PointRectangle a) Source # Instance detailsDefined in XMonad.Util.Rectangle Methods(==) :: PointRectangle a -> PointRectangle a -> Bool #(/=) :: PointRectangle a -> PointRectangle a -> Bool #

There are three possible ways to convert rectangles to pixels:

• Consider integers as "gaps" between pixels; pixels range from (N,N+1), exclusively: (0,1), (1,2), and so on. This leads to interval ambiguity: whether an integer endpoint contains a pixel depends on which direction the interval approaches the pixel. Consider the adjacent pixels (0,1) and (1,2) where 1 can refer to either pixel (0,1) or pixel (1,2).
• Consider integers to demarcate the start of each pixel; pixels range from [N,N+1): [0,1), [1,2), and so on - or equivalently: (N,N+1]. This is the most flexible coordinate system, and the convention used by the Rectangle type.
• Consider integers to demarcate the center of each pixel; pixels range from [N,N+1], as though each real-valued coordinate had been rounded (either down or up) to the nearest integers. So each pixel, from zero, is listed as: [0,0], [1,1], [2,2], and so on. Rather than a coordinate system, this considers pixels as row/colum indices. While easiest to reason with, indices are unable to represent zero-dimension rectangles.

Consider pixels as indices. Do not use this on empty rectangles.

Consider pixels as [N,N+1) coordinates. Available for empty rectangles.

Invert pixelsToIndices.

Invert pixelsToCoordinates.

True if either the rect_width or rect_height fields are zero, i.e. the rectangle has no area.

True if the intersection of the set of points comprising each rectangle is not the empty set. Therefore any rectangle containing the initial points of an empty rectangle will never intersect that rectangle - including the same empty rectangle.

True if the first rectangle contains at least all the points of the second rectangle. Any rectangle containing the initial points of an empty rectangle will be a superset of that rectangle - including the same empty rectangle.

Return the smallest set of rectangles resulting from removing all the points of the second rectangle from those of the first, i.e. r1 - r2, such that 0 <= l <= 4 where l is the length of the resulting list.

Arguments

 :: Integer Top border. -> Integer Bottom border. -> Integer Right border. -> Integer Left border. -> Integer Smallest allowable rectangle dimensions, i.e. width/height, with values <0 defaulting to 0. -> Rectangle -> Rectangle

Fit a Rectangle within the given borders of itself. Given insufficient space, borders are minimized while preserving the ratio of opposite borders. Origin is top-left, and yes, negative borders are allowed.

center :: Rectangle -> (Ratio Integer, Ratio Integer) Source #

Calculate the center - (x,y) - as if the Rectangle were bounded.

Invert scaleRationalRect. Since that operation is lossy a roundtrip conversion may not result in the original value. The first Rectangle is scaled to the second:

>>> (Rectangle 2 2 6 6) toRatio (Rectangle 0 0 10 10)
RationalRect (1 % 5) (1 % 5) (3 % 5) (3 % 5)