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

Definition

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

Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.hpp:35
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
Inheritance
xtd::objectxtd::drawing::pen
Namespace
xtd::drawing
Library
xtd.drawing
Examples
animation.cpp, draw_ellipse.cpp, draw_line.cpp, draw_point.cpp, draw_rectangle.cpp, draw_rounded_rectangle.cpp, fill_ellipse.cpp, fill_rectangle.cpp, fill_rounded_rectangle.cpp, form_paint.cpp, graph_control.cpp, graphics.cpp, minesweeper.cpp, owner_button.cpp, and user_control.cpp.

Public Constructors

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

xtd::drawing::drawing_2d::pen_alignment alignment () const noexcept
 Gets the alignment for this xtd::drawing::pen.
 
xtd::drawing::penalignment (xtd::drawing::drawing_2d::pen_alignment value)
 Sets the alignment for this xtd::drawing::pen.
 
const xtd::uptr< xtd::drawing::brush > & brush () const noexcept
 Gets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
 
template<typename brush_t >
xtd::drawing::penbrush (const brush_t &value)
 Sets the xtd::drawing::brush that determines attributes of this xtd::drawing::pen.
 
const xtd::drawing::colorcolor () const noexcept
 Gets the color of this xtd::drawing::pen.
 
xtd::drawing::pencolor (const xtd::drawing::color &value)
 Sets the color of this xtd::drawing::pen.
 
std::vector< float > dash_pattern () const noexcept
 Gets an array of custom dashes and spaces.
 
xtd::drawing::pendash_pattern (const std::vector< float > &value)
 Sets an array of custom dashes and spaces.
 
xtd::drawing::drawing_2d::dash_style dash_style () const noexcept
 Gets the style used for dashed lines drawn with this xtd::drawing::pen.
 
xtd::drawing::pendash_style (drawing::drawing_2d::dash_style value)
 Sets the style used for dashed lines drawn with this xtd::drawing::pen.
 
xtd::drawing::drawing_2d::line_cap end_cap () const noexcept
 Gets the cap style used at the end of lines drawn with this xtd::drawing::pen.
 
xtd::drawing::penend_cap (xtd::drawing::drawing_2d::line_cap value)
 Sets the cap style used at the end of lines drawn with this xtd::drawing::pen.
 
intptr handle () const noexcept
 Gets the handle of the pen.
 
xtd::drawing::drawing_2d::line_join line_join () const noexcept
 Gets the join style for the ends of two consecutive lines drawn with this xtd::drawing::pen.
 
xtd::drawing::penline_join (xtd::drawing::drawing_2d::line_join value)
 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.
 
xtd::drawing::penmiter_limit (float value)
 Sets the limit of the thickness of the join on a mitered corner.
 
xtd::drawing::drawing_2d::line_cap start_cap () const noexcept
 Gets the cap style used at the beginning of lines drawn with this xtd::drawing::pen.
 
xtd::drawing::penstart_cap (xtd::drawing::drawing_2d::line_cap value)
 Sets the cap style used at the beginning of lines drawn with this xtd::drawing::pen.
 
xtd::drawing::drawing_2d::pen_type type () const noexcept
 Gets the style of lines drawn with this xtd::drawing::pen.
 
float width () const noexcept
 Gets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for drawing.
 
xtd::drawing::penwidth (float value)
 Sets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for drawing.
 

Public Methods

bool equals (const xtd::drawing::pen &value) const noexcept override
 
xtd::string to_string () const noexcept override
 Returns a xtd::string that represents the current object.
 
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.
 

Additional Inherited Members

- 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< pen >
virtual bool equals (const pen &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 
- 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.
 

Constructor & Destructor Documentation

◆ pen() [1/4]

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() [2/4]

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() [3/4]

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() [4/4]

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]

xtd::drawing::drawing_2d::pen_alignment xtd::drawing::pen::alignment ( ) const
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::alignment ( xtd::drawing::drawing_2d::pen_alignment  value)

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]

const xtd::uptr< xtd::drawing::brush > & xtd::drawing::pen::brush ( ) const
noexcept

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 >
xtd::drawing::pen & xtd::drawing::pen::brush ( const brush_t &  value)
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]

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

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]

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

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]

std::vector< float > xtd::drawing::pen::dash_pattern ( ) const
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::dash_pattern ( const std::vector< float > &  value)

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]

xtd::drawing::drawing_2d::dash_style xtd::drawing::pen::dash_style ( ) const
noexcept

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.
Examples
draw_ellipse.cpp, draw_line.cpp, draw_rectangle.cpp, and draw_rounded_rectangle.cpp.

◆ dash_style() [2/2]

xtd::drawing::pen & xtd::drawing::pen::dash_style ( drawing::drawing_2d::dash_style  value)

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]

xtd::drawing::drawing_2d::line_cap xtd::drawing::pen::end_cap ( ) const
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::end_cap ( xtd::drawing::drawing_2d::line_cap  value)

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()

intptr xtd::drawing::pen::handle ( ) const
noexcept

Gets the handle of the pen.

Returns
An intptr that contains the handle of the pen.

◆ line_join() [1/2]

xtd::drawing::drawing_2d::line_join xtd::drawing::pen::line_join ( ) const
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::line_join ( xtd::drawing::drawing_2d::line_join  value)

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
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::miter_limit ( float  value)

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]

xtd::drawing::drawing_2d::line_cap xtd::drawing::pen::start_cap ( ) const
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::start_cap ( xtd::drawing::drawing_2d::line_cap  value)

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()

xtd::drawing::drawing_2d::pen_type xtd::drawing::pen::type ( ) const
noexcept

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]

float xtd::drawing::pen::width ( ) const
noexcept

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]

xtd::drawing::pen & xtd::drawing::pen::width ( float  value)

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.

◆ to_string()

xtd::string xtd::drawing::pen::to_string ( ) const
overridevirtualnoexcept

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>
using namespace 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
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10

Reimplemented from xtd::object.

◆ equals() [1/2]

virtual bool xtd::object::equals ( const object obj) const
virtualnoexcept

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.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals ( const object_a_t &  object_a,
const object_b_t &  object_b 
)
inlinestaticnoexcept

Determines whether the specified object instances are considered equal.

Parameters
object_aThe first object to compare.
object_bThe second object to compare.
Returns
true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
Examples
The following code example compares different objects.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Tom";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "Tom";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "Carol";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
s1 = "";
s2 = "";
console::write_line("object::equals(\"{0}\", \"{1}\") => {2}", s1, s2, object::equals(s1, s2));
}
// This code produces the following output :
//
// object::equals("Tom", "Carol") => false
// object::equals("Tom", "Tom") => true
// object::equals("", "Tom") => false
// object::equals("Carol", "") => false
// object::equals("", "") => true
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.

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