xtd 0.2.0
xtd::drawing::drawing2d::hatch_brush Class Referencefinal

#include <hatch_brush.h>

Definition

Defines a rectangular xtd::drawing::brush with a hatch style, a foreground color, and a background color. This class cannot be inherited.

Namespace
xtd::drawing::drawing2d
Library
xtd.drawing
Remarks
The following illustration shows a rectangle filled with a diagonal brick hatch pattern.
hatch_brush.png
Examples
The following code example demonstrates the use of hatch_brush class.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::drawing::drawing2d;
using namespace xtd::forms;
namespace examples {
class form1 : public form {
public:
form1() {
text("Fill rectangle example");
client_size({680, 340});
}
protected:
void on_paint(paint_event_args& e) override {
form::on_paint(e);
auto back_color = color::navy;
auto fore_color = color::white;
e.graphics().draw_rectangle(pen {fore_color, 4}, rectangle {10, 10, 150, 150});
e.graphics().fill_rectangle(solid_brush {back_color}, rectangle {180, 10, 150, 150});
e.graphics().draw_rectangle(pen {fore_color, 4}, rectangle {180, 10, 150, 150});
e.graphics().fill_rectangle(texture_brush {create_circle_texture(fore_color, back_color)}, rectangle {350, 10, 150, 150});
e.graphics().draw_rectangle(pen {fore_color, 4}, rectangle {350, 10, 150, 150});
e.graphics().draw_rectangle(pen {color::white, 4}, rectangle {520, 10, 150, 150});
e.graphics().fill_rectangle(conical_gradient_brush {point {85, 255}, back_color, fore_color, 0}, rectangle {10, 180, 150, 150});
e.graphics().draw_rectangle(pen {color::white, 4}, rectangle {10, 180, 150, 150});
e.graphics().fill_rectangle(linear_gradient_brush {rectangle {180, 180, 150, 150}, back_color, fore_color, 315}, rectangle {180, 180, 150, 150});
e.graphics().draw_rectangle(pen {color::white, 4}, rectangle {180, 180, 150, 150});
e.graphics().fill_rectangle(radial_gradient_brush {point {425, 255}, fore_color, back_color, 73}, rectangle {350, 180, 150, 150});
e.graphics().draw_rectangle(pen {color::white, 4}, rectangle {350, 180, 150, 150});
}
private:
image create_circle_texture(const color& fore_color, const color& back_color) {
auto texture = bitmap {16, 16};
auto graphics = texture.create_graphics();
graphics.fill_ellipse(solid_brush {back_color}, 1, 1, texture.width() - 2, texture.height() - 2);
graphics.draw_ellipse(pen {fore_color, 2}, 1, 1, texture.width() - 2, texture.height() - 2);
return texture;
}
};
}
auto main()->int {
application::run(examples::form1 {});
}
Examples:
color_picker.cpp, colors.cpp, fill_ellipse.cpp, fill_rectangle.cpp, and fill_rounded_rectangle.cpp.

Constructors

 hatch_brush (xtd::drawing::drawing2d::hatch_style hatch_style, const xtd::drawing::color &fore_color)
 Initializes a new instance of the xtd::drawing::drawing2d::hatch_brush class with the specified xtd::drawing::drawing2d::hatch_style enumeration and foreground color. More...
 
 hatch_brush (xtd::drawing::drawing2d::hatch_style hatch_style, const xtd::drawing::color &fore_color, const xtd::drawing::color &back_color)
 Initializes a new instance of the xtd::drawing::drawing2d::hatch_brush class with the specified xtd::drawing::drawing2d::hatch_style enumeration, foreground color and background color. More...
 

Properties

xtd::drawing::color background_color () const noexcept
 Gets the color of spaces between the hatch lines drawn by this hatch_brush object. More...
 
xtd::drawing::color foreground_color () const noexcept
 Gets the color of hatch lines drawn by this hatch_brush object. More...
 
xtd::drawing::drawing2d::hatch_style hatch_style () const noexcept
 Gets the hatch style of this hatch_brush object. More...
 

Methods

bool equals (const hatch_brush &value) const noexcept override
 

Additional Inherited Members

- Public Member Functions inherited from xtd::drawing::brush
intptr handle () const noexcept
 Gets the handle of the brush. More...
 
bool equals (const brush &value) const noexcept override
 
xtd::ustring to_string () const noexcept override
 Converts this brush object to a human-readable string. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
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 noexcept
 Gets the type of the current instance. More...
 
- Public Member Functions inherited from xtd::iequatable< brush >
virtual bool equals (const brush &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type. More...
 
- Public Member Functions inherited from xtd::iequatable< hatch_brush >
virtual bool equals (const hatch_brush &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type. 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...
 
- Protected Member Functions inherited from xtd::drawing::brush
 brush ()
 Initialize a new instance of brush class. More...
 
void set_native_brush (intptr brush)
 In a derived class, sets a reference to a GDI+ brush object. More...
 

Constructor & Destructor Documentation

◆ hatch_brush() [1/2]

xtd::drawing::drawing2d::hatch_brush::hatch_brush ( xtd::drawing::drawing2d::hatch_style  hatch_style,
const xtd::drawing::color fore_color 
)

Initializes a new instance of the xtd::drawing::drawing2d::hatch_brush class with the specified xtd::drawing::drawing2d::hatch_style enumeration and foreground color.

Parameters
hatch_styleOne of the xtd::drawing::drawing2d::hatch_style values that represents the pattern drawn by this xtd::drawing::drawing2d::hatch_brush.
fore_colorThe xtd::drawing::color structure that represents the color of lines drawn by this xtd::drawing::drawing2d::hatch_brush.
Remarks
The background color is initialized to black.

◆ hatch_brush() [2/2]

xtd::drawing::drawing2d::hatch_brush::hatch_brush ( xtd::drawing::drawing2d::hatch_style  hatch_style,
const xtd::drawing::color fore_color,
const xtd::drawing::color back_color 
)

Initializes a new instance of the xtd::drawing::drawing2d::hatch_brush class with the specified xtd::drawing::drawing2d::hatch_style enumeration, foreground color and background color.

Parameters
hatch_styleOne of the xtd::drawing::drawing2d::hatch_style values that represents the pattern drawn by this xtd::drawing::drawing2d::hatch_brush.
fore_colorThe xtd::drawing::color structure that represents the color of lines drawn by this xtd::drawing::drawing2d::hatch_brush.
back_colorThe xtd::drawing::color structure that represents the color of spaces between the lines drawn by this xtd::drawing::drawing2d::hatch_brush.

Member Function Documentation

◆ background_color()

xtd::drawing::color xtd::drawing::drawing2d::hatch_brush::background_color ( ) const
noexcept

Gets the color of spaces between the hatch lines drawn by this hatch_brush object.

Returns
A xtd::drawing::color structure that represents the background color for this hatch_brush.

◆ foreground_color()

xtd::drawing::color xtd::drawing::drawing2d::hatch_brush::foreground_color ( ) const
noexcept

Gets the color of hatch lines drawn by this hatch_brush object.

Returns
A xtd::drawing::color structure that represents the foreground color for this hatch_brush.

◆ hatch_style()

xtd::drawing::drawing2d::hatch_style xtd::drawing::drawing2d::hatch_brush::hatch_style ( ) const
noexcept

Gets the hatch style of this hatch_brush object.

Returns
One of the xtd::drawing::drawing2d::hatch_style values that represents the pattern of this hatch_brush.

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