previous chapter contents page top page next chapter

Measurement

October 5, 1992
last updated January 17, 1996

Defined in Graphics.def

Inherits from Object

Class Description

The Magic Cap graphics system defines a set of utility routines that perform various handy tests and calculations using x-y coordinates. These routines operate mainly on the two basic building blocks of the graphics system, dots and boxes.

Dots and boxes are simple data structures rather than full-fledged objects, so there is no dot or box class. Therefore, these utilities can't be methods of a dot or box class; there are no such classes. Instead, a class called Measurement was created, and these utilities have been collected together as intrinsic methods of the Measurement class.

Why are these utilities represented as intrinsic methods? Unlike ordinary methods, class methods don't require the object to be their first parameter. Because these routines operate on dots and boxes, they often don't have any objects as parameters.

Using a Measurement Object

Because class Measurement exists only as a convenient way to group utilities that operate on x-y coordinates, there are no objects of class Measurement, and you'll never have to create any. You can call any of the intrinsic methods of class Measurement without ever creating a measurement object. Class Measurement defines no fields or regular methods, only intrinsic methods.

Programming information

Instantiate: never
Subclass: never
Call its methods: sometimes

Methods defined by class Measurement

Class Measurement defines the following methods:

Method Description
BoxBoundsBox Returns true if one box is entirely enclosed by another
BoxBoundsDot Returns true if the pixel is contained within the box
BoxHitsBox Returns true if the boxes intersect
CenterBox Centers a box within another
CompareDelta Compares the position of two dots and returns the larger
CompareDiag Compares the sizes of two boxes and returns the larger
CompareDot Returns true if two dots are within the given distance
DiffBox Computes the difference between two boxes and returns the resulting
bounds
EqualBox Returns true if the boxes are equal
EqualDot Returns true if the dots are the same
ExtendBox Extends the box to include the point
InsetBox Shrinks the box horizontally and vertically
InsetBoxByThickness Shrinks the box
MapBox Moves the box in-between two boxes
MapDot Moves the dot in-between two boxes
MapTouch Moves a touch in-between two boxes
NotEmptyBox Returns true if the box contains one or more points
OffsetBox Moves the box vertically and horizontally by the supplied offsets
OutsetBoxByThickness Expands the box
PinDot Constrains a dot to the coordinates of the box
PinBox Constrains a box to the coordinates of another box
RotateBox Rotates a box by 90 degrees about its center
SectBox Returns true if the boxes intersect. Also returns the intersection.
SetEmptyBox Empties a rectangle
UnionBox Returns true if a non-empty box is returned. Also returns the union.

Fields defined by class Measurement

Class Measurement doesn't define any fields.

Method Descriptions

Containment and Collision Detection

BoxBoundsDot

intrinsic BoxBoundsDot(bounds: Box; dot1: Dot): Boolean

Call: sometimes
Override: never

Call BoxBoundsDot to determine if a dot lies within a box. Returns true if dot1 is inside bounds; otherwise, returns false.

Manipulating Dots and Boxes

InsetBox

intrinsic InsetBox(VAR box1: Box; dh: Micron; dv: Micron)

Call: sometimes
Override: never

Call InsetBox to enlarge or shrink a box by fixed amounts in both dimensions. The box to be changed is passed as box1. The dh and dv parameters contain the amount to change the box in its horizontal and vertical dimensions, respectively. InsetBox adds the value in dh to the left and right edges of the box and adds the value in dv to the top and bottom values of the box. Passing a negative value for dh or dv enlarges the box in that dimension; positive value shrinks the box.

OffsetBox

intrinsic OffsetBox(VAR box1: Box; dh: Micron; dv: Micron)

Call: sometimes
Override: never

Call OffsetBox to move the given box by adding dh to each horizontal coordinate and dv to each vertical coordinate. If dh is positive, the box moves to the right; if dh is negative, the box moves to the left. Similarly, if dv is positive, the box moves down; if dv is negative, the box moves up. The box retains its original shape and size.

SetEmptyBox

intrinsic SetEmptyBox(VAR box1: Box)

Call: sometimes
Override: rarely

Call SetEmptyBox to make the given box empty; that is, set it so that it encloses no dots. SetEmptyBox accomplishes this by setting all of the box's coordinates to zero.