Skip to content

Commit

Permalink
Add Rect::with[Horizontal|Vertical]Range()
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed Oct 29, 2023
1 parent 6b7cbf9 commit dd75643
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ class Rect
Rect<T> withTrimmedTop(T amount) const { return {x, y + amount, w, h - amount}; }
Rect<T> withTrimmedBottom(T amount) const { return {x, y, w, h - amount}; }

/* with[Horizontal|Vertical]Range
Returns a copy of this rect new position and size defined by Range 'r'. */

Rect<T> withHorizontalRange(Range<T> r) const { return {r.a, y, r.getLength(), h}; }
Rect<T> withVerticalRange(Range<T> r) const { return {x, r.a, w, r.getLength()}; }

/* get[Width|Height]AsLine
Returns width or height as a new Line object. */

Expand Down

0 comments on commit dd75643

Please sign in to comment.