Skip to content

Commit

Permalink
Add center property.
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Oct 14, 2023
1 parent 7c8aec1 commit 133894e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/xtd.drawing/include/xtd/drawing/rectangle_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ namespace xtd {
/// @remarks The value of the xtd::drawing::rectangle_f::bottom property represents the y-coordinate of the first point at the bottom edge of the xtd::drawing::rectangle_f that is not contained in the xtd::drawing::rectangle_f.
float bottom() const noexcept;

/// @brief Gets the center property values of this xtd::drawing::rectangle structure.
/// @return The center of this xtd::drawing::rectangle.
point_f center() const noexcept;

/// @brief Gets the height of this xtd::drawing::rectangle_f structure.
/// @return The height of this Rectangle structure. The default is 0.
/// @remarks Changing the xtd::drawing::rectangle_f::height property will also cause a change in the xtd::drawing::rectangle_f::bottom property of the xtd::drawing::rectangle_f. The units the rectangle is drawn in is determined by the xtd::drawing::graphics::page_unit and xtd::drawing::graphics::page_scale properties of the graphics object used for drawing. The default unit is pixels.
Expand Down
4 changes: 4 additions & 0 deletions src/xtd.drawing/src/xtd/drawing/rectangle_f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ float rectangle_f::bottom() const noexcept {
return y_ + height_;
}

point_f rectangle_f::center() const noexcept {
return {x_ + width_ / 2, y_ + height_ / 2};
}

float rectangle_f::height() const noexcept {
return height_;
}
Expand Down

0 comments on commit 133894e

Please sign in to comment.