previous chapter contents page top page next chapter

Path

October 5, 1992last updated September 30, 1993

Defined in Graphics.Def 
Inherits from Object

Class Description

The Magic Cap graphics system defines objects of class Path to represent arbitrary areas on the screen. Paths are constructed by specifying lines and boxes while accumulating the area that's inside the lines and boxes. The resulting accumulated area is a path.

Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Using a Path Object

Class Path is a direct descendant of class Object. Path objects include a couple of private fields, including one containing the smallest box that surrounds the entire path.

Path objects are usually only in use for a short time. You'll often create a path to use with a drawing call, then destroy the path after the call is made. You'll create paths using the path creation methods described below. You won't find any paths in the Magic Hat or elsewhere in the software.

Programming Information

Instantiate: sometimes
Subclass: rarely
Call its methods: sometimes

Usually, you'll create a path object in order to define a clipping path for a Draw call. Whenever you create a new class of viewable object, you override Draw to define how to draw the objects. The system passes in a clipping path when it calls your Draw method. You can compute a more refined clipping path in your overridden Draw method, then calculate the intersection of that smaller path and the passed-in path to make drawing faster.You might also create a path object if you want to fill a complex area on the screen.

Class Path defines methods for constructing paths from lines and boxes, for performing operations on paths, such as intersection and difference, and for testing whether the path includes a given box or dot.

Methods you might call

The Path class has the following methods you might call:

Method Description
SetBoxPath Sets a path to the given box
SectPath Compute the intersection of two paths
AddLine Add the given line to the path
AddBox Add the given box to the path
OpenPath Prepare to constructing a new path
ClosePath Finished constructing new path

Description of fields

The Path class defines the following fields:

Field Type Description
count Unsigned Used internally

Method Descriptions

SetBoxPath

operation SetBoxPath(box1: Box)

call: sometimes
Override: rarely

Call NewBoxPath to set the path object to the area described by the given box.

SectPath

operation SectPath(srcA: Path; srcB: Path)

call: sometimes
Override: rarely

Call SectPath to compute the intersection of two given paths. SectPath calculates the intersecting area of the two paths in srcA and srcB, then put the resulting path into the object.

AddLine

operation AddLine(dot1: Dot; dot2: Dot)

call: sometimes
Override: rarely

If you want to construct a path that's not simply a box, you can call AddLine to add a line to the path's edge. AddLine adds the line described by the given dots to the path's edge. You can mix calls to AddLine, AddBox, and AddRoundBox to construct the path.

Before calling AddLine, you should have created the path object (by calling New, for example) and prepared it by calling OpenPath.

AddBox

operation AddBox(box1: Box)

call: sometimes
Override: rarely

If you want to construct a path that's not simply a box, but includes a box in its description, you can call AddBox to add a box to the path. AddBox adds the given box to the path. You can mix calls to AddLine, AddBox, and AddRoundBox to construct the path.

Before calling AddBox, you should have created the path object (by calling New, for example) and prepared it by calling OpenPath.

OpenPath

operation OpenPath()

call: sometimes
Override: rarely

If you want to construct a path that's not simply a box, call OpenPath after you've created the path object (by calling New, for example). After calling OpenPath, you can call path construction methods (AddLine, AddBox, and AddRoundBox) to construct the path. Call ClosePath to finish constructing the path.

ClosePath

operation ClosePath()

If you've called OpenPath to construct a path, call ClosePath when you're done describing the path with path construction methods (AddLine, AddBox, and AddRoundBox).