pub struct Polygon<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
A QPolygon object is a QVector
In addition to the functions provided by QVector, QPolygon provides some point-specific functions.
Each point in a polygon can be retrieved by passing its index to the point() function. To populate the polygon, QPolygon provides the setPoint() function to set the point at a given index, the setPoints() function to set all the points in the polygon (resizing it to the given number of points), and the putPoints() function which copies a number of given points into the polygon from a specified index (resizing the polygon if necessary).
QPolygon provides the boundingRect() and translate() functions for geometry functions. Use the QMatrix::map() function for more general transformations of QPolygons.
The QPolygon class is implicitly shared
See also: [Vector
]
PolygonF
Line
Licence
The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Implementations
sourceimpl<'a> Polygon<'a>
impl<'a> Polygon<'a>
pub fn new() -> Polygon<'a>
sourcepub fn swap<P: PolygonTrait<'a>>(&self, other: &P) -> &Self
pub fn swap<P: PolygonTrait<'a>>(&self, other: &P) -> &Self
Swaps polygon other with this polygon. This operation is very fast and never fails.
sourcepub fn bounding_rect(&self) -> Rect<'_>
pub fn bounding_rect(&self) -> Rect<'_>
Returns the bounding rectangle of the polygon, or QRect(0, 0, 0, 0) if the polygon is empty.
See also: [Vector::is_empty
]
sourcepub fn point_2(&self, i: i32) -> Point<'_>
pub fn point_2(&self, i: i32) -> Point<'_>
Extracts the coordinates of the point at the given index to
- x and * y (if they are valid pointers).
See also: [set_point()
]
Overloads Returns the point at the given index.
sourcepub fn set_point(&self, index: i32, x: i32, y: i32) -> &Self
pub fn set_point(&self, index: i32, x: i32, y: i32) -> &Self
Overloads Sets the point at the given index to the given point.
Sets the point at the given index to the point specified by ( x , y ).
See also: [point()
]
[put_points()
]
[set_points()
]
*/
/*! Resizes the polygon to nPoints and populates it with the given points.
The example code creates a polygon with two points (10, 20) and (30, 40):
See also: [set_point()
]
[put_points()
]
Overloads Resizes the polygon to nPoints and populates it with the points specified by the variable argument list. The points are given as a sequence of integers, starting with firstx then firsty, and so on.
The example code creates a polygon with two points (10, 20) and (30, 40):
sourcepub fn set_point_2<P: PointTrait<'a>>(&self, index: i32, p: &P) -> &Self
pub fn set_point_2<P: PointTrait<'a>>(&self, index: i32, p: &P) -> &Self
Overloads Sets the point at the given index to the given point.
Sets the point at the given index to the point specified by ( x , y ).
See also: [point()
]
[put_points()
]
[set_points()
]
*/
/*! Resizes the polygon to nPoints and populates it with the given points.
The example code creates a polygon with two points (10, 20) and (30, 40):
See also: [set_point()
]
[put_points()
]
Overloads Resizes the polygon to nPoints and populates it with the points specified by the variable argument list. The points are given as a sequence of integers, starting with firstx then firsty, and so on.
The example code creates a polygon with two points (10, 20) and (30, 40):
sourcepub fn set_points_2(&self, n_points: i32, firstx: i32, firsty: i32) -> &Self
pub fn set_points_2(&self, n_points: i32, firstx: i32, firsty: i32) -> &Self
Overloads Resizes the polygon to nPoints and populates it with the points specified by the variable argument list. The points are given as a sequence of integers, starting with firstx then firsty, and so on.
The example code creates a polygon with two points (10, 20) and (30, 40):
sourcepub fn put_points_2(
&self,
index: i32,
n_points: i32,
firstx: i32,
firsty: i32
) -> &Self
pub fn put_points_2(
&self,
index: i32,
n_points: i32,
firstx: i32,
firsty: i32
) -> &Self
Copies nPoints points from the variable argument list into this polygon from the given index.
The points are given as a sequence of integers, starting with firstx then firsty, and so on. The polygon is resized if
index+nPoints
exceeds its current size.
The example code creates a polygon with three points (4,5), (6,7) and (8,9), by expanding the polygon from 1 to 3 points:
The following code has the same result, but here the putPoints() function overwrites rather than extends:
See also: [set_points()
]
Overloads Copies nPoints points from the given fromIndex ( 0 by default) in fromPolygon into this polygon, starting at the specified index. For example:
sourcepub fn put_points_3<P: PolygonTrait<'a>>(
&self,
index: i32,
n_points: i32,
from: &P,
from_index: i32
) -> &Self
pub fn put_points_3<P: PolygonTrait<'a>>(
&self,
index: i32,
n_points: i32,
from: &P,
from_index: i32
) -> &Self
Copies nPoints points from the variable argument list into this polygon from the given index.
The points are given as a sequence of integers, starting with firstx then firsty, and so on. The polygon is resized if
index+nPoints
exceeds its current size.
The example code creates a polygon with three points (4,5), (6,7) and (8,9), by expanding the polygon from 1 to 3 points:
The following code has the same result, but here the putPoints() function overwrites rather than extends:
See also: [set_points()
]
Overloads Copies nPoints points from the given fromIndex ( 0 by default) in fromPolygon into this polygon, starting at the specified index. For example:
sourcepub fn contains_point<P: PointTrait<'a>>(
&self,
pt: &P,
fill_rule: FillRule
) -> bool
pub fn contains_point<P: PointTrait<'a>>(
&self,
pt: &P,
fill_rule: FillRule
) -> bool
Returns true
if the given point is inside the polygon according to
the specified fillRule; otherwise returns false.
sourcepub fn united<P: PolygonTrait<'a>>(&self, r: &P) -> Polygon<'_>
pub fn united<P: PolygonTrait<'a>>(&self, r: &P) -> Polygon<'_>
Returns a polygon which is the union of this polygon and r.
Set operations on polygons, will treat the polygons as areas, and implicitly close the polygon.
See also: [intersected()
]
[subtracted()
]
sourcepub fn intersected<P: PolygonTrait<'a>>(&self, r: &P) -> Polygon<'_>
pub fn intersected<P: PolygonTrait<'a>>(&self, r: &P) -> Polygon<'_>
Returns a polygon which is the intersection of this polygon and r.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
See also: [intersects()
]
sourcepub fn intersects<P: PolygonTrait<'a>>(&self, r: &P) -> bool
pub fn intersects<P: PolygonTrait<'a>>(&self, r: &P) -> bool
Returns true
if the current polygon intersects at any point the given polygon p.
Also returns true
if the current polygon contains or is contained by any part of p.
Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.
See also: [intersected()
]