Loading...
Searching...
No Matches
Public Member Functions | List of all members
BPolygon Class Reference

A closed, many-sided figure which defines an area in a two-dimensional Cartesian coordinate system. More...

Public Member Functions

 BPolygon ()
 Initializes an empty polygon without any points.
 
 BPolygon (const BPoint *points, int32 count)
 Initializes a new BPolygon object from an array of points.
 
 BPolygon (const BPolygon &other)
 Initializes a new BPolygon object from another BPolygon and copies the list of BPoint objects from other.
 
 BPolygon (const BPolygon *other)
 Initializes a new BPolygon object from a pointer to another BPolygon and copies the list of BPoint objects from other.
 
virtual ~BPolygon ()
 Destroys the object and frees the memory used by the associated BPoint objects.
 
void AddPoints (const BPoint *points, int32 count)
 Adds an array of BPoint objects.
 
int32 CountPoints () const
 Returns the number of points associated with the polygon.
 
BRect Frame () const
 Returns the frame rectangle that encloses the BPolygon object.
 
void MapTo (BRect source, BRect destination)
 Modifies each BPoint in the BPolygon so that the shape fits inside the destination rectangle.
 
BPolygonoperator= (const BPolygon &other)
 Initializes a new BPolygon object and copies the list of BPoint objects from other.
 
void PrintToStream () const
 Prints each of the points of the BPolygon to standard output.
 

Detailed Description

A closed, many-sided figure which defines an area in a two-dimensional Cartesian coordinate system.

A BPolygon is defined as a set of BPoint objects, each BPoint represents a vertex of the polygon. Unlike a BRect, a BPolygon can can have any number of sides and the sides don't have to be aligned on coordinate axes.

BPolygon objects are most commonly used for drawing. BView::StrokePolygon() and BView::FillPolygon() allow you to draw a polygon in a BView by taking a BPolygon object as an argument.

See also
BView::StrokePolygon()
BView::FillPolygon()
Since
BeOS R3

Constructor & Destructor Documentation

◆ BPolygon() [1/4]

BPolygon::BPolygon ( const BPoint points,
int32  count 
)

Initializes a new BPolygon object from an array of points.

Parameters
pointsThe array of BPoint objects to add.
countThe number of BPoint objects in the array.
Since
BeOS R3

◆ BPolygon() [2/4]

BPolygon::BPolygon ( const BPolygon other)

Initializes a new BPolygon object from another BPolygon and copies the list of BPoint objects from other.

Parameters
otherThe BPolygon object to copy from.
Since
Haiku R1

◆ BPolygon() [3/4]

BPolygon::BPolygon ( const BPolygon other)

Initializes a new BPolygon object from a pointer to another BPolygon and copies the list of BPoint objects from other.

Parameters
otherA pointer to a BPolygon object to copy from.
Since
BeOS R3

◆ BPolygon() [4/4]

BPolygon::BPolygon ( )

Initializes an empty polygon without any points.

See also
BPolygon::AddPoints() to add points to the BPolygon.
Since
BeOS R3

◆ ~BPolygon()

BPolygon::~BPolygon ( )
virtual

Destroys the object and frees the memory used by the associated BPoint objects.

Since
BeOS R3

Member Function Documentation

◆ AddPoints()

void BPolygon::AddPoints ( const BPoint points,
int32  count 
)

Adds an array of BPoint objects.

Parameters
pointsThe array of BPoint objects to add.
countThe number of BPoint objects in the array.
Since
BeOS R3

◆ CountPoints()

int32 BPolygon::CountPoints ( ) const

Returns the number of points associated with the polygon.

Since
BeOS R3

◆ Frame()

BRect BPolygon::Frame ( ) const

Returns the frame rectangle that encloses the BPolygon object.

Since
BeOS R3

◆ MapTo()

void BPolygon::MapTo ( BRect  source,
BRect  destination 
)

Modifies each BPoint in the BPolygon so that the shape fits inside the destination rectangle.

The source rectangle is used so that the points are mapped proportionally. To modify a polygon so that it is inscribed in the destination rectangle exactly, pass the frame rectangle as the source.

Since
BeOS R3

◆ operator=()

BPolygon & BPolygon::operator= ( const BPolygon other)

Initializes a new BPolygon object and copies the list of BPoint objects from other.

Parameters
otherThe BPolygon object to copy from.
Since
BeOS R3

◆ PrintToStream()

void BPolygon::PrintToStream ( ) const

Prints each of the points of the BPolygon to standard output.

See also
BPoint::PrintToStream()
Since
BeOS R3