INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Abstract class rectangle"
project: "Visual Eiffel"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: grape
class RECT
creation

intersect,
load,
make,
make_from_points,
make_from_two_points,
make_from_xywh,
subtract,
union
feature

x: REAL

y: REAL

w: REAL

h: REAL

make, make_from_xywh (xp, yp, width, height: REAL)

make_from_points (x1, y1, x2, y2: REAL)

make_from_two_points (p1, p2: POINT)
feature

xw: REAL

yh: REAL

delta (point1, point2: REAL): REAL
-- Calculates the delta between two coords
require
valid_points: point1 <= point2

compare (another: like Current): BOOLEAN
-- Determines whether the two given rectangles are equal
-- by comparing the coordinates of their upper-left corners
-- and delta-delta metrics.
-- Returns True if they have the same values, and False if they are
-- different

move (x_offset: REAL; y_offset: REAL)
-- Moves the given rectangle by the specified offsets.

resize (x_delta, y_delta: REAL)
-- Changes the height and width by adding a delta value to each of
-- the coordinates. This delta can be negative or positive

inflate (x_amount, y_amount: REAL)
-- Increases or decreases the coordinates of a rectangle.
-- The inflate method subtracts/adds x_amount units to the left and
-- y_amount units to the top ends of the rectangle and adds/subtracts
-- x_amount units from the delta and y_amount units from the delta
-- of the rectangle.
-- The x_amount and y_amount parameters are signed values; positive
-- values increase the rectangle, and negative values decreases him.
require
x_amount < 0 implies - x_amount < w / 2
y_amount < 0 implies - y_amount < h / 2

intersect (source1, source2: RECT)
-- Calculates the intersection of two source rectangles and places the
-- coordinates of the intersection rectangle into the Current rectangle.
-- If the rectangles do not intersect, an empty rectangle (0, 0, 0, 0)
-- is placed into the Current rectangle.

subtract (source1: RECT; source2: RECT)
-- Creates a rectangle from the difference of two others.
-- The rectangle specified by the source2 parameter is subtracted
-- from the rectangle specified by source1 only when the rectangles
-- intersect completely in either the x- or y-direction.
-- The result is placed in the current rectangle.
require
rectangles_intersects: source1.is_intersect (source2)
complete_intersection: ((source2.x <= source1.x and then source2.xw >= source1.xw) or else (source2.y <= source1.y and then source2.yh >= source1.yh))

union (source1: RECT; source2: RECT)
-- Creates the union of two rectangles. The union is the
-- smallest rectangle that contains both source rectangles.

load (rc: RESOURCE_CONTAINER; code: INTEGER)

build (rc: RESOURCE_CONTAINER; p: POINTER)

is_empty: BOOLEAN
-- Determines whether the specified rectangle is empty. A rectangle is
-- empty if its width or height is zero, or if both are zero.

is_point_in (x_coord, y_coord: REAL): BOOLEAN
-- Determines whether a point is in a rectangle

is_intersect (another: like Current): BOOLEAN
-- Determines if the Current rectangle intersects with the given
-- rectangle

distance (p: POINT): REAL
-- shortest distance from point p to edge of Rect
ensure
Result >= 0

top_left: POINT

top_right: POINT

bottom_left: POINT

bottom_right: POINT

is_top (p: POINT): BOOLEAN

is_bottom (p: POINT): BOOLEAN

is_left (p: POINT): BOOLEAN

is_right (p: POINT): BOOLEAN

min (a, b: REAL): REAL

max (a, b: REAL): REAL
end -- class RECT

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES