xtd - Reference Guide 0.2.0
xtd::drawing::rectangle Class Reference

#include <rectangle.h>

Definition

Stores a set of four integers that represent the location and size of a rectangle.

class drawing_export_ rectangle : public xtd::object
Inheritance
xtd::objectxtd::drawing::rectangle
Namespace
xtd::drawing
Library
xtd.drawing
Examples
The following example draws a rectangle with its upper-left corner at (10, 10). The rectangle has a width of 100 and a height of 50. The second argument passed to the Pen constructor indicates that the pen width is 5 pixels.

When the rectangle is drawn, the pen is centered on the rectangle's boundary. Because the pen width is 5, the sides of the rectangle are drawn 5 pixels wide, such that 1 pixel is drawn on the boundary itself, 2 pixels are drawn on the inside, and 2 pixels are drawn on the outside. For more details on pen alignment, see How to: Set Pen Width and Alignment.

The following illustration shows the resulting rectangle. The dotted lines show where the rectangle would have been drawn if the pen width had been one pixel. The enlarged view of the upper-left corner of the rectangle shows that the thick black lines are centered on those dotted lines.

rectangle_pens.png

The example is designed for use with xtd.forms, and it requires xtd::forms::paint_event_args e, which is a parameter of the xtd::forms::control::paint event handler.

pen black_pen(color::from_argb(255, 0, 0, 0), 5);
e.graphics().draw_rectangle(black_pen, 10, 10, 100, 50);
Remarks
A rectangle is defined by its xtd::drawing::rectangle::width, xtd::drawing::rectangle::height, and upper-left corner represented by the xtd::drawing::rectangle::location property.
To draw rectangles, you need a xtd::drawing::graphics object and a xtd::drawing::pen object. The xtd::drawing::graphics object provides the xtd::drawing::graphics::draw_rectangle method, and the xtd::drawing::pen object stores features of the line, such as color and width. 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.
To draw a xtd::drawing::rectangle filled with color, you need a xtd::drawing::graphics object and an object derived from xtd::drawing::brush such as xtd::drawing::solid_brush or xtd::drawing::texture_brush or xtd::drawing::drawing2d::conical_gradient_brush or xtd::drawing::drawing2d::hatch_gradient_brush or xtd::drawing::drawing2d::linear_gradient_brush or xtd::drawing::drawing2d::radial_gradient_brush. The xtd::drawing::graphics object provides the xtd::drawing::graphics::fill_rectangle method and the xtd::drawing::brush object provides the color and fill information.
For more advanced shapes, use a xtd::drawing::region object.
Examples:
fill_rectangle.cpp, screen.cpp, and user_control.cpp.

Fields

static const rectangle empty
 Represents a xtd::drawing::rectangle that has xtd::drawing::rectagle::x, xtd::drawing::rectangle::y, xtd::drawing::rectangle::width and xtd::drawing::rectangle::height values set to zero. More...
 

Constructors

 rectangle () noexcept=default
 Initializes a new instance of the xtd::drawing::rectangle class. More...
 
 rectangle (int32_t x, int32_t y, int32_t width, int32_t height) noexcept
 Initializes a new instance of the xtd::drawing::rectangle class with the specified location and size. More...
 
 rectangle (const xtd::drawing::point &location, const xtd::drawing::size &size) noexcept
 Initializes a new instance of the xtd::drawing::rectangle class with the specified location and size. More...
 

Properties

int32_t bottom () const noexcept
 Gets the y-coordinate that is the sum of the xtd::drawing::rectangle::y and xtd::drawing::rectangle::height property values of this xtd::drawing::rectangle structure. More...
 
int32_t height () const noexcept
 Gets the height of this xtd::drawing::rectangle structure. More...
 
void height (int32_t value) noexcept
 Sets the height of this xtd::drawing::rectangle structure. More...
 
bool is_empty () const noexcept
 Tests whether all numeric properties of this xtd::drawing::rectangle have values of zero. More...
 
int32_t left () const noexcept
 Gets the x-coordinate of the left edge of this xtd::drawing::rectangle structure. More...
 
xtd::drawing::point location () const noexcept
 Gets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure. More...
 
void location (const xtd::drawing::point &value) noexcept
 Sets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure. More...
 
int32_t right () const noexcept
 Gets the x-coordinate that is the sum of xtd::drawing::rectangle::x and xtd::drawing::rectangle::width property values of this xtd::drawing::rectangle structure. More...
 
xtd::drawing::size size () const noexcept
 Gets the size of this xtd::drawing::rectangle. More...
 
void size (const xtd::drawing::size &value) noexcept
 Sets the size of this xtd::drawing::rectangle. More...
 
int32_t top () const noexcept
 Gets the y-coordinate of the top edge of this xtd::drawing::rectangle structure. More...
 
int32_t width () const noexcept
 Gets the width of this xtd::drawing::rectangle structure. More...
 
void width (int32_t value) noexcept
 Sets the width of this xtd::drawing::rectangle structure. More...
 
int32_t x () const noexcept
 Gets the x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. More...
 
void x (int32_t value) noexcept
 Sets the x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. More...
 
int32_t y () const noexcept
 Gets the y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. More...
 
void y (int32_t value) noexcept
 Sets the y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. More...
 

Methods

void add (const drawing::size &sz) noexcept
 Adds this xtd::drawing::rectangle by the specified amount. More...
 
void add (int width, int height) noexcept
 Adds this xtd::drawing::rectangle by the specified amount. More...
 
bool contains (const xtd::drawing::point &pt) const noexcept
 Determines if the specified point is contained within this xtd::drawing::rectangle structure. More...
 
bool contains (const xtd::drawing::rectangle &rect) const noexcept
 Determines if the rectangular region represented by rect is entirely contained within this xtd::drawing::rectangle structure. More...
 
bool contains (int32_t x, int32_t y) const noexcept
 Determines if the specified point is contained within this xtd::drawing::rectangle structure. More...
 
void inflate (const drawing::size &sz) noexcept
 Enlarges this xtd::drawing::rectangle by the specified amount. More...
 
void inflate (int width, int height) noexcept
 Enlarges this xtd::drawing::rectangle by the specified amount. More...
 
bool intersects_with (const rectangle &rect) const noexcept
 Determines if this rectangle intersects with rect. More...
 
void make_intersect (const rectangle &rect) noexcept
 Replaces this xtd::drawing::rectangle with the intersection of itself and the specified xtd::drawing::rectangle. More...
 
void make_union (const rectangle &rect) noexcept
 Replaces this xtd::drawing::rectangle with the union of itself and the specified xtd::drawing::rectangle. More...
 
void offset (const point &pos) noexcept
 Adjusts the location of this rectangle by the specified amount. More...
 
void offset (int32_t x, int32_t y) noexcept
 Adjusts the location of this rectangle by the specified amount. More...
 
xtd::ustring to_string () const noexcept override
 Converts the attributes of this xtd::drawing::rectangle to a human-readable string. More...
 
static rectangle add (const rectangle &rect, int x, int y) noexcept
 Creates and returns an added copy of the specified xtd::drawing::rectangle structure. The copy is added by the specified amount. The original xtd::drawing::rectangle structure remains unmodified. More...
 
static rectangle add (const rectangle &rect, const drawing::size &sz) noexcept
 Creates and returns an added copy of the specified xtd::drawing::rectangle structure. The copy is added by the specified amount. The original xtd::drawing::rectangle structure remains unmodified. More...
 
static rectangle ceiling (const xtd::drawing::rectangle_f &rect) noexcept
 Converts the specified xtd::drawing::rectangle_f structure to a xtd::drawing::rectangle structure by rounding the xtd::drawing::rectangle_f values to the next higher integer values. More...
 
static rectangle from_ltrb (int32_t left, int32_t top, int32_t right, int32_t bottom) noexcept
 Creates a xtd::drawing::rectangle structure with the specified edge locations. More...
 
static rectangle inflate (const rectangle &rect, int x, int y) noexcept
 Creates and returns an enlarged copy of the specified xtd::drawing::rectangle structure. The copy is enlarged by the specified amount. The original xtd::drawing::rectangle structure remains unmodified. More...
 
static rectangle inflate (const rectangle &rect, const drawing::size &sz) noexcept
 Creates and returns an enlarged copy of the specified xtd::drawing::rectangle structure. The copy is enlarged by the specified amount. The original xtd::drawing::rectangle structure remains unmodified. More...
 
static rectangle make_intersect (const rectangle &a, const rectangle &b) noexcept
 Returns a third xtd::drawing::rectangle structure that represents the intersection of two other xtd::drawing::rectangle structures. If there is no intersection, an empty xtd::drawing::rectangle is returned. More...
 
static rectangle make_union (const rectangle &a, const rectangle &b) noexcept
 Gets a xtd::drawing::rectangle structure that contains the union of two xtd::drawing::rectangle structures. More...
 
static rectangle offset (const rectangle &rect, const point &pos) noexcept
 Creates and returns an offsetted copy of the specified xtd::drawing::rectangle structure. The copy is offsetted by the specified amount. The original xtd::drawing::rectangle structure remains unmodified. More...
 
static rectangle offset (const rectangle &rect, int x, int y) noexcept
 Creates and returns an offsetted copy of the specified xtd::drawing::rectangle structure. The copy is offsetted by the specified amount. The original xtd::drawing::rectangle structure remains unmodified. More...
 
static rectangle round (const rectangle_f &rect) noexcept
 Converts the specified xtd::drawing::rectangle_f to a xtd::drawing::rectangle by rounding the xtd::drawing::rectangle_f values to the nearest integer values. More...
 
static rectangle truncate (const rectangle_f &rect) noexcept
 Converts the specified xtd::drawing::rectangle_f to a xtd::drawing::rectangle by truncating the xtd::drawing::rectangle_f values. More...
 

Operators

bool operator== (const rectangle &value) const noexcept
 Tests whether two xtd::drawing::rectangle structures have equal location and size. More...
 
bool operator!= (const rectangle &value) const noexcept
 Tests whether two xtd::drawing::rectangle structures differ in location or size. More...
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Constructor & Destructor Documentation

◆ rectangle() [1/3]

xtd::drawing::rectangle::rectangle ( )
defaultnoexcept

Initializes a new instance of the xtd::drawing::rectangle class.

Remarks
xtd::drawing::rectagle::x, xtd::drawing::rectangle::y, xtd::drawing::rectangle::width and xtd::drawing::rectangle::height values are set to zero.

◆ rectangle() [2/3]

xtd::drawing::rectangle::rectangle ( int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height 
)
noexcept

Initializes a new instance of the xtd::drawing::rectangle class with the specified location and size.

Parameters
xThe x-coordinate of the upper-left corner of the rectangle.
yThe y-coordinate of the upper-left corner of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.

◆ rectangle() [3/3]

xtd::drawing::rectangle::rectangle ( const xtd::drawing::point location,
const xtd::drawing::size size 
)
noexcept

Initializes a new instance of the xtd::drawing::rectangle class with the specified location and size.

Parameters
locationA xtd::drawing::point that represents the upper-left corner of the rectangular region.
sizeA xtd::drawing::size that represents the width and height of the rectangular region.

Member Function Documentation

◆ add() [1/4]

void xtd::drawing::rectangle::add ( const drawing::size sz)
noexcept

Adds this xtd::drawing::rectangle by the specified amount.

Parameters
szThe amount to add this rectangle.
Remarks
This method adds this rectangle, not a copy of it.

◆ add() [2/4]

void xtd::drawing::rectangle::add ( int  width,
int  height 
)
noexcept

Adds this xtd::drawing::rectangle by the specified amount.

Parameters
widthThe amount to add this xtd::drawing::rectangle horizontally.
heightThe amount to add this xtd::drawing::rectangle verticaly.
Remarks
This method adds this rectangle, not a copy of it.

◆ add() [3/4]

static rectangle xtd::drawing::rectangle::add ( const rectangle rect,
int  x,
int  y 
)
staticnoexcept

Creates and returns an added copy of the specified xtd::drawing::rectangle structure. The copy is added by the specified amount. The original xtd::drawing::rectangle structure remains unmodified.

Parameters
rectThe xtd::drawing::rectangle with which to start. This rectangle is not modified.
xThe amount to add the specified rectangle horizontally.
yThe amount to add the specified rectangle vertically.
Returns
The added xtd::drawing::rectangle.
Remarks
This method makes a copy of rect, adds the copy, and then returns the added copy.

◆ add() [4/4]

static rectangle xtd::drawing::rectangle::add ( const rectangle rect,
const drawing::size sz 
)
staticnoexcept

Creates and returns an added copy of the specified xtd::drawing::rectangle structure. The copy is added by the specified amount. The original xtd::drawing::rectangle structure remains unmodified.

Parameters
rectThe xtd::drawing::rectangle with which to start. This rectangle is not modified.
szThe amount to add the specified rectangle.
Returns
The added xtd::drawing::rectangle.
Remarks
This method makes a copy of rect, adds the copy, and then returns the added copy.

◆ bottom()

int32_t xtd::drawing::rectangle::bottom ( ) const
noexcept

Gets the y-coordinate that is the sum of the xtd::drawing::rectangle::y and xtd::drawing::rectangle::height property values of this xtd::drawing::rectangle structure.

Returns
The y-coordinate that is the sum of xtd::drawing::rectangle::y and xtd::drawing::rectangle::height of this xtd::drawing::rectangle.
Remarks
The value of the xtd::drawing::rectangle::bottom property represents the y-coordinate of the first point at the bottom edge of the xtd::drawing::rectangle that is not contained in the xtd::drawing::rectangle.

◆ ceiling()

static rectangle xtd::drawing::rectangle::ceiling ( const xtd::drawing::rectangle_f rect)
staticnoexcept

Converts the specified xtd::drawing::rectangle_f structure to a xtd::drawing::rectangle structure by rounding the xtd::drawing::rectangle_f values to the next higher integer values.

Parameters
rectThe xtd::drawing::rectangle_f structure to be converted.
Returns
Returns a xtd::drawing::rectangle.

◆ contains() [1/3]

bool xtd::drawing::rectangle::contains ( const xtd::drawing::point pt) const
noexcept

Determines if the specified point is contained within this xtd::drawing::rectangle structure.

Parameters
ptThe xtd::drawing::point to test.
Returns
This method returns true if the point represented by pt is contained within this xtd::drawing::rectangle structure; otherwise false.
Remarks
The containing rectangle must be normalized for this method to return accurate results.

◆ contains() [2/3]

bool xtd::drawing::rectangle::contains ( const xtd::drawing::rectangle rect) const
noexcept

Determines if the rectangular region represented by rect is entirely contained within this xtd::drawing::rectangle structure.

Parameters
rectThe xtd::drawing::rectangle to test.
Returns
This method returns true if the rectangular region represented by rect is entirely contained within this xtd::drawing::rectangle structure; otherwise false.
Remarks
The containing rectangle must be normalized for this method to return accurate results.

◆ contains() [3/3]

bool xtd::drawing::rectangle::contains ( int32_t  x,
int32_t  y 
) const
noexcept

Determines if the specified point is contained within this xtd::drawing::rectangle structure.

Parameters
xThe x-coordinate of the point to test.
yThe y-coordinate of the point to test.
Returns
This method returns true if the point defined by x and y is contained within this xtd::drawing::rectangle structure; otherwise false.
Remarks
The containing rectangle must be normalized for this method to return accurate results.

◆ from_ltrb()

static rectangle xtd::drawing::rectangle::from_ltrb ( int32_t  left,
int32_t  top,
int32_t  right,
int32_t  bottom 
)
staticnoexcept

Creates a xtd::drawing::rectangle structure with the specified edge locations.

Parameters
leftThe x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.
topThe y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.
rightThe x-coordinate of the lower-right corner of this xtd::drawing::rectangle structure.
bottomThe y-coordinate of the lower-right corner of this xtd::drawing::rectangle structure.
Returns
The new xtd::drawing::rectangle that this method creates.
Remarks
This method creates a xtd::drawing::rectangle with the specified upper-left and lower-right corners.

◆ height() [1/2]

int32_t xtd::drawing::rectangle::height ( ) const
noexcept

Gets the height of this xtd::drawing::rectangle structure.

Returns
The height of this Rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::height property will also cause a change in the xtd::drawing::rectangle::bottom property of the xtd::drawing::rectangle. 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.

◆ height() [2/2]

void xtd::drawing::rectangle::height ( int32_t  value)
noexcept

Sets the height of this xtd::drawing::rectangle structure.

Parameters
valueThe height of this Rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::height property will also cause a change in the xtd::drawing::rectangle::bottom property of the xtd::drawing::rectangle. 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.

◆ inflate() [1/4]

void xtd::drawing::rectangle::inflate ( const drawing::size sz)
noexcept

Enlarges this xtd::drawing::rectangle by the specified amount.

Parameters
szThe amount to inflate this rectangle.
Remarks
This method enlarges this rectangle, not a copy of it. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is enlarged by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

◆ inflate() [2/4]

void xtd::drawing::rectangle::inflate ( int  width,
int  height 
)
noexcept

Enlarges this xtd::drawing::rectangle by the specified amount.

Parameters
widthThe amount to inflate this xtd::drawing::rectangle horizontally.
heightThe amount to inflate this xtd::drawing::rectangle verticaly.
Remarks
This method enlarges this rectangle, not a copy of it. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is enlarged by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.
If either x or y is negative, the xtd::drawing::rectangle structure is deflated in the corresponding direction.

◆ inflate() [3/4]

static rectangle xtd::drawing::rectangle::inflate ( const rectangle rect,
int  x,
int  y 
)
staticnoexcept

Creates and returns an enlarged copy of the specified xtd::drawing::rectangle structure. The copy is enlarged by the specified amount. The original xtd::drawing::rectangle structure remains unmodified.

Parameters
rectThe xtd::drawing::rectangle with which to start. This rectangle is not modified.
xThe amount to inflate the specified rectangle horizontally.
yThe amount to inflate the specified rectangle vertically.
Returns
The enlarged xtd::drawing::rectangle.
Remarks
This method makes a copy of rect, enlarges the copy, and then returns the enlarged copy. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is enlarged by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

◆ inflate() [4/4]

static rectangle xtd::drawing::rectangle::inflate ( const rectangle rect,
const drawing::size sz 
)
staticnoexcept

Creates and returns an enlarged copy of the specified xtd::drawing::rectangle structure. The copy is enlarged by the specified amount. The original xtd::drawing::rectangle structure remains unmodified.

Parameters
rectThe xtd::drawing::rectangle with which to start. This rectangle is not modified.
szThe amount to inflate the specified rectangle.
Returns
The enlarged xtd::drawing::rectangle.
Remarks
This method makes a copy of rect, enlarges the copy, and then returns the enlarged copy. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is enlarged by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

◆ intersects_with()

bool xtd::drawing::rectangle::intersects_with ( const rectangle rect) const
noexcept

Determines if this rectangle intersects with rect.

Parameters
rectThe rectangle to test.
Returns
This method returns true if there is any intersection, otherwise false.

◆ is_empty()

bool xtd::drawing::rectangle::is_empty ( ) const
noexcept

Tests whether all numeric properties of this xtd::drawing::rectangle have values of zero.

Returns
This property returns true if the xtd::drawing::rectangle::width, xtd::drawing::rectangle::height, xtd::drawing::rectangle::x, and xtd::drawing::rectangle::y properties of this xtd::drawing::rectangle all have values of zero; otherwise, false.

◆ left()

int32_t xtd::drawing::rectangle::left ( ) const
noexcept

Gets the x-coordinate of the left edge of this xtd::drawing::rectangle structure.

Returns
The x-coordinate of the left edge of this xtd::drawing::rectangle structure.

◆ location() [1/2]

xtd::drawing::point xtd::drawing::rectangle::location ( ) const
noexcept

Gets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure.

Returns
A xtd::drawing::point that represents the upper-left corner of this xtd::drawing::rectangle structure.
Examples:
screen.cpp.

◆ location() [2/2]

void xtd::drawing::rectangle::location ( const xtd::drawing::point value)
noexcept

Sets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure.

Parameters
valueA xtd::drawing::point that represents the upper-left corner of this xtd::drawing::rectangle structure.

◆ make_intersect() [1/2]

static rectangle xtd::drawing::rectangle::make_intersect ( const rectangle a,
const rectangle b 
)
staticnoexcept

Returns a third xtd::drawing::rectangle structure that represents the intersection of two other xtd::drawing::rectangle structures. If there is no intersection, an empty xtd::drawing::rectangle is returned.

Parameters
aA rectangle to intersect.
bA rectangle to intersect.
Returns
A xtd::drawing::rectangle that represents the intersection of a and b.

◆ make_intersect() [2/2]

void xtd::drawing::rectangle::make_intersect ( const rectangle rect)
noexcept

Replaces this xtd::drawing::rectangle with the intersection of itself and the specified xtd::drawing::rectangle.

Parameters
rectThe xtd::drawing::rectangle with which to intersect.

◆ make_union() [1/2]

static rectangle xtd::drawing::rectangle::make_union ( const rectangle a,
const rectangle b 
)
staticnoexcept

Gets a xtd::drawing::rectangle structure that contains the union of two xtd::drawing::rectangle structures.

Parameters
aA rectangle to union.
bA rectangle to union.
Returns
A xtd::drawing::rectangle structure that bounds the union of the two xtd::drawing::rectangle structures.

◆ make_union() [2/2]

void xtd::drawing::rectangle::make_union ( const rectangle rect)
noexcept

Replaces this xtd::drawing::rectangle with the union of itself and the specified xtd::drawing::rectangle.

Parameters
rectThe xtd::drawing::rectangle with which to union.

◆ offset() [1/4]

void xtd::drawing::rectangle::offset ( const point pos)
noexcept

Adjusts the location of this rectangle by the specified amount.

Parameters
posAmount to offset the location.
Remarks
This method adjusts the location of the upper-left corner horizontally by the x-coordinate of the specified point, and vertically by the y-coordinate of the specified point.

◆ offset() [2/4]

void xtd::drawing::rectangle::offset ( int32_t  x,
int32_t  y 
)
noexcept

Adjusts the location of this rectangle by the specified amount.

Parameters
xThe horizontal offset.
yThe vertical offset.

◆ offset() [3/4]

static rectangle xtd::drawing::rectangle::offset ( const rectangle rect,
const point pos 
)
staticnoexcept

Creates and returns an offsetted copy of the specified xtd::drawing::rectangle structure. The copy is offsetted by the specified amount. The original xtd::drawing::rectangle structure remains unmodified.

Parameters
rectThe xtd::drawing::rectangle with which to start. This rectangle is not modified.
posThe amount to offset the specified rectangle.
Returns
The offsetted xtd::drawing::rectangle.
Remarks
This method makes a copy of rect, offsets the copy, and then returns the offsetted copy.

◆ offset() [4/4]

static rectangle xtd::drawing::rectangle::offset ( const rectangle rect,
int  x,
int  y 
)
staticnoexcept

Creates and returns an offsetted copy of the specified xtd::drawing::rectangle structure. The copy is offsetted by the specified amount. The original xtd::drawing::rectangle structure remains unmodified.

Parameters
rectThe xtd::drawing::rectangle with which to start. This rectangle is not modified.
xThe amount to offset the specified rectangle horizontally.
yThe amount to offset the specified rectangle vertically.
Returns
The offsetted xtd::drawing::rectangle.
Remarks
This method makes a copy of rect, offsets the copy, and then returns the offsetted copy.

◆ operator!=()

bool xtd::drawing::rectangle::operator!= ( const rectangle value) const
noexcept

Tests whether two xtd::drawing::rectangle structures differ in location or size.

Parameters
valueThe xtd::drawing::rectangle structure that is to the right of the inequality operator.
Returns
This operator returns true if any of the xtd::drawing::rectangle::x, xtd::drawing::rectangle::y, xtd::drawing::rectangle::width or xtd::drawing::rectangle::height properties of the two xtd::drawing::rectangle structures are unequal; otherwise false.

◆ operator==()

bool xtd::drawing::rectangle::operator== ( const rectangle value) const
noexcept

Tests whether two xtd::drawing::rectangle structures have equal location and size.

Parameters
valueThe xtd::drawing::rectangle structure that is to the right of the equality operator.
Returns
This operator returns true if the two xtd::drawing::rectangle structures have equal xtd::drawing::rectangle::x, xtd::drawing::rectangle::y, xtd::drawing::rectangle::width, and xtd::drawing::rectangle::height properties.

◆ right()

int32_t xtd::drawing::rectangle::right ( ) const
noexcept

Gets the x-coordinate that is the sum of xtd::drawing::rectangle::x and xtd::drawing::rectangle::width property values of this xtd::drawing::rectangle structure.

Returns
The x-coordinate that is the sum of xtd::drawing::rectangle::x and xtd::drawing::rectangle::width of this xtd::drawing::rectangle.

◆ round()

static rectangle xtd::drawing::rectangle::round ( const rectangle_f rect)
staticnoexcept

Converts the specified xtd::drawing::rectangle_f to a xtd::drawing::rectangle by rounding the xtd::drawing::rectangle_f values to the nearest integer values.

Parameters
rectThe xtd::drawing::rectangle_f to be converted.
Returns
The rounded integer value of the xtd::drawing::rectangle.

◆ size() [1/2]

xtd::drawing::size xtd::drawing::rectangle::size ( ) const
noexcept

Gets the size of this xtd::drawing::rectangle.

Returns
A xtd::drawing::size that represents the width and height of this xtd::drawing::rectangle structure.
Examples:
screen.cpp.

◆ size() [2/2]

void xtd::drawing::rectangle::size ( const xtd::drawing::size value)
noexcept

Sets the size of this xtd::drawing::rectangle.

Parameters
valueA xtd::drawing::size that represents the width and height of this xtd::drawing::rectangle structure.

◆ to_string()

xtd::ustring xtd::drawing::rectangle::to_string ( ) const
overridevirtualnoexcept

Converts the attributes of this xtd::drawing::rectangle to a human-readable string.

Returns
A string that contains the position, width, and height of this Rectangle structure ¾ for example, {x=20, y=20, width=100, height=50}.

Reimplemented from xtd::object.

◆ top()

int32_t xtd::drawing::rectangle::top ( ) const
noexcept

Gets the y-coordinate of the top edge of this xtd::drawing::rectangle structure.

Returns
The y-coordinate of the top edge of this xtd::drawing::rectangle structure.

◆ truncate()

static rectangle xtd::drawing::rectangle::truncate ( const rectangle_f rect)
staticnoexcept

Converts the specified xtd::drawing::rectangle_f to a xtd::drawing::rectangle by truncating the xtd::drawing::rectangle_f values.

Parameters
rectThe xtd::drawing::rectangle_f to be converted.
Returns
The truncated value of the xtd::drawing::rectangle.

◆ width() [1/2]

int32_t xtd::drawing::rectangle::width ( ) const
noexcept

Gets the width of this xtd::drawing::rectangle structure.

Returns
The width of this xtd::drawing::rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::width property will also cause a change in the xtd::drawing::rectangle::bottom property of the xtd::drawing::rectangle. 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.

◆ width() [2/2]

void xtd::drawing::rectangle::width ( int32_t  value)
noexcept

Sets the width of this xtd::drawing::rectangle structure.

Parameters
valueThe width of this xtd::drawing::rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::width property will also cause a change in the xtd::drawing::rectangle::bottom property of the xtd::drawing::rectangle. 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.

◆ x() [1/2]

int32_t xtd::drawing::rectangle::x ( ) const
noexcept

Gets the x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.

Returns
The x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::x property will also cause a change in the xtd::drawing::rectangle::right property of the xtd::drawing::rectangle.

◆ x() [2/2]

void xtd::drawing::rectangle::x ( int32_t  value)
noexcept

Sets the x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.

Parameters
valueThe x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::x property will also cause a change in the xtd::drawing::rectangle::right property of the xtd::drawing::rectangle.

◆ y() [1/2]

int32_t xtd::drawing::rectangle::y ( ) const
noexcept

Gets the y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.

Returns
The y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::y property will also cause a change in the xtd::drawing::rectangle::bottom property of the xtd::drawing::rectangle.

◆ y() [2/2]

void xtd::drawing::rectangle::y ( int32_t  value)
noexcept

Sets the y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.

Parameters
valueThe y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure. The default is 0.
Remarks
Changing the xtd::drawing::rectangle::y property will also cause a change in the xtd::drawing::rectangle::bottom property of the xtd::drawing::rectangle.

Member Data Documentation

◆ empty

const rectangle xtd::drawing::rectangle::empty
static

Represents a xtd::drawing::rectangle that has xtd::drawing::rectagle::x, xtd::drawing::rectangle::y, xtd::drawing::rectangle::width and xtd::drawing::rectangle::height values set to zero.


The documentation for this class was generated from the following file: