2 * Copyright 2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * John Scipione, jscipione@gmail.com
9 * headers/os/interface/Polygon.h hrev47240
10 * src/kits/interface/Polygon.cpp hrev47240
18 \brief BPolygon class definition.
26 \brief A closed, many-sided figure which defines an area in a
27 two-dimensional Cartesian coordinate system.
29 A BPolygon is defined as a set of BPoint objects, each BPoint represents
30 a vertex of the polygon. Unlike a BRect, a BPolygon can can have any number
31 of sides and the sides don't have to be aligned on coordinate axes.
33 BPolygon objects are most commonly used for drawing. BView::StrokePolygon()
34 and BView::FillPolygon() allow you to draw a polygon in a BView by taking a
35 BPolygon object as an argument.
37 \sa BView::StrokePolygon()
38 \sa BView::FillPolygon()
45 \fn BPolygon::BPolygon(const BPoint* points, int32 count)
46 \brief Initializes a new BPolygon object from an array of \a points.
48 \param points The array of BPoint objects to add.
49 \param count The number of BPoint objects in the array.
56 \fn BPolygon::BPolygon(const BPolygon& other)
57 \brief Initializes a new BPolygon object from another BPolygon and
58 copies the list of BPoint objects from \a other.
60 \param other The BPolygon object to copy from.
67 \fn BPolygon::BPolygon(const BPolygon* other)
68 \brief Initializes a new BPolygon object from a pointer to another
69 BPolygon and copies the list of BPoint objects from \a other.
71 \param other A pointer to a BPolygon object to copy from.
78 \fn BPolygon::BPolygon()
79 \brief Initializes an empty polygon without any points.
81 \see BPolygon::AddPoints() to add points to the BPolygon.
88 \fn BPolygon::~BPolygon()
89 \brief Destroys the object and frees the memory used by the associated
97 \fn BPolygon& BPolygon::operator=(const BPolygon& other)
98 \brief Initializes a new BPolygon object and copies the list of BPoint
99 objects from \a other.
101 \param other The BPolygon object to copy from.
108 \fn BRect BPolygon::Frame() const
109 \brief Returns the frame rectangle that encloses the BPolygon object.
116 \fn void BPolygon::AddPoints(const BPoint* points, int32 count)
117 \brief Adds an array of BPoint objects.
119 \param points The array of BPoint objects to add.
120 \param count The number of BPoint objects in the array.
127 \fn int32 BPolygon::CountPoints() const
128 \brief Returns the number of points associated with the polygon.
135 \fn void BPolygon::MapTo(BRect source, BRect destination)
136 \brief Modifies each BPoint in the BPolygon so that the shape fits inside
137 the \a destination rectangle.
139 The \a source rectangle is used so that the points are mapped
140 proportionally. To modify a polygon so that it is inscribed in the
141 \a destination rectangle exactly, pass the frame rectangle as the
149 \fn void BPolygon::PrintToStream() const
150 \brief Prints each of the points of the BPolygon to standard output.
152 \see BPoint::PrintToStream()