Skip to content

Commit ef0915c

Browse files
authored
update docs for Path.getBounds (#5261)
* update docs for getBounds * Add computeMetrics suggestion * better explanation
1 parent bb1736b commit ef0915c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎lib/ui/painting.dart‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,20 @@ class Path extends NativeFieldWrapperClass2 {
17921792
Path _transform(Float64List matrix4) native 'Path_transform';
17931793

17941794
/// Computes the bounding rectangle for this path.
1795+
///
1796+
/// A path containing only axis-aligned points on the same straight line will
1797+
/// have no area, and therefore `Rect.isEmpty` will return true for such a
1798+
/// path. Consider checking `rect.width + rect.height > 0.0` instead, or
1799+
/// using the [computeMetrics] API to check the path length.
1800+
///
1801+
/// For many more elaborate paths, the bounds may be inaccurate. For example,
1802+
/// when a path contains a circle, the points used to compute the bounds are
1803+
/// the circle's implied control points, which form a square around the circle;
1804+
/// if the circle has a transformation applied using [transform] then that
1805+
/// square is rotated, and the (axis-aligned, non-rotated) bounding box
1806+
/// therefore ends up grossly overestimating the actual area covered by the
1807+
/// circle.
1808+
// see https://skia.org/user/api/SkPath_Reference#SkPath_getBounds
17951809
Rect getBounds() {
17961810
final Float32List rect = _getBounds();
17971811
return new Rect.fromLTRB(rect[0], rect[1], rect[2], rect[3]);

0 commit comments

Comments
 (0)