Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rect::is_zero_area, Size::is_zero_area #370

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This release has an [MSRV][] of 1.65.
- Add `CubicBez::tangents` ([#288] by [@raphlinus])
- Add `Arc::flipped`. ([#367] by [@waywardmonkeys])
- Add `CircleSegment::inner_arc` and `CircleSegment::outer_arc` ([#368] by [@waywardmonkeys])
- Add `Rect::is_zero_area` and `Size::is_zero_area` and deprecate their `is_empty` methods. ([#370] by [@waywardmonkeys])

### Changed

Expand Down Expand Up @@ -59,6 +60,7 @@ Note: A changelog was not kept for or before this release
[#361]: https://github.com/linebender/kurbo/pull/361
[#367]: https://github.com/linebender/kurbo/pull/367
[#368]: https://github.com/linebender/kurbo/pull/368
[#370]: https://github.com/linebender/kurbo/pull/370

[Unreleased]: https://github.com/linebender/kurbo/compare/v0.11.0...HEAD
[0.11.0]: https://github.com/linebender/kurbo/releases/tag/v0.11.0
Expand Down
9 changes: 8 additions & 1 deletion src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,19 @@ impl Rect {
self.width() * self.height()
}

/// Whether this rectangle has zero area.
#[inline]
pub fn is_zero_area(&self) -> bool {
self.area() == 0.0
}

/// Whether this rectangle has zero area.
///
/// Note: a rectangle with negative area is not considered empty.
#[inline]
#[deprecated(since = "0.11.1", note = "use is_zero_area instead")]
pub fn is_empty(&self) -> bool {
self.area() == 0.0
self.is_zero_area()
}

/// The center point of the rectangle.
Expand Down
9 changes: 8 additions & 1 deletion src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,19 @@ impl Size {
self.width * self.height
}

/// Whether this size has zero area.
#[inline]
pub fn is_zero_area(self) -> bool {
self.area() == 0.0
}

/// Whether this size has zero area.
///
/// Note: a size with negative area is not considered empty.
#[inline]
#[deprecated(since = "0.11.1", note = "use is_zero_area instead")]
pub fn is_empty(self) -> bool {
self.area() == 0.0
self.is_zero_area()
}

/// Returns a new size bounded by `min` and `max.`
Expand Down