xtd 1.0.0
Loading...
Searching...
No Matches
xtd::drawing::pen Class Referencefinal
Inheritance diagram for xtd::drawing::pen:
xtd::object xtd::iequatable< pen > xtd::interface xtd::extensions::equality_operators< pen, iequatable< pen > >

Definition

Defines an object used to draw lines and curves. This class cannot be inherited.

pen()
Initializes a new instance of the xtd::drawing::pen class with xtd::drawing::color::black and width o...
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
Inheritance
xtd::objectxtd::drawing::pen
Namespace
xtd::drawing
Library
xtd.drawing
Examples
form_paint.cpp, and graphics.cpp.

Public Constructors

 pen ()
 Initializes a new instance of the xtd::drawing::pen class with xtd::drawing::color::black and width of 1 pixel.
template<typename brush_t>
 pen (const brush_t &brush)
 Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.
template<typename brush_t>
 pen (const brush_t &brush, float width)
 Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.
 pen (const xtd::drawing::color &color)
 Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::color.
 pen (const xtd::drawing::color &color, float width)
 Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::color.

Public Properties

auto alignment () const noexcept -> xtd::drawing::drawing_2d::pen_alignment
 Gets the alignment for this xtd::drawing::pen.
auto alignment (xtd::drawing::drawing_2d::pen_alignment value) -> xtd::drawing::pen &
 Sets the alignment for this xtd::drawing::pen.
auto brush () const noexcept -> const xtd::uptr< xtd::drawing::brush > &
 Gets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
template<typename brush_t>
auto brush (const brush_t &value) -> xtd::drawing::pen &
 Sets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
auto color () const noexcept -> const xtd::drawing::color &
 Gets the color of this xtd::drawing::pen.
auto color (const xtd::drawing::color &value) -> xtd::drawing::pen &
 Sets the color of this xtd::drawing::pen.
auto dash_pattern () const noexcept -> xtd::array< float >
 Gets an array of custom dashes and spaces.
auto dash_pattern (const xtd::array< float > &value) -> xtd::drawing::pen &
 Sets an array of custom dashes and spaces.
auto dash_style () const noexcept -> xtd::drawing::drawing_2d::dash_style
 Gets the style used for dashed lines drawn with this xtd::drawing::pen.
auto dash_style (drawing::drawing_2d::dash_style value) -> xtd::drawing::pen &
 Sets the style used for dashed lines drawn with this xtd::drawing::pen.
auto end_cap () const noexcept -> xtd::drawing::drawing_2d::line_cap
 Gets the cap style used at the end of lines drawn with this xtd::drawing::pen.
auto end_cap (xtd::drawing::drawing_2d::line_cap value) -> xtd::drawing::pen &
 Sets the cap style used at the end of lines drawn with this xtd::drawing::pen.
auto handle () const noexcept -> xtd::intptr
 Gets the handle of the pen.
auto line_join () const noexcept -> xtd::drawing::drawing_2d::line_join
 Gets the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.
auto line_join (xtd::drawing::drawing_2d::line_join value) -> xtd::drawing::pen &
 Sets the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.
float miter_limit () const noexcept
 Gets the limit of the thickness of the join on a mitered corner.
auto miter_limit (float value) -> xtd::drawing::pen &
 Sets the limit of the thickness of the join on a mitered corner.
auto start_cap () const noexcept -> xtd::drawing::drawing_2d::line_cap
 Gets the cap style used at the beginning of lines drawn with this xtd::drawing::pen.
auto start_cap (xtd::drawing::drawing_2d::line_cap value) -> xtd::drawing::pen &
 Sets the cap style used at the beginning of lines drawn with this xtd::drawing::pen.
auto type () const noexcept -> xtd::drawing::drawing_2d::pen_type
 Gets the style of lines drawn with this xtd::drawing::pen.
auto width () const noexcept -> float
 Gets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for drawing.
auto width (float value) -> xtd::drawing::pen &
 Sets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for drawing.

Public Methods

auto equals (const object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto equals (const xtd::drawing::pen &other) const noexcept -> bool override
 Indicates whether the current object is equal to another object of the same type.
auto get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.
auto to_string () const noexcept -> xtd::string override
 Returns a xtd::string that represents the current object.

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 pen &) 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

◆ pen() [1/5]

xtd::drawing::pen::pen ( )

Initializes a new instance of the xtd::drawing::pen class with xtd::drawing::color::black and width of 1 pixel.

◆ pen() [2/5]

template<typename brush_t>
xtd::drawing::pen::pen ( const brush_t & brush)
inlineexplicit

Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.

Parameters
brushA xtd::drawing::brush that determines the fill properties of this xtd::drawing::pen.
Remarks
The brush property determines how the xtd::drawing::pen draws lines. Lines are drawn as if they are filled rectangles, with the characteristics of the specified brush.
The width property of the new xtd::drawing::pen is set to 1 (the default).

◆ pen() [3/5]

template<typename brush_t>
xtd::drawing::pen::pen ( const brush_t & brush,
float width )
inline

Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::brush.

Parameters
brushA xtd::drawing::brush that determines the fill properties of this xtd::drawing::pen.
widthA single number that represent the pen width.
Remarks
The brush property determines how the xtd::drawing::pen draws lines. Lines are drawn as if they are filled rectangles, with the characteristics of the specified brush.
The width property of the new xtd::drawing::pen is set to 1 (the default).

◆ pen() [4/5]

xtd::drawing::pen::pen ( const xtd::drawing::color & color)
explicit

Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::color.

Parameters
colorA xtd::drawing::color structure that indicates the color of this xtd::drawing::pen.
Remarks
The color property is set to the color specified by the color parameter. The width property is set to 1 (the default).

◆ pen() [5/5]

xtd::drawing::pen::pen ( const xtd::drawing::color & color,
float width )

Initializes a new instance of the xtd::drawing::pen class with the specified xtd::drawing::color.

Parameters
colorA xtd::drawing::color structure that indicates the color of this xtd::drawing::pen.
widthA single number that represent the pen width.
Remarks
The color property is set to the color specified by the color parameter. The width property is set to 1 (the default).

Member Function Documentation

◆ alignment() [1/2]

auto xtd::drawing::pen::alignment ( ) const -> xtd::drawing::drawing_2d::pen_alignment
nodiscardnoexcept

Gets the alignment for this xtd::drawing::pen.

Returns
A xtd::drawing::drawing_2d::pen_alignment that represents the alignment for this xtd::drawing::pen.
Remarks
This property determines how the xtd::drawing::pen draws closed curves and polygons. The xtd::drawing_2d::pen_alignment enumeration specifies five values; however, only two values - xtd::drawing_2d::pen_alignment::center and xtd::drawing_2d::pen_alignment::inset - will change the appearance of a drawn line. xtd::drawing_2d::pen_alignment::center is the default value for this property and specifies that the width of the pen is centered on the outline of the curve or polygon. A value of xtd::drawing_2d::pen_alignment::inset for this property specifies that the width of the pen is inside the outline of the curve or polygon. The other three values, xtd::drawing_2d::pen_alignment::right, xtd::drawing_2d::pen_alignment::left, and xtd::drawing_2d::pen_alignment::outset, will result in a pen that is centered.

◆ alignment() [2/2]

auto xtd::drawing::pen::alignment ( xtd::drawing::drawing_2d::pen_alignment value) -> xtd::drawing::pen &

Sets the alignment for this xtd::drawing::pen.

Parameters
valueA xtd::drawing::drawing_2d::pen_alignment that represents the alignment for this xtd::drawing::pen.
Remarks
This property determines how the xtd::drawing::pen draws closed curves and polygons. The xtd::drawing::drawing_2d::pen_alignment enumeration specifies five values; however, only two values - xtd::drawing::drawing_2d::pen_alignment::center and xtd::drawing::drawing_2d::pen_alignment::inset - will change the appearance of a drawn line. xtd::drawing::drawing_2d::pen_alignment::center is the default value for this property and specifies that the width of the pen is centered on the outline of the curve or polygon. A value of xtd::drawing::drawing_2d::pen_alignment::inset for this property specifies that the width of the pen is inside the outline of the curve or polygon. The other three values, xtd::drawing::drawing_2d::pen_alignment::right, xtd::drawing::drawing_2d::pen_alignment::left, and xtd::drawing::drawing_2d::pen_alignment::outset, will result in a pen that is centered.

◆ brush() [1/2]

auto xtd::drawing::pen::brush ( ) const -> const xtd::uptr< xtd::drawing::brush > &
nodiscardnoexcept

Gets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.

Returns
A Brush that determines attributes of this xtd::drawing::pen.
Remarks
Assigning this property causes the pen to draw filled lines and curves. It overrides thextd::drawing::pen::color property of the xtd::drawing::pen.

◆ brush() [2/2]

template<typename brush_t>
auto xtd::drawing::pen::brush ( const brush_t & value) -> xtd::drawing::pen &
inline

Sets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.

Parameters
valueA xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
Remarks
Assigning this property causes the pen to draw filled lines and curves. It overrides thextd::drawing::pen::color property of the xtd::drawing::pen.

◆ color() [1/2]

auto xtd::drawing::pen::color ( ) const -> const xtd::drawing::color &
nodiscardnoexcept

Gets the color of this xtd::drawing::pen.

Returns
A xtd::drawing::color structure that represents the color of this xtd::drawing::pen.

◆ color() [2/2]

auto xtd::drawing::pen::color ( const xtd::drawing::color & value) -> xtd::drawing::pen &

Sets the color of this xtd::drawing::pen.

Parameters
valueA xtd::drawing::color structure that represents the color of this xtd::drawing::pen.
Returns
This current instance.

◆ dash_pattern() [1/2]

auto xtd::drawing::pen::dash_pattern ( ) const -> xtd::array< float >
nodiscardnoexcept

Gets an array of custom dashes and spaces.

Returns
An array of real numbers that specifies the lengths of alternating dashes and spaces in dashed lines.
Remarks
Assigning a value other than empty to this property will set the xtd::drawing::pen::dash_style property for this xtd::drawing::pen to xtd::drawing:drawing_2d::dash_style::custom.
The elements in the dash_pattern array set the length of each dash and space in the dash pattern. The first element sets the length of a dash, the second element sets the length of a space, the third element sets the length of a dash, and so on. Consequently, each element should be a non-zero positive number.
The length of each dash and space in the dash pattern is the product of the element value in the array and the width of the xtd::drawing::pen.

◆ dash_pattern() [2/2]

auto xtd::drawing::pen::dash_pattern ( const xtd::array< float > & value) -> xtd::drawing::pen &

Sets an array of custom dashes and spaces.

Parameters
valueAn array of real numbers that specifies the lengths of alternating dashes and spaces in dashed lines.
Remarks
Assigning a value other than empty to this property will set the xtd::drawing::pen::dash_style property for this xtd::drawing::pen to xtd::drawing:drawing_2d::dash_style::custom.
The elements in the dash_pattern array set the length of each dash and space in the dash pattern. The first element sets the length of a dash, the second element sets the length of a space, the third element sets the length of a dash, and so on. Consequently, each element should be a non-zero positive number.
The length of each dash and space in the dash pattern is the product of the element value in the array and the width of the xtd::drawing::pen.

◆ dash_style() [1/2]

auto xtd::drawing::pen::dash_style ( ) const -> xtd::drawing::drawing_2d::dash_style
nodiscardnoexcept

Gets the style used for dashed lines drawn with this xtd::drawing::pen.

Returns
A xtd::drawing::drawing_2d::dash_style that represents the style used for dashed lines drawn with this xtd::drawing::pen.
Remarks
A value of xtd::drawing::drawing_2d::dash_style::custom for this property specifies that a custom pattern of dashes and spaces, defined by the xtd::drawing::pendash_pattern property, makes up lines drawn with this xtd::drawing::pen. If the value of this property is xtd::drawing::drawing_2d::dash_style::custom and the value of the xtd::drawing::pen::dash_pattern property is empty, the pen draws solid lines.

◆ dash_style() [2/2]

auto xtd::drawing::pen::dash_style ( drawing::drawing_2d::dash_style value) -> xtd::drawing::pen &

Sets the style used for dashed lines drawn with this xtd::drawing::pen.

Parameters
valueA xtd::drawing::drawing_2d::dash_style that represents the style used for dashed lines drawn with this xtd::drawing::pen.
Returns
This current instance.
Remarks
A value of xtd::drawing::drawing_2d::dash_style::custom for this property specifies that a custom pattern of dashes and spaces, defined by the xtd::drawing::pendash_pattern property, makes up lines drawn with this xtd::drawing::pen. If the value of this property is xtd::drawing::drawing_2d::dash_style::custom and the value of the xtd::drawing::pen::dash_pattern property is empty, the pen draws solid lines.

◆ end_cap() [1/2]

auto xtd::drawing::pen::end_cap ( ) const -> xtd::drawing::drawing_2d::line_cap
nodiscardnoexcept

Gets the cap style used at the end of lines drawn with this xtd::drawing::pen.

Returns
One of the xtd::drawing::drawing_2d::line_cap values that represents the cap style used at the end of lines drawn with this xtd::drawing::pen.

◆ end_cap() [2/2]

auto xtd::drawing::pen::end_cap ( xtd::drawing::drawing_2d::line_cap value) -> xtd::drawing::pen &

Sets the cap style used at the end of lines drawn with this xtd::drawing::pen.

Parameters
valueOne of the xtd::drawing::drawing_2d::line_cap values that represents the cap style used at the end of lines drawn with this xtd::drawing::pen.
Returns
This current instance.

◆ handle()

auto xtd::drawing::pen::handle ( ) const -> xtd::intptr
nodiscardnoexcept

Gets the handle of the pen.

Returns
An intptr that contains the handle of the pen.

◆ line_join() [1/2]

auto xtd::drawing::pen::line_join ( ) const -> xtd::drawing::drawing_2d::line_join
nodiscardnoexcept

Gets the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.

Returns
A xtd::drawing::drawing_2d::line_join that represents the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.
Remarks
A line join is the common area that is formed by two lines whose ends meet or overlap. There are three line join styles: miter, bevel, and round. When you specify a line join style for a xtd::drawing::pen object, that join style will be applied to all the connected lines in any xtd::drawing::drawing_2d::graphics_path object drawn using that pen. The following illustration shows the results of the beveled line join example.

◆ line_join() [2/2]

auto xtd::drawing::pen::line_join ( xtd::drawing::drawing_2d::line_join value) -> xtd::drawing::pen &

Sets the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.

Parameters
valueA xtd::drawing::drawing_2d::line_join that represents the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.
Returns
This current instance.
Remarks
A line join is the common area that is formed by two lines whose ends meet or overlap. There are three line join styles: miter, bevel, and round. When you specify a line join style for a xtd::drawing::pen object, that join style will be applied to all the connected lines in any xtd::drawing::drawing_2d::graphics_path object drawn using that pen. The following illustration shows the results of the beveled line join example.

◆ miter_limit() [1/2]

float xtd::drawing::pen::miter_limit ( ) const
nodiscardnoexcept

Gets the limit of the thickness of the join on a mitered corner.

Returns
The limit of the thickness of the join on a mitered corner.
Remarks
The miter length is the distance from the intersection of the line walls on the inside of the join to the intersection of the line walls outside of the join. The miter length can be large when the angle between two lines is small. The miter limit is the maximum allowed ratio of miter length to stroke width. The default value is 10.0f.
If the miter length of the join of the intersection exceeds the limit of the join, then the join will be beveled to keep it within the limit of the join of the intersection.

◆ miter_limit() [2/2]

auto xtd::drawing::pen::miter_limit ( float value) -> xtd::drawing::pen &

Sets the limit of the thickness of the join on a mitered corner.

Parameters
valueThe limit of the thickness of the join on a mitered corner.
Returns
This current instance.
Remarks
The miter length is the distance from the intersection of the line walls on the inside of the join to the intersection of the line walls outside of the join. The miter length can be large when the angle between two lines is small. The miter limit is the maximum allowed ratio of miter length to stroke width. The default value is 10.0f.
If the miter length of the join of the intersection exceeds the limit of the join, then the join will be beveled to keep it within the limit of the join of the intersection.

◆ start_cap() [1/2]

auto xtd::drawing::pen::start_cap ( ) const -> xtd::drawing::drawing_2d::line_cap
nodiscardnoexcept

Gets the cap style used at the beginning of lines drawn with this xtd::drawing::pen.

Returns
One of the xtd::drawing::drawing_2d::line_cap values that represents the cap style used at the beginning of lines drawn with this xtd::drawing::pen.

◆ start_cap() [2/2]

auto xtd::drawing::pen::start_cap ( xtd::drawing::drawing_2d::line_cap value) -> xtd::drawing::pen &

Sets the cap style used at the beginning of lines drawn with this xtd::drawing::pen.

Parameters
valueOne of the xtd::drawing::drawing_2d::line_cap values that represents the cap style used at the beginning of lines drawn with this xtd::drawing::pen.
Returns
This current instance.

◆ type()

auto xtd::drawing::pen::type ( ) const -> xtd::drawing::drawing_2d::pen_type
nodiscardnoexcept

Gets the style of lines drawn with this xtd::drawing::pen.

Returns
A xtd::drawing::drawing_2d::pen_type enumeration that specifies the style of lines drawn with this xtd::drawing::pen.
Remarks
A xtd::drawing::pen can draw solid lines, filled lines, or textured lines, depending on the style specified by a member of the PenType enumeration.

◆ width() [1/2]

auto xtd::drawing::pen::width ( ) const -> float
nodiscardnoexcept

Gets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for drawing.

Returns
The width of this xtd::drawing::pen.
Remarks
You can access the unit of measure of the xtd::drawing::graphics object using its xtd::drawing::graphics::page_unit property. The unit of measure is typically pixels. A Width of 0 will result in the xtd::drawing::pen drawing as if the xtd::drawing::pen::width were 1.
Examples
graphics.cpp.

◆ width() [2/2]

auto xtd::drawing::pen::width ( float value) -> xtd::drawing::pen &

Sets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for drawing.

Parameters
valueThe width of this xtd::drawing::pen.
Returns
This current instance.
Remarks
You can access the unit of measure of the xtd::drawing::graphics object using its xtd::drawing::graphics::page_unit property. The unit of measure is typically pixels. A Width of 0 will result in the xtd::drawing::pen drawing as if the xtd::drawing::pen::width were 1.

◆ equals() [1/2]

auto xtd::drawing::pen::equals ( const 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::pen::equals ( const xtd::drawing::pen & other) const -> bool
nodiscardoverridenoexcept

Indicates whether the current object is equal to another object of the same type.

Parameters
otherAn object to compare with this object.
Returns
true if the current object is equal to the other parameter; otherwise, false.

◆ get_hash_code()

auto xtd::drawing::pen::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.

◆ to_string()

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

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.
Examples
The following code example demonstrates what to_string returns.
#include <xtd/xtd>
namespace examples {
namespace object_test {
class object1 : public object {
};
}
}
auto main() -> int {
ptr<object> obj1 = new_ptr<examples::object_test::object1>();
console::write_line(obj1->to_string());
ptr<object> obj2 = new_ptr<date_time>(1971, 1, 5, 23, 5, 0);
console::write_line(obj2->to_string());
ptr<object> obj3 = new_ptr<boolean_object>();
console::write_line(obj3->to_string());
}
// This code produces the following output :
//
// examples::object_test::object1
// Tue Jan 5 23:05:00 1971
// false
object()=default
Create a new instance of the ultimate base class object.

Reimplemented from xtd::object.


The documentation for this class was generated from the following file:
  • xtd.drawing/include/xtd/drawing/pen.hpp