1.4 class area

An area is a rectangular set of pixels. areas are used by graphical objects and windows to represent their position and size.

An area has an origin, described by the area<->x and area<->y attributes and a size described by the area<->width and area<->height attributes. All parameters are in pixel-units. An area with either area<->width or area<->height equal to 0 (zero) contains no pixels.

The position of the origin with respect to the rectangle is determined by the sign of the width and height attributes. See area area->orientation and area area->normalise.

Class area supports class graphical to represent the area of the graphical in the coordinate system of its device. Most of the methods defined on class area also exist on class graphical. For area's, these methods are side-effect free, whereas for graphicals they change the geometry of the graphical. See graphical->set and‘graphical area->geometry’.

See also
- class region
- area->orientation
- area->normalise
- class point
- class size
- class graphical

1.4.1 Instance variables

area <-> height: int
Height of area in pixels. Zero height implies the area contains no pixels. With a positive value, the origin is at the top, with a negative value it is at the bottom.
See also
area-width
area <-> width: int
Width of area in pixels. Zero width implies the area contains no pixels. With a positive value, the origin is at the left, with a negative value it is at the right.
See also
area-height
area <-> x: int
X-coordinate of the area. The value may both be positive and negative, indicating the origin of the area to be at the right, resp. left of the origin of the coordinate system.
See also
area-y
area <-> y: int
Y-coordinate of the area. The value may both be positive and negative, indicating the origin of the area to be at below/above of the origin of the coordinate system.
See also
area-x

1.4.2 Send methods

area ->center: point
Move the area<-x and area<-y of the area such that the area<-center of the area matches the argument point.
See also
area->set
area ->clear:
Equivalent to area->set: 0, 0, 0, 0. Note that an area with area<-width or area<-height equal contain no pixels and area->union with such an area is a no-op.
See also
area->union
area ->corner: point
Manipulate area<-width and area<-height such that area<-corner matches the argument point. Its graphical->corner counterpart is sometimes used to implement resizing.
See also
area<-corner
area ->decrease: int
Makes the area from all sides smaller by the specified amount. For normalised areas (see area->normalise), this implies:
<-width := <-width - 2*<arg>
<-x     := <-x + <arg>

and similar for area<-y and area<-height. Deals properly with non-normalised areas.

See also
- graphical->resize
- area->increase
area ->equal: area
Succeed if the normalised representation of both areas is the same. See area->normalise.
area ->in: point
@see event->inside
area ->increase: int
Move all sides outward. This is the opposite operation of area->decrease.
See also
area->decrease
area ->initialise: x=[int], y=[int], width=[int], height=[int]
Creates an area with origin at (X,Y) and given width and height.
area ->inside: area
Succeeds if the argument area is inside this area. See also area->in, graphical->in_event_area and area->overlap.
See also
device<-inside
area ->intersection: area
Area becomes the intersection with the argument area. The intersection is the largest (rectangular) area that is area->inside both area's. To get the intersection without modifying either of the areas, use area<-intersection. Fails without modifying the area if the areas do not area->overlap.
See also
- area->overlap
- area<-intersection
area ->normalise:
Places the origin at the top-left corner. Equivalent to area->orientation: north_west.
See also
- area<-normalised
- area->orientation
- class area
area ->orientation: {north_west,south_west,north_east,south_east}
An area object is described by its area<-x, area<-y, area<-width and area<-height. The point (area<-x, area<-y) is called the origin or area<-position. Either or both area<-width and area<-height (together representing area<-size) may be negative. This method manipulates one or both of the pairs area<-x/area<-width or area<-y/area<-height such that the origin becomes the indicated corner.

The call area->orientation: north_west is equivalent to area->normalise.

area->orientation area->width area->height
north_west>= 0>= 0
south_west>= 0< 0
north_east< 0>= 0
south_east< 0< 0
See also
class area
area ->overlap: area
Succeeds if both areas describe common pixels. If this message succeeds, area<-distance returns 0 and area->intersection computes the common pixels.
See also
- area->intersection
- area<-distance
area ->position: point
Copy area<-x and area<-y from the corresponding values of the point object.
area ->relative_move: point
Executes area<-x := area<-x + point<-x and area<-y := area<-y + point<-y.
area ->set: x=[int], y=[int], width=[int], height=[int]
Sets area<-x, area<-y, area<-width and area<-height from the 4 integer arguments. Any argument that is @default will not cause the corresponding parameter to be changed.
area ->size: size
Sets area->width and area->height from the corresponding size parameters.
area ->union: area
Enlarge the area such that it represents the smallest area containing both area objects. area<-union computes the same without changing either of the area objects.
See also
- area<-union
- area->clear

1.4.3 Get methods

area <-left_side: -> int
area <-right_side: -> int
area <-top_side: -> int
area <-bottom_side: -> int
Return the pixel position of the specified edge. Deals properly with areas in any area<-orientation.
See also
- area<-top_side
- area<-right_side
- area<-left_side
area <-corner: -> point
New point at area<-x + area<-width, area<-y + area<-height
See also
- graphical->corner
- area->corner
area <-distance: area -> int
Yields the length of the shortest line that can connect a point on the outline of the first area with a point on the outline of the second area. Yields 0 if the graphicals overlap.
See also
- area<-distance_y
- area<-distance_x
- area->overlap
- graphical<-distance
area <-distance_x: area -> int
Yields an integer representing the distance between the areas in X-direction. Yields 0 if both areas overlap in X-direction.
See also
- area<-distance
- area<-distance_y
- graphical<-distance_x
area <-distance_y: area -> int
Yields an integer representing the distance between the areas in Y-direction. Yields 0 if both areas overlap in Y-direction.
See also
- area<-distance
- area<-distance_x
area <-intersection: area -> area
New area object that represents the common part of the receiver and argument area. The area<-orientation of the new area is the same as that of the receiver.

See also area->intersection and area<-union.

Diagnostics: Fails if the areas do not area->overlap.

See also
area->intersection
area <-less_sides: area -> int
Like area->same_sides, but returns those sides for which the value in the receiver is closer to the origin (i.e. less) then for the argument area.
See also
- area<-same_sides
- area<-near_sides
area <-near_sides: area, int -> int
Same as area<-same_sides, but accepts sides to be the same when they are within the specified distance. With distance 0, exactly the same as area<-same_sides.
See also
- area<-same_sides
- area<-less_sides
area <-normalised: -> area
Return a new area object that describes the same collection of pixels and has area<-orientation = north_west.
See also
area->normalise
area <-orientation: -> {north_west,south_west,north_east,south_east}
Current orientation. See area->orientation for details.

Inherits description from: area->orientation

area <-position: -> point
New point object from area<-x and area<-y.
area <-same_sides: area -> int
Returns a bitmask for sides that have the same value on both arguments. Implemented in the darkness of time for handling automatic layout. The values of the mask are:
ReceiverArgumentValue (octal)
toptop01
topcenter02
topbottom04
centertop010
bottomtop020
bottomcenter040
bottombottom0100
leftleft0200
leftmiddle0400
leftright01000
middleleft02000
middlemiddle04000
middleright010000
rightleft020000
rightmiddle040000
rightright0100000

The PCE/Prolog library file area.pl defines these bitmasks.

area <-size: -> size
New size object from the area<-width and area<-height of the area. Note that either or both may be negative. See area->orientation.
area <-union: area -> area