The Interface Kit Table of Contents | The Interface Kit Index |
Derived from: BArchivable
Declared in: be/interface/Shape.h
Library: libbe.so
Allocation: Constructor only
The BShape class provides a powerful means of representing the outline of any shape that can be comprised of lines or Beziér curves.
The BShapeIterator class provides a means for utilizing BShape objects in your own code. You can also use BShape objects to obtain outlines of characters in a BFont by calling BFont::GetGlyphShapes().
A BShape is essentially a list of graphics commands, of which there are four types:
Functions by the same names are used to add the corresponding commands to the BShape object. For example, to create a BShape that represents two vertical lines, the following code might be used:
BShape shape; shape.MoveTo(0,0); shape.LineTo(0,100); shape.MoveTo(5,0); shape.LineTo(5,100);
|
Creates a new BShape object. The first form of the BShape constructor creates an empty shape. The second form, which accepts another BShape as an argument, copies that shape into the new one. The third form reconstructs a BShape from an archive.
|
Releases memory occupied by the BShape object.
|
Returns a new BShape object, allocated by new and created with the version of the constructor that takes a BMessage archive. However, if the archive message doesn't contain data for a BShape object, the return value will be NULL.
See also: BArchivable::Instantiate(), instantiate_object(), Archive()
|
AddShape() adds the lines and curves that comprise the otherShape to the shape.
RETURN CODES
B_OK. No error.
|
Adds a command to the BShape that represents a Beziér curve that begins at the current coordinates and is constructed using the specified control points.
RETURN CODES
B_OK. No error.
|
Bounds() returns the bounds rectangle of the entire shape; this rectangle encloses all the lines and Beziér curves that comprise the shape.
|
Clear() deletes all the lines and Beziér curves that comprise the shape, leaving it empty.
|
Close() should be called when the shape has been fully-constructed by calls to the BezierTo(), LineTo(), and MoveTo() functions.
RETURN CODES
B_OK. No error.
|
Adds a "draw line" command to the BShape. A line will be drawn from the previous coordinates to the specified coordinates.
RETURN CODES
B_OK. No error.
|
Adds a "move to" command to the BShape. The next LineTo() or BezierTo() will begin at this point. This lets you create noncontiguous shapes.
RETURN CODES
B_OK. No error.
The Archive() function adds the following fields to its BMessage argument:
Field | Type code | Meaning |
---|---|---|
"pts" | B_POINT_TYPE | The list of points used by the shape's commands. |
"ops" | B_INT32_TYPE | The list of command opcodes indicating the shape's commands. |
The Interface Kit Table of Contents | The Interface Kit Index |
Copyright © 2000 Be, Inc. All rights reserved..