xtd 1.0.0
Loading...
Searching...
No Matches
xtd::drawing::point Struct Reference
Inheritance diagram for xtd::drawing::point:
xtd::object xtd::iequatable< point > xtd::interface xtd::extensions::equality_operators< point, iequatable< point > >

Definition

Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane.

Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
point() noexcept=default
Initializes a new instance of the xtd::drawing::point class.
Inheritance
xtd::objectxtd::drawing::point
Namespace
xtd::drawing
Library
xtd.drawing
Remarks
To convert a point to a point_f, use Implicit cast operator.
Examples
void create_points_and_sizes(paint_event_args& e) {
// Create the starting point.
point start_point = subtract_button.size();
// Use the addition operator to get the end point.
point end_point = start_point + size(140, 150);
// Draw a line between the points.
e.graphics().draw_line(system_pens::highlight, start_point, end_point);
// Convert the starting point to a size and compare it to the subtractButton size.
size button_size(start_point);
if (button_size == subtract_button.size()) {
// If the sizes are equal, tell the user.
e.graphics().draw_string("The sizes are equal.", font(font, font_style.italic), brushes::indigo, 10.0F, 65.0F);
}
}
static auto indigo() -> xtd::drawing::solid_brush
A system-defined brush object.
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
static auto highlight() -> xtd::drawing::pen
Gets a pen that is the color of the highlight.
font_style
Specifies style information applied to text. This enumeration has a flags attribute that allows a bit...
Definition font_style.hpp:17
@ e
The E key.
Definition console_key.hpp:96
constexpr auto size() const noexcept -> size_type
Returns the number of elements.
Definition read_only_span.hpp:217
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:32
Examples
buttons.cpp, form_paint.cpp, graphics.cpp, point.cpp, and tutorial_button.cpp.

Public Fields

static const point empty
 Represents a xtd::drawing::point that has xtd::drawing::point::x and xtd::drawing::point::y values set to zero.

Public Properties

xtd::int32 x
 Gets or sets the x-coordinate of this xtd::drawing::point.
xtd::int32 y
 Gets or sets the y-coordinate of this xtd::drawing::point.
auto is_empty () const noexcept -> bool
 Gets a value indicating whether this xtd::drawing::point is empty.

Public Constructors

 point () noexcept=default
 Initializes a new instance of the xtd::drawing::point class.
 point (int32 dw) noexcept
 Initializes a new instance of the xtd::drawing::point class using coordinates specified by an integer value.
 point (xtd::int32 x, xtd::int32 y) noexcept
 Initializes a new instance of the xtd::drawing::point class with the specified coordinates.
 point (const size &sz) noexcept
 Initializes a new instance of the xtd::drawing::point class from a xtd::drawing::size.

Public Methods

auto equals (const xtd::object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto equals (const point &other) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.
auto offset (xtd::int32 dx, xtd::int32 dy) noexcept -> void
 Translates this xtd::drawing::point by the specified amount.
auto offset (const point &p) noexcept -> void
 Translates this xtd::drawing::point by the specified xtd::drawing::point.
auto to_string () const noexcept -> xtd::string override
 Converts this point to a human-readable string.

Operators

auto operator+ (const xtd::drawing::size &sz) const noexcept -> point
 Translates a xtd::drawing::point by a given xtd::drawing::size.
auto operator+ (const point &pt) const noexcept -> point
 Translates a xtd::drawing::point by a given xtd::drawing::point.
auto operator+= (const xtd::drawing::size &sz) noexcept -> point &
 Translates a xtd::drawing::point by a given xtd::drawing::size.
auto operator+= (const point &pt) noexcept -> point &
 Translates a xtd::drawing::point by a given xtd::drawing::point.
auto operator- (const xtd::drawing::size &sz) const noexcept -> point
 Translates a xtd::drawing::point by the negative of a given xtd::drawing::size.
auto operator- (const point &pt) const noexcept -> point
 Translates a xtd::drawing::point by the negative of a given xtd::drawing::point.
auto operator-= (const xtd::drawing::size &sz) noexcept -> point &
 Translates a xtd::drawing::point by the negative of a given xtd::drawing::size.
auto operator-= (const point &pt) noexcept -> point &
 Translates a xtd::drawing::point by the negative of a given xtd::drawing::point.

Public Static Methods

static auto add (const point &pt, const xtd::drawing::size &sz) noexcept -> point
 Adds the specified xtd::drawing::size to the specified xtd::drawing::point.
static auto add (const point &pt1, const point &pt2) noexcept -> point
 Adds the specified xtd::drawing::point to the specified xtd::drawing::point.
static auto ceiling (const xtd::drawing::point_f &value) noexcept -> point
 Converts the specified xtd::drawing::point_f to a point by rounding the values of the xtd::drawing::point_f to the next higher integer values.
static auto round (const xtd::drawing::point_f &value) noexcept -> point
 Converts the specified xtd::drawing::point_f to a point object by rounding the xtd::drawing::point_f values to the nearest integer.
static auto subtract (const point &pt, const size &sz) noexcept -> point
 Returns the result of subtracting specified xtd::drawing::size from the specified xtd::drawing::point.
static auto subtract (const point &pt1, const point &pt2) noexcept -> point
 Returns the result of subtracting specified xtd::drawing::point from the specified xtd::drawing::point.
static auto truncate (const xtd::drawing::point_f &value) noexcept -> point
 Converts the specified xtd::drawing::point_f to a point by truncating the values of the xtd::drawing::point_f.

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto equals (const point &) const noexcept -> bool=0
 Indicates whether the current object is equal to another object of the same type.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.

Constructor & Destructor Documentation

◆ point() [1/4]

xtd::drawing::point::point ( )
defaultnoexcept

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

Remarks
xtd::drawing::point::x and xtd::drawing::point::y values are set to zero.

◆ point() [2/4]

xtd::drawing::point::point ( int32 dw)
explicitnoexcept

Initializes a new instance of the xtd::drawing::point class using coordinates specified by an integer value.

Parameters
dxA 32-bit integer that specifies the coordinates for the new xtd::drawing::point.
Remarks
The low-order 16 bits of the dw parameter specify the horizontal x-coordinate and the higher 16 bits specify the vertical y-coordinate for the new point.
Examples
The following code example demonstrates how to use the point and size. size constructors and the xtd::drawing::content_alignment enumeration. To run this example, paste this code into a Windows Form (xtd::forms) that contains a label named label1, and call the initialize_label1 method in the form's constructor.
void initialize_label1() {
// Set a border.
label1.border_style = border_style::fixed_single;
// Set the size, constructing a size from two integers.
label1.size(drawing::size(100, 50));
// Set the location, constructing a point from a 32-bit integer
// (using hexadecimal).
label1.location(point(0x280028));
// Set and align the text on the lower-right side of the label.
label1.text_align = content_alignment::bottom_right;
label1.text = "Bottom Right Alignment";
}

◆ point() [3/4]

xtd::drawing::point::point ( xtd::int32 x,
xtd::int32 y )
noexcept

Initializes a new instance of the xtd::drawing::point class with the specified coordinates.

Parameters
xThe horizontal position of the point.
yThe vertical position of the point.
Examples
The following code example demonstrates how to use the Equality operator and how to construct a point from a size or two integers. It also demonstrates how to use the x and y properties. This example is designed to be used with Windows Forms (xtd.forms). Paste the code into a form that contains a button named button1, and associate the button1_click method with the button's click event.
void button1_click(object& sender, const event_args& e) {
// Construct a new point with integers.
point point1(100, 100);
// Create a Graphics object.
graphics form_graphics = create_graphics();
// Construct another point, this time using a xtd::drawing::size.
point point2(size(100, 100));
// Call the equality operator to see if the points are equal, and if so print out their x and y values.
if (point1 == point2) {
form_graphics.draw_string(string::format("point1.x: {}, point2.x: {}, point1.y: {}, point2.y {}", point1.x(), point2.x(), point1.y(), point2.y()), font(), brushes::black, point_f(10, 70));
}
}
static auto black() -> xtd::drawing::solid_brush
A system-defined brush object.
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.hpp:67
auto draw_string(const xtd::string &s, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &layout_rectangle) -> void
Draws the specified text string at the specified rectangle with the specified xtd::drawing::brush and...
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.hpp:35

◆ point() [4/4]

xtd::drawing::point::point ( const size & sz)
explicitnoexcept

Initializes a new instance of the xtd::drawing::point class from a xtd::drawing::size.

Parameters
szA size that specifies the coordinates for the new point.
Examples
The following code example demonstrates how to use the Equality operator and how to construct a point from a size or two integers. It also demonstrates how to use the x and y properties. This example is designed to be used with Windows Forms (xtd.forms). Paste the code into a form that contains a button named button1, and associate the button1_click method with the button's click event.
void button1_click(object& sender, const event_args& e) {
// Construct a new point with integers.
point point1(100, 100);
// Create a Graphics object.
graphics form_graphics = create_graphics();
// Construct another point, this time using a xtd::drawing::size.
point point2(size(100, 100));
// Call the equality operator to see if the points are equal, and if so print out their x and y values.
if (point1 == point2) {
form_graphics.draw_string(string::format("point1.x: {}, point2.x: {}, point1.y: {}, point2.y {}", point1.x(), point2.x(), point1.y(), point2.y()), font(), brushes::black, point_f(10, 70));
}
}

Member Function Documentation

◆ is_empty()

auto xtd::drawing::point::is_empty ( ) const -> bool
nodiscardnoexcept

Gets a value indicating whether this xtd::drawing::point is empty.

Returns
true if both xtd::drawing::point::x and xtd::drawing::point::y are 0; otherwise, false.

◆ equals() [1/2]

auto xtd::drawing::point::equals ( const xtd::object & obj) const -> bool
nodiscardoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

auto xtd::drawing::point::equals ( const point & other) const -> bool
nodiscardoverridenoexcept

Determines whether the specified object is equal to the current object.

Parameters
otherThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

◆ get_hash_code()

auto xtd::drawing::point::get_hash_code ( ) const -> xtd::usize
nodiscardoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
A hash code for the current object.

Reimplemented from xtd::object.

◆ offset() [1/2]

auto xtd::drawing::point::offset ( xtd::int32 dx,
xtd::int32 dy ) -> void
noexcept

Translates this xtd::drawing::point by the specified amount.

Parameters
dxThe amount to offset the x-coordinate.
dyThe amount to offset the y-coordinate.

◆ offset() [2/2]

auto xtd::drawing::point::offset ( const point & p) -> void
noexcept

Translates this xtd::drawing::point by the specified xtd::drawing::point.

Parameters
pThe xtd::drawing::point used offset this xtd::drawing::point.
Remarks
This method adjusts the xtd::drawing::point::x and xtd::drawing::point::y values of this xtd::drawing::point to the sum of the xtd::drawing::point::x and xtd::drawing::point::y values of this xtd::drawing::point and p.
Examples
The following example shows how to use the Offset method. To run this example, paste it into a Windows Form. Handle the form's xtd::forms::control::paint event and call the Offsetpoint method from the xtd::forms::control::paint event-handling method, passing e as xtd::forms::paint_event_args.
void offset_point(paint_event_args& e) {
point point1(10, 10);
point1.offset(50, 0);
point point2(250, 10);
e.graphics().draw_line(pens::red, point1, point2);
}
static auto red() -> xtd::drawing::pen
A system-defined pen object with a width of 1.

◆ to_string()

auto xtd::drawing::point::to_string ( ) const -> xtd::string
nodiscardoverridevirtualnoexcept

Converts this point to a human-readable string.

Returns
An xtd::string that represents this xtd::drawing::point.

Reimplemented from xtd::object.

◆ add() [1/2]

auto xtd::drawing::point::add ( const point & pt,
const xtd::drawing::size & sz ) -> point
staticnodiscardnoexcept

Adds the specified xtd::drawing::size to the specified xtd::drawing::point.

Parameters
ptThe xtd::drawing::point to add.
szThe xtd::drawing::size to add.
Returns
The xtd::drawing::point that is the result of the addition operation.
Remarks
The xtd::drawing::point::add adds the xtd::drawing::size::width and xtd::drawing::size::height of the specified size to the xtd::drawing::point::x and xtd::drawing::point::y values of the specified xtd::drawing::point.
Examples
The following example shows how to use the add method. To run this example, paste it into a Windows Form (xtd::forms. Handle the form's xtd::forms::control::paint event and call the add_point method from the paint event-handling method, passing e as paint_event_args.
void add_point(paint_event_args& e) {
point point1(10, 10);
point point2 = point::add(point1, drawing::size(250,0));
e.graphics().draw_line(pens::red, point1, point2);
}
static auto add(const point &pt, const xtd::drawing::size &sz) noexcept -> point
Adds the specified xtd::drawing::size to the specified xtd::drawing::point.

◆ add() [2/2]

auto xtd::drawing::point::add ( const point & pt1,
const point & pt2 ) -> point
staticnodiscardnoexcept

Adds the specified xtd::drawing::point to the specified xtd::drawing::point.

Parameters
pt1The xtd::drawing::point to add.
pt2The xtd::drawing::point to add.
Returns
The xtd::drawing::point that is the result of the addition operation.

◆ ceiling()

auto xtd::drawing::point::ceiling ( const xtd::drawing::point_f & value) -> point
staticnodiscardnoexcept

Converts the specified xtd::drawing::point_f to a point by rounding the values of the xtd::drawing::point_f to the next higher integer values.

Parameters
valueThe xtd::drawing::point_f to convert.
Returns
The xtd::drawing::point this method converts to.

◆ round()

auto xtd::drawing::point::round ( const xtd::drawing::point_f & value) -> point
staticnodiscardnoexcept

Converts the specified xtd::drawing::point_f to a point object by rounding the xtd::drawing::point_f values to the nearest integer.

Parameters
valueThe xtd::drawing::point_f to convert.
Returns
The xtd::drawing::point this method converts to.

◆ subtract() [1/2]

auto xtd::drawing::point::subtract ( const point & pt,
const size & sz ) -> point
staticnodiscardnoexcept

Returns the result of subtracting specified xtd::drawing::size from the specified xtd::drawing::point.

Parameters
ptThe xtd::drawing::point to be subtracted from.
szThe xtd::drawing::size to subtract from the xtd::drawing::point.
Returns
The xtd::drawing::point that is the result of the subtraction operation.
Remarks
The xtd::drawing::point::subtract subtracts the xtd::drawing::size::width and xtd::drawing::size::height of the specified xtd::drawing::size from the xtd::drawing::point::x and xtd::drawing::point::y values of the specified xtd::drawing::point.

◆ subtract() [2/2]

auto xtd::drawing::point::subtract ( const point & pt1,
const point & pt2 ) -> point
staticnodiscardnoexcept

Returns the result of subtracting specified xtd::drawing::point from the specified xtd::drawing::point.

Parameters
pt1The xtd::drawing::point to be subtracted from.
pt2The xtd::drawing::point to subtract from the xtd::drawing::point.
Returns
The xtd::drawing::point that is the result of the subtraction operation.

◆ truncate()

auto xtd::drawing::point::truncate ( const xtd::drawing::point_f & value) -> point
staticnodiscardnoexcept

Converts the specified xtd::drawing::point_f to a point by truncating the values of the xtd::drawing::point_f.

Parameters
valueThe xtd::drawing::point_f to convert.
Returns
The xtd::drawing::point this method converts to.

◆ operator+() [1/2]

auto xtd::drawing::point::operator+ ( const xtd::drawing::size & sz) const -> point
noexcept

Translates a xtd::drawing::point by a given xtd::drawing::size.

Parameters
szA xtd::drawing::size that specifies the pair of numbers to add to the coordinates of this xtd::drawing::point.
Returns
The translated xtd::drawing::point.

◆ operator+() [2/2]

auto xtd::drawing::point::operator+ ( const point & pt) const -> point
noexcept

Translates a xtd::drawing::point by a given xtd::drawing::point.

Parameters
ptA xtd::drawing::point that specifies the pair of numbers to add to the coordinates of this xtd::drawing::point.
Returns
The translated xtd::drawing::point.

◆ operator+=() [1/2]

auto xtd::drawing::point::operator+= ( const xtd::drawing::size & sz) -> point &
noexcept

Translates a xtd::drawing::point by a given xtd::drawing::size.

Parameters
szA xtd::drawing::size that specifies the pair of numbers to add to the coordinates of this xtd::drawing::point.
Returns
The translated xtd::drawing::point.

◆ operator+=() [2/2]

auto xtd::drawing::point::operator+= ( const point & pt) -> point &
noexcept

Translates a xtd::drawing::point by a given xtd::drawing::point.

Parameters
ptA xtd::drawing::point that specifies the pair of numbers to add to the coordinates of this xtd::drawing::point.
Returns
The translated xtd::drawing::point.

◆ operator-() [1/2]

auto xtd::drawing::point::operator- ( const xtd::drawing::size & sz) const -> point
noexcept

Translates a xtd::drawing::point by the negative of a given xtd::drawing::size.

Parameters
szA xtd::drawing::size that specifies the pair of numbers to subtract from the coordinates of this xtd::drawing::point.
Returns
A xtd::drawing::point structure that is translated by the negative of a given xtd::drawing::size structure.

◆ operator-() [2/2]

auto xtd::drawing::point::operator- ( const point & pt) const -> point
noexcept

Translates a xtd::drawing::point by the negative of a given xtd::drawing::point.

Parameters
ptA xtd::drawing::point that specifies the pair of numbers to subtract from the coordinates of this xtd::drawing::point.
Returns
A xtd::drawing::point structure that is translated by the negative of a given xtd::drawing::size structure.

◆ operator-=() [1/2]

auto xtd::drawing::point::operator-= ( const xtd::drawing::size & sz) -> point &
noexcept

Translates a xtd::drawing::point by the negative of a given xtd::drawing::size.

Parameters
szA xtd::drawing::size that specifies the pair of numbers to subtract from the coordinates of this xtd::drawing::point.
Returns
The translated xtd::drawing::point.

◆ operator-=() [2/2]

auto xtd::drawing::point::operator-= ( const point & pt) -> point &
noexcept

Translates a xtd::drawing::point by the negative of a given xtd::drawing::point.

Parameters
ptA xtd::drawing::point that specifies the pair of numbers to subtract from the coordinates of this xtd::drawing::point.
Returns
The translated xtd::drawing::point.

Member Data Documentation

◆ empty

const point xtd::drawing::point::empty
static

Represents a xtd::drawing::point that has xtd::drawing::point::x and xtd::drawing::point::y values set to zero.

◆ x

xtd::int32 xtd::drawing::point::x

Gets or sets the x-coordinate of this xtd::drawing::point.

Parameters
xThe x-coordinate of this xtd::drawing::point.
Examples
The following code example demonstrates how to use the Equality operator and how to construct a point from a size or two integers. It also demonstrates how to use the x and y properties. This example is designed to be used with Windows Forms (xtd.forms). Paste the code into a form that contains a button named button1, and associate the button1_click method with the button's click event.
void button1_click(object& sender, const event_args& e) {
// Construct a new point with integers.
point point1(100, 100);
// Create a Graphics object.
graphics form_graphics = create_graphics();
// Construct another point, this time using a xtd::drawing::size.
point point2(size(100, 100));
// Call the equality operator to see if the points are equal, and if so print out their x and y values.
if (point1 == point2) {
form_graphics.draw_string(string::format("point1.x: {}, point2.x: {}, point1.y: {}, point2.y {}", point1.x(), point2.x(), point1.y(), point2.y()), font(), brushes::black, point_f(10, 70));
}
}

◆ y

xtd::int32 xtd::drawing::point::y

Gets or sets the y-coordinate of this xtd::drawing::point.

Parameters
yThe y-coordinate of this xtd::drawing::point.
Examples
The following code example demonstrates how to use the Equality operator and how to construct a point from a size or two integers. It also demonstrates how to use the x and y properties. This example is designed to be used with Windows Forms (xtd.forms). Paste the code into a form that contains a button named button1, and associate the button1_click method with the button's click event.
void button1_Click(object& sender, const event_args& e) {
// Construct a new point with integers.
point point1(100, 100);
// Create a Graphics object.
graphics form_graphics = create_graphics();
// Construct another point, this time using a xtd::drawing::size.
point point2(size(100, 100));
// Call the equality operator to see if the points are equal, and if so print out their x and y values.
if (point1 == point2) {
form_graphics.draw_string(string::format("point1.x: {}, point2.x: {}, point1.y: {}, point2.y {}", point1.x(), point2.x(), point1.y(), point2.y()), font(), brushes::black, point_f(10, 70));
}
}

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