xtd 0.2.0
Loading...
Searching...
No Matches
xtd::drawing::rectangle Class Reference
Inheritance diagram for xtd::drawing::rectangle:
xtd::object xtd::iequatable< rectangle > xtd::interface xtd::equality_operators< type_t, equatable_t >

Definition

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

Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.h:44
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
#define drawing_export_
Define shared library export.
Definition drawing_export.h:13
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.


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);
static xtd::drawing::color from_argb(uint32 argb) noexcept
Creates a xtd::drawing::color class from a 32-bit ARGB value.
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.h:35
@ e
The E key.
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::drawing_2d::conical_gradient_brush or xtd::drawing::drawing_2d::hatch_gradient_brush or xtd::drawing::drawing_2d::linear_gradient_brush or xtd::drawing::drawing_2d::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
border_style.cpp, draw_image.cpp, fill_ellipse.cpp, fill_rectangle.cpp, fill_rounded_rectangle.cpp, form_paint.cpp, graph_control.cpp, graphics.cpp, image_converter.cpp, minesweeper.cpp, owner_button.cpp, painting.cpp, screen.cpp, and user_control.cpp.

Public Member Functions

void inflate (const drawing::size &sz) noexcept
 Enlarges this xtd::drawing::rectangle by the specified amount.
 
void inflate (int32 width, int32 height) noexcept
 Enlarges this xtd::drawing::rectangle by the specified amount.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::iequatable< rectangle >
virtual bool equals (const rectangle &) const noexcept=0
 Indicates wheth er the current object is equal to another object of the same type.
 

Public 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.
 

Public Constructors

 rectangle () noexcept=default
 Initializes a new instance of the xtd::drawing::rectangle class.
 
 rectangle (int32 x, int32 y, int32 width, int32 height) noexcept
 Initializes a new instance of the xtd::drawing::rectangle class with the specified location and size.
 
 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.
 

Public Properties

int32 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.
 
point center () const noexcept
 Gets the center property values of this xtd::drawing::rectangle structure.
 
int32 height () const noexcept
 Gets the height of this xtd::drawing::rectangle structure.
 
void height (int32 value) noexcept
 Sets the height of this xtd::drawing::rectangle structure.
 
bool is_empty () const noexcept
 Tests whether all numeric properties of this xtd::drawing::rectangle have values of zero.
 
int32 left () const noexcept
 Gets the x-coordinate of the left edge of this xtd::drawing::rectangle structure.
 
xtd::drawing::point location () const noexcept
 Gets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure.
 
void location (const xtd::drawing::point &value) noexcept
 Sets the coordinates of the upper-left corner of this xtd::drawing::rectangle structure.
 
int32 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.
 
xtd::drawing::size size () const noexcept
 Gets the size of this xtd::drawing::rectangle.
 
void size (const xtd::drawing::size &value) noexcept
 Sets the size of this xtd::drawing::rectangle.
 
int32 top () const noexcept
 Gets the y-coordinate of the top edge of this xtd::drawing::rectangle structure.
 
int32 width () const noexcept
 Gets the width of this xtd::drawing::rectangle structure.
 
void width (int32 value) noexcept
 Sets the width of this xtd::drawing::rectangle structure.
 
int32 x () const noexcept
 Gets the x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.
 
void x (int32 value) noexcept
 Sets the x-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.
 
int32 y () const noexcept
 Gets the y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.
 
void y (int32 value) noexcept
 Sets the y-coordinate of the upper-left corner of this xtd::drawing::rectangle structure.
 

Public Methods

void add (const drawing::size &sz) noexcept
 Adds this xtd::drawing::rectangle by the specified amount.
 
void add (int32 width, int32 height) noexcept
 Adds this xtd::drawing::rectangle by the specified amount.
 
bool contains (const xtd::drawing::point &pt) const noexcept
 Determines if the specified point is contained within this xtd::drawing::rectangle structure.
 
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.
 
bool contains (int32 x, int32 y) const noexcept
 Determines if the specified point is contained within this xtd::drawing::rectangle structure.
 
bool equals (const rectangle &value) const noexcept override
 
bool intersects_with (const rectangle &rect) const noexcept
 Determines if this rectangle intersects with rect.
 
void make_intersect (const rectangle &rect) noexcept
 Replaces this xtd::drawing::rectangle with the intersection of itself and the specified xtd::drawing::rectangle.
 
void make_union (const rectangle &rect) noexcept
 Replaces this xtd::drawing::rectangle with the union of itself and the specified xtd::drawing::rectangle.
 
void offset (const point &pos) noexcept
 Adjusts the location of this rectangle by the specified amount.
 
void offset (int32 x, int32 y) noexcept
 Adjusts the location of this rectangle by the specified amount.
 
xtd::string to_string () const noexcept override
 Converts the attributes of this xtd::drawing::rectangle to a human-readable string.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 

Public Static Methods

static rectangle add (const rectangle &rect, int32 x, int32 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.
 
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.
 
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.
 
static rectangle from_ltrb (int32 left, int32 top, int32 right, int32 bottom) noexcept
 Creates a xtd::drawing::rectangle structure with the specified edge locations.
 
static rectangle inflate (const rectangle &rect, int32 x, int32 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.
 
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.
 
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.
 
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.
 
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.
 
static rectangle offset (const rectangle &rect, int32 x, int32 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.
 
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.
 
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.
 

Additional Inherited Members

- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

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